|
@ -0,0 +1,57 @@ |
|
|
|
|
|
# |
|
|
|
|
|
|
|
|
|
|
|
BEGIN { if (-e $ENV{SITE}.'/lib') { use lib $ENV{SITE}.'/lib'; } } |
|
|
|
|
|
|
|
|
|
|
|
our $dbug=1; |
|
|
|
|
|
print "--- $0\n"; |
|
|
|
|
|
|
|
|
|
|
|
use YAML::Syck qw(Dump); |
|
|
|
|
|
|
|
|
|
|
|
use seed qw(readsalt); |
|
|
|
|
|
use encode qw(mbase58); |
|
|
|
|
|
use CAStore qw(CASRead); |
|
|
|
|
|
use botname qw(botname); |
|
|
|
|
|
use ECKeys qw($keys ecsign ecverif loadKeys eckeygen saveKeys); |
|
|
|
|
|
printf "--- keys %s...\n",Dump($keys); |
|
|
|
|
|
|
|
|
|
|
|
use Genesis qw(createCoinBaseTx); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
my $nonce = &readsalt($ENV{SITE}.'/salts/CBtxi.yml'); |
|
|
|
|
|
printf "=== createCoinBaseTx w/ default message ===\n"; |
|
|
|
|
|
# &createCoinBaseTx($tic,$msg,$nonce,$type,$dif); |
|
|
|
|
|
# using default message ... |
|
|
|
|
|
my ($txaddr,$txcoin) = &createCoinBaseTx(1625714463012468224,undef,$nonce,'CBtxi',($dbug?4:7)); |
|
|
|
|
|
printf "txaddr: %s\n",$txaddr; |
|
|
|
|
|
|
|
|
|
|
|
printf "=== get it from the pool (for verification) ===\n"; |
|
|
|
|
|
my $tx = &CASRead($ENV{SITE}.'/txpool',$txaddr); |
|
|
|
|
|
printf "--- tx %s...\n",Dump($tx); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use TXPOOL qw(isTxValid); |
|
|
|
|
|
$TXPOOL::UTXO->{coinbase} = 100; |
|
|
|
|
|
my $valid = isTxValid($tx); |
|
|
|
|
|
printf "tx: %s is %s\n",$txaddr,($valid?'valid':'rejected'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (0) { |
|
|
|
|
|
my $msg= qq'["coinbase","100","default coinbase"]'; |
|
|
|
|
|
my $sig = &ecsign('coinbase',$msg); |
|
|
|
|
|
printf "- default coinbase: %s\n",$sig; |
|
|
|
|
|
|
|
|
|
|
|
my $key58 = $keys->{coinbase}{public}; |
|
|
|
|
|
print "verification ..."; |
|
|
|
|
|
my $sigok = &ecverif($key58,$sig,$msg); |
|
|
|
|
|
print ($sigok?'ok':'failed'),"\n"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
printf "DBUG %s @%s\n",$::db++,__LINE__; # <------------------------------------- /!\ --- |
|
|
|
|
|
exit $?; |
|
|
|
|
|
|
|
|
|
|
|
1; |
|
|
|
|
|
|
|
|
|
|
|
|