Bitcoin Forum
May 08, 2024, 05:13:37 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: C to Delphi: validate Bitcoin wallet address  (Read 291 times)
flashcoder (OP)
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
September 25, 2017, 02:11:47 AM
 #1

Hello,

i want know if someone here already made some validation of a wallet address in Delphi?

if not, then i'm trying convert a C code that is able to validate a Bitcoin wallet address and is be very hard because i not know much about C language.

Here:https://rosettacode.org/wiki/Bitcoin/address_validation#C, is C code used as reference and below is point until where i'm able to make.

So, someone could help me?

Code:
{$APPTYPE CONSOLE}
{$R *.res}

uses
  SysUtils;

const
  TMPL = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
  SHA256_DIGEST_LENGTH = 32;

function UnBase58(S: PWideChar; Outter: Byte): Integer;
var
  I, J: Integer;
  C: Extended;
  P: PWideChar;
begin
  Result := 0;
  FillChar(Outter, 0, 25);

  for I := 0 to Length(S) do
  begin
    P := StrPos(PWideChar(TMPL), PWideChar(S[I]));

    if P = nil then
      Exit;

    C := P - PWideChar(TMPL);
    for J := 25 downto 0 do
    begin
      C := C + 58 * Outter[J];
      Outter[J] := C mod 256;
      C := C / 256;
    end;

    // if C then Exit;

  end;

  Result := 1;
end;

function Valid(S: PWideChar): Integer;
var
 d, d1, d2: array[0..SHA256_DIGEST_LENGTH] of Byte;
begin
    if UnBase58(S, d) = 0 then Exit;

    ...

end;
Be very wary of relying on JavaScript for security on crypto sites. The site can change the JavaScript at any time unless you take unusual precautions, and browsers are not generally known for their airtight security.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715188417
Hero Member
*
Offline Offline

Posts: 1715188417

View Profile Personal Message (Offline)

Ignore
1715188417
Reply with quote  #2

1715188417
Report to moderator
pooya87
Legendary
*
Offline Offline

Activity: 3444
Merit: 10555



View Profile
September 25, 2017, 04:24:38 AM
 #2

try reading the wiki documentation on how base58 encoding is done https://en.bitcoin.it/wiki/Base58Check_encoding

i also found this: https://github.com/Tinkerforge/generators/blob/master/delphi/Base58.pas
which seems to be Delphi but i am not familiar with this language.

.
.BLACKJACK ♠ FUN.
█████████
██████████████
████████████
█████████████████
████████████████▄▄
░█████████████▀░▀▀
██████████████████
░██████████████
████████████████
░██████████████
████████████
███████████████░██
██████████
CRYPTO CASINO &
SPORTS BETTING
▄▄███████▄▄
▄███████████████▄
███████████████████
█████████████████████
███████████████████████
█████████████████████████
█████████████████████████
█████████████████████████
███████████████████████
█████████████████████
███████████████████
▀███████████████▀
█████████
.
mrf001
Newbie
*
Offline Offline

Activity: 2
Merit: 0


View Profile
June 07, 2018, 03:45:49 AM
 #3

delphi demo。

uses
  DCPconst in '..\dcpcrypt2-2010\DCPconst.pas',
  DCPsha256 in '..\dcpcrypt2-2010\Hashes\DCPsha256.pas',
  DCPbase64 in '..\dcpcrypt2-2010\DCPbase64.pas',
  DCPcrypt2 in '..\dcpcrypt2-2010\DCPcrypt2.pas',

https://rosettacode.org/wiki/Bitcoin/address_validation#Delphi
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!