public function setup()
 {
     if (!getenv('BITCOINLIB_TEST_AGAINST_RPC')) {
         return $this->markTestSkipped("Not testing against RPC");
     }
     $rpcHost = getenv('BITCOINLIB_RPC_HOST') ?: '127.0.0.1';
     $rpcUser = getenv('BITCOINLIB_RPC_USER') ?: 'bitcoinrpc';
     $rpcPassword = getenv('BITCOINLIB_RPC_PASSWORD') ?: '6Wk1SYL7JmPYoUeWjYRSdqij4xrM5rGBvC4kbJipLVJK';
     $this->client = new Jsonrpcclient(['url' => "http://{$rpcUser}:{$rpcPassword}@{$rpcHost}:8332"]);
     if ($this->client->getinfo() == null) {
         $this->fail("Can't connect to bitcoind");
     }
 }
 public function testSignMessageDataSetAgainstRPC()
 {
     if (!getenv('BITCOINLIB_TEST_AGAINST_RPC')) {
         return $this->markTestSkipped("Not testing against RPC");
     }
     // special case, when undefined we do 1, otherwise we do ENV * 5 (50 on travis)
     $cnt = getenv('BITCOINLIB_EXTENSIVE_TESTING') ? getenv('BITCOINLIB_EXTENSIVE_TESTING') * 5 : 1;
     $rpcHost = getenv('BITCOINLIB_RPC_HOST') ?: '127.0.0.1';
     $rpcUser = getenv('BITCOINLIB_RPC_USER') ?: 'bitcoinrpc';
     $rpcPassword = getenv('BITCOINLIB_RPC_PASSWORD') ?: '6Wk1SYL7JmPYoUeWjYRSdqij4xrM5rGBvC4kbJipLVJK';
     $rpc = new Jsonrpcclient(['url' => "http://{$rpcUser}:{$rpcPassword}@{$rpcHost}:8332"]);
     if ($rpc->getinfo() == null) {
         $this->fail("Can't connect to bitcoind");
     }
     $data = json_decode(file_get_contents(__DIR__ . "/data/signverify.json"), true);
     $data = array_map(function ($k) use($data) {
         return $data[$k];
     }, (array) array_rand($data, $cnt));
     foreach ($data as $row) {
         $privKey = BitcoinLib::WIF_to_private_key($row['wif']);
         $signature = BitcoinLib::signMessage($row['address'], $privKey);
         $this->assertTrue(!!$signature);
         $this->assertTrue(BitcoinLib::verifyMessage($row['address'], $signature, $row['address']));
         $this->assertTrue($rpc->verifymessage($row['address'], $signature, $row['address']));
     }
 }