| 1 |  |  | /* jshint -W101, -W098 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | var blocktrail = require('../'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | var assert = require('assert'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | var crypto = require('crypto'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @type APIClient | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | var client = blocktrail.BlocktrailSDK({ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |     apiKey: process.env.BLOCKTRAIL_SDK_APIKEY || "EXAMPLE_BLOCKTRAIL_SDK_NODEJS_APIKEY", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     apiSecret: process.env.BLOCKTRAIL_SDK_APISECRET || "EXAMPLE_BLOCKTRAIL_SDK_NODEJS_APISECRET", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |     btccom: typeof process.env.BLOCKTRAIL_SDK_BTCCOM !== "undefined" ? JSON.parse(process.env.BLOCKTRAIL_SDK_BTCCOM) : true | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | var cleanTxin = function(txin) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     delete txin.output_confirmed; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     delete txin.multisig; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     delete txin.multisig_addresses; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | var cleanTxout = function(txout) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     if (txout.type === 'witnessscripthash') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         txout.type = 'unknown'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         txout.address = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     if (!txout.spent_hash) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         txout.spent_index = -1; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     delete txout.multisig; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     delete txout.multisig_addresses; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | var cleanTx = function(tx) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         'block_hash', // @TODO | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         'confirmations', 'estimated_change', 'estimated_change_address', 'estimated_value', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         'is_coinbase', 'time', 'version', 'weight', 'witness_hash', 'is_double_spend', 'is_sw_tx', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         'sigops', 'lock_time', 'contains_dust', 'double_spend_in', 'enough_fee', 'first_seen_at', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         'last_seen_at', 'high_priority', 'unconfirmed_inputs' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     ].forEach(function(prop) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         delete tx[prop]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     tx.inputs.forEach(function(txin) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |         cleanTxin(txin); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     tx.outputs.forEach(function(txout) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         cleanTxout(txout); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | var cleanBlock = function(block) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     delete block.confirmations; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     delete block.is_sw_block; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     delete block.created_at; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     delete block.bits; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     delete block.reward_block; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     delete block.reward_fees; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |     delete block.weight; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     delete block.value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 66 |  |  | describe('data api', function() { | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |     it('test address', function(cb) { | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |         client.address("3EU8LRmo5PgcSwnkn6Msbqc8BKNoQ7Xief", function(err, address) { | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |             assert.ifError(err); | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |             assert.ok(address['address']); | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |             assert.equal(address['address'], '3EU8LRmo5PgcSwnkn6Msbqc8BKNoQ7Xief'); | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |             // trim off deprecated fields | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |             delete address.category; | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |             delete address.tag; | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |             delete address.first_seen; | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |             delete address.last_seen; | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |             delete address.total_transactions_in; | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |             delete address.total_transactions_out; | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |             delete address.unconfirmed_utxos; | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |             // trim off new fields | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |             delete address.first_tx; | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |             delete address.last_tx; | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |             assert.deepEqual( | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |                 address, | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |                 require('./test_data/address.3EU8LRmo5PgcSwnkn6Msbqc8BKNoQ7Xief') | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |             ); | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |             cb(); | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |         }); | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |     }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |     it('test addressTransactions', function(cb) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         client.addressTransactions("3EU8LRmo5PgcSwnkn6Msbqc8BKNoQ7Xief", {limit: 20}, function(err, address_txs) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |             assert.ifError(err); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |             assert.ok(address_txs['data']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |             assert.ok(address_txs['total']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |             var expected = require('./test_data/addressTxs.3EU8LRmo5PgcSwnkn6Msbqc8BKNoQ7Xief'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |             var expectedTxMap = {}; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |             expected.data.forEach(function(tx) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |                 cleanTx(tx); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |                 expectedTxMap[tx.hash] = tx; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |             }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |             address_txs.data.forEach(function(tx) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |                 cleanTx(tx); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |                 assert.deepEqual(tx, expectedTxMap[tx.hash]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |             }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |             cb(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |     }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |     it('test addressUnconfirmedTransactions', function(cb) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         client.addressUnconfirmedTransactions("1dice8EMZmqKvrGE4Qc9bUFf9PX3xaYDp", {limit: 23}, function(err, address_txs) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |             assert.ifError(err); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |             assert.ok('data' in address_txs); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |             assert.ok('total' in address_txs); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |             assert.ok(address_txs['total'] >= address_txs['data'].length); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |             cb(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |     }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |     it('test addressUnspentOutputs', function(cb) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         client.addressUnspentOutputs("16dwJmR4mX5RguGrocMfN9Q9FR2kZcLw2z", {limit: 23}, function(err, address_utxo) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |             assert.ifError(err); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |             assert.ok('data' in address_utxo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |             assert.ok('total' in address_utxo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |             assert.ok(address_utxo['total'] >= address_utxo['data'].length); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |             cb(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |     }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |     it('test batchAddressUnspentOutputs', function(cb) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |         this.skip(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         client.batchAddressUnspentOutputs(["16dwJmR4mX5RguGrocMfN9Q9FR2kZcLw2z", "16fVUD4yCuabS153FJGtmLL8tgydsrf6vu"], {limit: 23}, function(err, address_utxo) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |             assert.ifError(err); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |             assert.ok('data' in address_utxo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |             assert.ok('total' in address_utxo); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |             assert.ok(address_utxo['total'] >= address_utxo['data'].length); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |             cb(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     it('test verifyAddress', function(cb) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         client.verifyAddress("16dwJmR4mX5RguGrocMfN9Q9FR2kZcLw2z", "HPMOHRgPSMKdXrU6AqQs/i9S7alOakkHsJiqLGmInt05Cxj6b/WhS7kJxbIQxKmDW08YKzoFnbVZIoTI2qofEzk=", function(err, result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |             assert.ifError(err); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |             assert.ok(result); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |             cb(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |     it('test block by hash', function(cb) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |         client.block("000000000000034a7dedef4a161fa058a2d67a173a90155f3a2fe6fc132e0ebf", function(err, block) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |             assert.ifError(err); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |             assert.ok(block['hash']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |             assert.equal(block['hash'], '000000000000034a7dedef4a161fa058a2d67a173a90155f3a2fe6fc132e0ebf'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |             var expected = require('./test_data/block.000000000000034a7dedef4a161fa058a2d67a173a90155f3a2fe6fc132e0ebf'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |             cleanBlock(block); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |             cleanBlock(expected); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |             assert.deepEqual(block, expected); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |             cb(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |     }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |     it('test block by height', function(cb) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |         client.block(200000, function(err, block) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |             assert.ifError(err); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |             assert.ok(block['hash']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |             assert.equal(block['hash'], '000000000000034a7dedef4a161fa058a2d67a173a90155f3a2fe6fc132e0ebf'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |             cb(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |     }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |     it('test blockTransactions', function(cb) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |         client.blockTransactions("000000000000034a7dedef4a161fa058a2d67a173a90155f3a2fe6fc132e0ebf", {limit: 23}, function(err, block_txs) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |             assert.ifError(err); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |             assert.ok(block_txs['data']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |             assert.ok(block_txs['total']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |             assert.ok(block_txs['data'].length === 23); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |             cb(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |     }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |     it('test allBlocks', function(cb) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |         this.skip(); // @TODO | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |         client.allBlocks({page: 2, limit: 23, sort_dir: 'asc'}, function(err, blocks) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             assert.ifError(err); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |             assert.ok(blocks['data']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |             assert.ok(blocks['total']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |             assert.ok(blocks['data'].length === 23); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |             assert.equal(blocks['data'][0]['hash'], '000000000cd339982e556dfffa9de94744a4135c53eeef15b7bcc9bdeb9c2182'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |             assert.equal(blocks['data'][1]['hash'], '00000000fc051fbbce89a487e811a5d4319d209785ea4f4b27fc83770d1e415f'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |             cb(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |     }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |     it('test blockLatest', function(cb) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |         client.blockLatest(function(err, block) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |             assert.ifError(err); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |             assert.ok(block['hash']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |             cb(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |     }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |     it('test coinbase transaction', function(cb) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |         client.transaction("0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098", function(err, tx) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |             assert.ifError(err); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |             assert.equal(tx['hash'], "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |             assert.equal(tx['enough_fee'], null); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |             cb(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |     }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |     it('test tx 95740451ac22f63c42c0d1b17392a0bf02983176d6de8dd05d6f06944d93e615', function(cb) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |         client.transaction("95740451ac22f63c42c0d1b17392a0bf02983176d6de8dd05d6f06944d93e615", function(err, tx) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |             assert.ifError(err); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |             assert.equal(tx['hash'], "95740451ac22f63c42c0d1b17392a0bf02983176d6de8dd05d6f06944d93e615"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |             var expected = require('./test_data/tx.95740451ac22f63c42c0d1b17392a0bf02983176d6de8dd05d6f06944d93e615'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |             cleanTx(expected); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |             cleanTx(tx); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |             assert.deepEqual(tx, expected); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |             cb(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |     }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |     it('test batch transactions', function(cb) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |         client.transactions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |             "c791b82ed9af681b73eadb7a05b67294c1c3003e52d01e03775bfb79d4ac58d1", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |             "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |             "4bbe6feeb50e47e2de5ef6a9d7378363823611dd07d4a5ea1799da9ae6a21665", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |             "6c0d3156621051a86b8af3f23dfe211e8a17a01bffe3c2b24cbee65139873c6a", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |             "356210d6b8143e23d0cf4d0dae0ac686015a13fe3b2b46b1cc43a71a36c73355", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |             "a40d1eee0cec3d963d8df2870bd642bd3fd07163e864aeb90fa5efe9ea91c998", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |             "1c7e3c9823baa9bb70b09ed666e8a6b3120b07f84429ed41f05d5504bd58f188", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |             "1f0a168f0fceb6e48208b23ffb1ad528acfc11c30ab302d447743f2a0fc5fe80" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |         ], function(err, txs) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |             assert.ifError(err); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |             assert.equal(Object.keys(txs['data']).length, 8); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |             var tx1 = txs['data']["c791b82ed9af681b73eadb7a05b67294c1c3003e52d01e03775bfb79d4ac58d1"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |             assert.equal(tx1['hash'], "c791b82ed9af681b73eadb7a05b67294c1c3003e52d01e03775bfb79d4ac58d1"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |             assert.ok(tx1['confirmations']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |             var tx2 = txs['data']["0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |             assert.equal(tx2['hash'], "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |             var tx8 = txs['data']["1f0a168f0fceb6e48208b23ffb1ad528acfc11c30ab302d447743f2a0fc5fe80"]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |             assert.equal(tx8['hash'], "1f0a168f0fceb6e48208b23ffb1ad528acfc11c30ab302d447743f2a0fc5fe80"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |             assert.ok(!txs['data']['ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |             cb(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |         }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |     }); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  | }); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 265 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 266 |  |  |  |