1

I took a script to translate the bitcoin address to hash160:
http://lenschulwitz.com/b58/base58perl.txt
replaced the lines for working with the list from the file:

#Sample test taken from https://en.bitcoin.it/wiki/Technical_background_of_version_1_Bitcoin_addresses.
my $base58_encoded_address = "16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM";
print "\nRunning tests for bitcoin address $base58_encoded_address\n";
print "Bitcoin address is valid.  Address type: '", check_bitcoin_address($base58_encoded_address), "'.\n";
my $binary_address = decodebase58tohex($base58_encoded_address);
print "Binary hexadecimal representation is: $binary_address\n";
my $reencoded_base58 = encodebase58fromhex($binary_address);
print "Re-encoded back to Base58 is: $reencoded_base58\n\n";

to:

my $fileSrc = 'base58.txt';
open my $fhSrc, $fileSrc or die "Could not open $fileSrc: $!";

my $fileDest = 'hex.txt';
open(my $fhDest, '>>', $fileDest) or die "Could not open file $fileDest: $!";

while( my $base58_encoded_address = <$fhSrc>)  {   
  my $binary_address = decodebase58tohex($base58_encoded_address);
  say $fhDest $binary_address, 2, 40;
}

close $fhSrc;
close $fhDest;

But this script stops and does not work with bech32 addresses, tell me what needs to be added so that it works with bech32. Or maybe someone has a similar script for converting addresses for the brainflayer?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.