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?
{$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;