#!/usr/bin/perl -w
use strict;
use diagnostics;
#use encoding 'cp1251';
use JSON:: RPC :: Legacy :: Client ;
use Data:: Dumper ;
my $client = new JSON:: RPC :: Legacy :: Client ;
$client -> ua -> credentials (
'localhost:9357' , 'jsonrpc' , 'user' => 'pass' # REPLACE WITH YOUR bitcoin.conf rpcuser/rpcpassword
) ;
my $count = 0 ;
my $uri = 'http://localhost:9357/' ;
my $i = 0 ;
#my $j = 0;
print STDERR "дерьмо \n " ; for ( $i = 1 ; $i <= 40000 ; $i ++ )
{
#sleep (10) unless ($i%500);
#$j = $i;
#for ($j; $j<=$i+100; $j++)
#{
my $obj = {
method => 'getblockhash' ,
params => [ $i ] ,
} ;
my $res = $client -> call ( $uri , $obj ) ;
if ( $res ) {
if ( $res -> is_error ) { print STDERR "Error : " , $res -> error_message , " \n " ; sleep ( 30 ) ; } else {
my $bh = $res -> result ;
$obj = {
method => 'getblock' ,
params => [ $bh ] ,
} ;
$res = $client -> call ( $uri , $obj ) ;
#my $bc = $res->result;
my $tidha = $res -> result -> { 'tx' } ;
#my %tid = %bc{'tx'};
#$obj = {
# method => 'getblock',
# params => [$tid],
#};
$obj = {
method => 'getrawtransaction' ,
params => [ $tid ] ,
} ;
$res = $client -> call ( $uri , $obj ) ;
$obj = {
method => 'decoderawtransaction' ,
params => [ $res -> result ] ,
} ;
$res = $client -> call ( $uri , $obj ) ;
my $voita = $res -> result -> { 'vout' } ;
#print Dumper($voita);
my $awa = $wta -> { 'scriptPubKey' } -> { 'addresses' } ;
#print $aw, "\n";
print $tid , "\n " if ( $aw eq 'Sg2NdZywasiNUADzm5dxt6G1WWKyKkj9Mc' ) ; }
$count ++;
#print Dumper($awa);
;
#while (defined( my $aw = pop @$voita)){
#}
}
#print @$voita, "\n";
#$count = $res->result;
#print $count, "\n";
}
#my $tid = pop @$tidh;
#print $tid;
#print Dumper($tid);
#print Dumper($tidh);
#print Dumper($res->result);
}
} else { print STDERR $client -> status_line , " \n " ; sleep ( 30 ) ; }
#}
#$i = $j;
#print $count," $j", "\n";
#sleep (1);
}
#my $obj = {
#method => 'decoderawtransaction',
#params => [$count],
#};
#my $res = $client->call( $uri, $obj );
#print Dumper($res->result);
IyEvdXNyL2Jpbi9wZXJsIC13CnVzZSBzdHJpY3Q7CnVzZSBkaWFnbm9zdGljczsKI3VzZSBlbmNvZGluZyAnY3AxMjUxJzsKCgogdXNlIEpTT046OlJQQzo6TGVnYWN5OjpDbGllbnQ7CiAgdXNlIERhdGE6OkR1bXBlcjsKIAogIG15ICRjbGllbnQgPSBuZXcgSlNPTjo6UlBDOjpMZWdhY3k6OkNsaWVudDsKIAogICRjbGllbnQtPnVhLT5jcmVkZW50aWFscygKICAgICAnbG9jYWxob3N0OjkzNTcnLCAnanNvbnJwYycsICd1c2VyJyA9PiAncGFzcycgICMgUkVQTEFDRSBXSVRIIFlPVVIgYml0Y29pbi5jb25mIHJwY3VzZXIvcnBjcGFzc3dvcmQKICAgICAgKTsKICBteSAkY291bnQ9MDsKICBteSAkdXJpID0gJ2h0dHA6Ly9sb2NhbGhvc3Q6OTM1Ny8nOwogIG15ICRpID0gMDsKICAjbXkgJGogPSAwOwogIHByaW50IFNUREVSUiAi0LTQtdGA0YzQvNC+IFxuIjsKICBmb3IgKCRpID0gMTsgJGk8PTQwMDAwOyAkaSsrKQogIHsKICAjc2xlZXAgKDEwKSB1bmxlc3MgKCRpJTUwMCk7CiAgIyRqID0gJGk7CiAgI2ZvciAoJGo7ICRqPD0kaSsxMDA7ICRqKyspCiAgI3sKICBteSAkb2JqID0gewogICAgICBtZXRob2QgID0+ICdnZXRibG9ja2hhc2gnLAogICAgICBwYXJhbXMgID0+IFskaV0sCiAgIH07CiAgIAogIG15ICRyZXMgPSAkY2xpZW50LT5jYWxsKCAkdXJpLCAkb2JqICk7CiAgICAgCiAgaWYgKCRyZXMpewogICAgICBpZiAoJHJlcy0+aXNfZXJyb3IpIHsgcHJpbnQgU1RERVJSICJFcnJvciA6ICIsICRyZXMtPmVycm9yX21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