From f2f5d7e807ac70a60118775f779420ebaaa573ea Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Thu, 16 Apr 2015 20:27:38 -0300 Subject: [PATCH 1/5] work towards testnet support --- lib/data/genesis.js | 13 +++++++++++-- lib/networkmonitor.js | 1 + lib/node.js | 5 +++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/data/genesis.js b/lib/data/genesis.js index 46bf2f59..f272c3fa 100644 --- a/lib/data/genesis.js +++ b/lib/data/genesis.js @@ -9,5 +9,14 @@ module.exports = { '000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a6' + '7962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b' + '8d578a4c702b6bf11d5fac00000000', 'hex'), - testnet: new Buffer('') -} + testnet: new Buffer('010000000000000000000000000000000000000000000000000000000000' + + '0000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a5132' + + '3a9fb8aa4b1e5e4adae5494dffff001d1aa4ae1801010000000100000000' + + '00000000000000000000000000000000000000000000000000000000ffff' + + 'ffff4d04ffff001d0104455468652054696d65732030332f4a616e2f3230' + + '3039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f' + + '6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01' + + '000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a6' + + '7962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b' + + '8d578a4c702b6bf11d5fac00000000', 'hex') +}; diff --git a/lib/networkmonitor.js b/lib/networkmonitor.js index 9e87523c..437dff24 100644 --- a/lib/networkmonitor.js +++ b/lib/networkmonitor.js @@ -69,6 +69,7 @@ NetworkMonitor.prototype.requestBlocks = function(locator) { $.checkArgument(_.isArray(locator) && _.isUndefined(locator[0]) || _.isString(locator[0]), 'start must be a block hash string array'); + console.log('request blocks', locator); this.peer.sendMessage(messages.GetBlocks({ starts: locator, //stop: '000000002c05cc2e78923c34df87fd108b22221ac6076c18f3ade378a4d915e9' // TODO: remove this!!! diff --git a/lib/node.js b/lib/node.js index 984ab2b6..767cea7b 100644 --- a/lib/node.js +++ b/lib/node.js @@ -53,7 +53,7 @@ BitcoreNode.create = function(opts) { ); var rpc = opts.rpc || Promise.promisifyAll(new RPC(opts.RPC)); - var transactionService = opts.transactionService || new TransactionService({ + var transactionService = opts.transactionService || new TransactionService({ rpc: rpc, database: database }); @@ -75,6 +75,7 @@ BitcoreNode.create = function(opts) { BitcoreNode.prototype.initialize = function() { var self = this; + setInterval(function() { if (!self.blockchain) { // not ready yet @@ -99,6 +100,7 @@ BitcoreNode.prototype.initialize = function() { // Annotate block with extra data from the chain block.height = self.blockchain.height[block.id]; block.work = self.blockchain.work[block.id]; + console.log('>block', block.id, 'height', block.height); return Promise.each(blockchainChanges.unconfirmed, function(hash) { return self.blockService.unconfirm(self.blockCache[hash]); @@ -144,7 +146,6 @@ BitcoreNode.prototype.start = function() { this.blockService.getBlockchain().then(function(blockchain) { if (!blockchain) { - console.log('nothing'); self.blockchain = new BlockChain(); self.bus.process(genesis); } else { From 029e2ef9999a798457fc732593e1133d90472203 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Wed, 22 Apr 2015 16:52:05 -0300 Subject: [PATCH 2/5] optimize performance and fix testnet --- config/testnet.yml | 16 +++++++ lib/networkmonitor.js | 10 +++-- lib/node.js | 11 +++-- lib/services/block.js | 35 ++++++++------- lib/services/transaction.js | 88 ++++++++++++++----------------------- 5 files changed, 81 insertions(+), 79 deletions(-) create mode 100644 config/testnet.yml diff --git a/config/testnet.yml b/config/testnet.yml new file mode 100644 index 00000000..313e99cd --- /dev/null +++ b/config/testnet.yml @@ -0,0 +1,16 @@ +BitcoreNode: + LevelUp: ./testnet-db + network: testnet + NetworkMonitor: + host: localhost + port: 18333 +Reporter: none # none, simple, matrix +BitcoreHTTP: + host: localhost + port: 8080 +RPC: + user: user + pass: password + protocol: http + host: 127.0.0.1 + port: 18332 diff --git a/lib/networkmonitor.js b/lib/networkmonitor.js index 437dff24..2bfbd692 100644 --- a/lib/networkmonitor.js +++ b/lib/networkmonitor.js @@ -9,13 +9,16 @@ var $ = bitcore.util.preconditions; var _ = bitcore.deps._; var p2p = require('bitcore-p2p'); var Peer = p2p.Peer; -var messages = new p2p.Messages(); function NetworkMonitor(eventBus, peer) { $.checkArgument(eventBus); $.checkArgument(peer); this.bus = eventBus; this.peer = peer; + this.messages = new p2p.Messages({ + network: this.peer.network, + magicNumber: this.peer.network.networkMagic.readUInt32LE(0) + }); this.setupPeer(peer); } util.inherits(NetworkMonitor, EventEmitter); @@ -41,7 +44,7 @@ NetworkMonitor.prototype.setupPeer = function(peer) { peer.on('inv', function(m) { self.emit('inv', m.inventory); // TODO only ask for data if tx or block is unknown - peer.sendMessage(messages.GetData(m.inventory)); + peer.sendMessage(self.messages.GetData(m.inventory)); }); peer.on('tx', function(m) { self.bus.process(m.transaction) @@ -69,8 +72,7 @@ NetworkMonitor.prototype.requestBlocks = function(locator) { $.checkArgument(_.isArray(locator) && _.isUndefined(locator[0]) || _.isString(locator[0]), 'start must be a block hash string array'); - console.log('request blocks', locator); - this.peer.sendMessage(messages.GetBlocks({ + this.peer.sendMessage(this.messages.GetBlocks({ starts: locator, //stop: '000000002c05cc2e78923c34df87fd108b22221ac6076c18f3ade378a4d915e9' // TODO: remove this!!! })); diff --git a/lib/node.js b/lib/node.js index 767cea7b..e1c6f8e3 100644 --- a/lib/node.js +++ b/lib/node.js @@ -76,6 +76,8 @@ BitcoreNode.prototype.initialize = function() { var self = this; + var prevHeight = 0; + var statTimer = 5 * 1000; setInterval(function() { if (!self.blockchain) { // not ready yet @@ -83,8 +85,10 @@ BitcoreNode.prototype.initialize = function() { } var tipHash = self.blockchain.tip; var block = self.blockCache[tipHash]; - console.log('block', block.id, 'height', block.height); - }, 5 * 1000); + var delta = block.height - prevHeight; + prevHeight = block.height; + console.log(block.id, block.height, 'vel', delta * 1000 / statTimer, 'b/s'); + }, statTimer); this.bus.register(bitcore.Block, function(block) { @@ -100,7 +104,8 @@ BitcoreNode.prototype.initialize = function() { // Annotate block with extra data from the chain block.height = self.blockchain.height[block.id]; block.work = self.blockchain.work[block.id]; - console.log('>block', block.id, 'height', block.height); + + //console.log('block', block.id, block.height); return Promise.each(blockchainChanges.unconfirmed, function(hash) { return self.blockService.unconfirm(self.blockCache[hash]); diff --git a/lib/services/block.js b/lib/services/block.js index e360ef1b..0353685b 100644 --- a/lib/services/block.js +++ b/lib/services/block.js @@ -200,7 +200,9 @@ BlockService.prototype.getLatest = function() { return self.getBlock(blockHash); }).catch(LevelUp.errors.NotFoundError, function() { + return null; + }); }; @@ -251,6 +253,7 @@ BlockService.prototype.confirm = function(block, ops) { //console.log(4); self._setBlockByTs(ops, block); + //console.log(4.1); self._setTip(ops, block); //console.log(5); @@ -471,23 +474,23 @@ BlockService.prototype.getBlockchain = function() { }; return self.database.getAsync(Index.tip) - .catch(function(err) { - if (err.notFound) { - return undefined; - } - throw err; - }) - .then(function(tip) { - if (!tip) { - console.log('No tip found'); - return; - } - console.log('Tip is', tip); - blockchain.tip = tip; - return fetchUnlessGenesis(tip).then(function() { - return blockchain; + .catch(function(err) { + if (err.notFound) { + return undefined; + } + throw err; + }) + .then(function(tip) { + if (!tip) { + console.log('No tip found'); + return; + } + console.log('Tip is', tip); + blockchain.tip = tip; + return fetchUnlessGenesis(tip).then(function() { + return blockchain; + }); }); - }); }; module.exports = BlockService; diff --git a/lib/services/transaction.js b/lib/services/transaction.js index a704bc12..b0b01d76 100644 --- a/lib/services/transaction.js +++ b/lib/services/transaction.js @@ -25,7 +25,7 @@ var _ = bitcore.deps._; var $ = bitcore.util.preconditions; var NULLTXHASH = bitcore.util.buffer.emptyBuffer(32).toString('hex'); -var GENESISTX = '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b' +var GENESISTX = '4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b'; var helper = function(name) { return function(txId, output) { @@ -50,15 +50,15 @@ var helperAddress = function(index) { }; var Index = { - output: 'txo-', // txo-- -> serialized Output - spent: 'txs-', // txo---- -> block height of confirmation for spend - address: 'txa-', // txa-
-- -> Output + output: 'txo-', // txo-- -> serialized Output + spent: 'txs-', // txo---- -> block height of confirmation for spend + address: 'txa-', // txa-
-- -> Output addressSpent: 'txas-', // txa-
-- -> { - // heightSpent: number, (may be -1 for unconfirmed tx) - // spentTx: string, spentTxInputIndex: number, spendInput: Input - // } - transaction: 'btx-' // btx- -> block in main chain that confirmed the tx -} + // heightSpent: number, (may be -1 for unconfirmed tx) + // spentTx: string, spentTxInputIndex: number, spendInput: Input + // } + transaction: 'btx-' // btx- -> block in main chain that confirmed the tx +}; _.extend(Index, { getOutput: helper(Index.output), @@ -76,7 +76,7 @@ _.extend(Index, { } }); -function TransactionService (opts) { +function TransactionService(opts) { opts = _.extend({}, opts); this.database = opts.database || Promise.promisifyAll(new LevelUp(config.get('LevelUp'))); this.rpc = opts.rpc || Promise.promisifyAll(new RPC(config.get('RPC'))); @@ -91,7 +91,6 @@ TransactionService.transactionRPCtoBitcore = function(rpcResponse) { }; TransactionService.prototype.getTransaction = function(transactionId) { - var self = this; if (transactionId === GENESISTX) { @@ -106,27 +105,24 @@ TransactionService.prototype.getTransaction = function(transactionId) { }; TransactionService.prototype._confirmOutput = function(ops, block, transaction) { + var txid = transaction.id; return function(output, index) { ops.push({ type: 'put', - key: Index.getOutput(transaction.id, index), + key: Index.getOutput(txid, index), value: output.toJSON() }); var address; - // TODO: Move this logic to bitcore - if (output.script.isPublicKeyOut()) { - var hash = bitcore.crypto.Hash.sha256ripemd160(output.script.chunks[0].buf); - address = new bitcore.Address(hash, bitcore.Networks.defaultNetwork, bitcore.Address.PayToPublicKeyHash); - } else if (output.script.isPublicKeyHashOut() || output.script.isScriptHashOut()) { + if (output.script.isPublicKeyHashOut() || output.script.isScriptHashOut()) { address = output.script.toAddress(); } if (address) { + var out4addr = output.toObject(); + out4addr.heightConfirmed = block.height; ops.push({ type: 'put', - key: Index.getOutputsForAddress(address, transaction.id, index), - value: JSON.stringify(_.extend(output.toObject(), { - heightConfirmed: block.height - })) + key: Index.getOutputsForAddress(address, txid, index), + value: JSON.stringify(out4addr) }); } }; @@ -134,13 +130,14 @@ TransactionService.prototype._confirmOutput = function(ops, block, transaction) TransactionService.prototype._confirmInput = function(ops, block, transaction) { var self = this; + var txid = transaction.id; return function(input, index) { if (input.prevTxId.toString('hex') === NULLTXHASH) { return Promise.resolve(); } ops.push({ type: 'put', - key: Index.getOutput(transaction.id, index), + key: Index.getOutput(txid, index), value: JSON.stringify(_.extend(input.toObject(), { heightConfirmed: block.height })) @@ -151,15 +148,14 @@ TransactionService.prototype._confirmInput = function(ops, block, transaction) { } return Promise.try(function() { - return self._getAddressForInput(input) - }).then(function(address) { + var address = self._getAddressForInput(input); if (address) { ops.push({ type: 'put', - key: Index.getSpentOutputsForAddress(address, transaction.id, index), + key: Index.getSpentOutputsForAddress(address, txid, index), value: JSON.stringify({ heightSpent: block.height, - spentTx: transaction.id, + spentTx: txid, spentTxInputIndex: index, spendInput: input.toObject() }) @@ -171,29 +167,8 @@ TransactionService.prototype._confirmInput = function(ops, block, transaction) { TransactionService.prototype._getAddressForInput = function(input) { var script = input.script; - var self = this; - - if (script.isPublicKeyHashIn()) { - var hash = bitcore.crypto.Hash.sha256ripemd160(script.chunks[0].buf); - return new bitcore.Address( - hash, bitcore.Networks.defaultNetwork, bitcore.Address.PayToPublicKeyHash - ); - } else if (script.isPublicKeyIn()) { - /* - return self.getTransaction(input.prevTxId.toString('hex')).then(function(transaction) { - var outputScript = transaction.outputs[input.outputIndex].script; - if (outputScript.isPublicKeyOut()) { - return new bitcore.Address( - bitcore.crypto.Hash.sha256ripemd160(outputScript.chunks[0].buf), - bitcore.Networks.defaultNetwork, bitcore.Address.PayToPublicKeyHash - ); - } - return; - }); - */ - } else { - return new bitcore.Script(script.chunks[script.chunks.length - 1]).toAddress(); - } + // TODO: move this to bitcore + return new bitcore.Script(script.chunks[script.chunks.length - 1]).toAddress(); }; TransactionService.prototype._confirmTransaction = function(ops, block, transaction) { @@ -203,11 +178,12 @@ TransactionService.prototype._confirmTransaction = function(ops, block, transact key: Index.getBlockForTransaction(transaction), value: block.id }); - return Promise.all( + var confirmFunctions = _.map(transaction.outputs, self._confirmOutput(ops, block, transaction)) - .concat( - _.map(transaction.inputs, self._confirmInput(ops, block, transaction)) - )); + .concat( + _.map(transaction.inputs, self._confirmInput(ops, block, transaction)) + ); + return Promise.all(confirmFunctions); }; TransactionService.prototype._unconfirmTransaction = function(ops, block, transaction) { @@ -219,9 +195,9 @@ TransactionService.prototype._unconfirmTransaction = function(ops, block, transa }); return Promise.all( _.map(transaction.outputs, self._unconfirmOutput(ops, block, transaction)) - .concat( - _.map(transaction.inputs, self._unconfirmInput(ops, block, transaction)) - )); + .concat( + _.map(transaction.inputs, self._unconfirmInput(ops, block, transaction)) + )); }; module.exports = TransactionService; From 845d4daeb782565120dfff3a26bc70285acc1947 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Fri, 24 Apr 2015 15:18:02 -0300 Subject: [PATCH 3/5] fix tests --- test/networkmonitor.js | 1 + test/services/transaction.js | 115 ++++++++++++++++------------------- 2 files changed, 55 insertions(+), 61 deletions(-) diff --git a/test/networkmonitor.js b/test/networkmonitor.js index 40c9d560..3674eff9 100644 --- a/test/networkmonitor.js +++ b/test/networkmonitor.js @@ -25,6 +25,7 @@ describe('NetworkMonitor', function() { mockBlock.id = 'asd'; busMock = new EventBus(); peerMock = new EventEmitter(); + peerMock.network = Networks.testnet; peerMock.sendMessage = sinon.spy(); peerMock.connect = function() { this.emit('ready'); diff --git a/test/services/transaction.js b/test/services/transaction.js index ac07a991..4994ad3a 100644 --- a/test/services/transaction.js +++ b/test/services/transaction.js @@ -71,27 +71,26 @@ describe('TransactionService', function() { it('confirms correctly the first transaction on genesis block', function(callback) { var ops = []; service._confirmTransaction(ops, genesisBlock, genesisTx).then(function() { - ops.map(function(k) { + var opsObj = ops.map(function(k) { if (bitcore.util.js.isValidJSON(k.value)) { k.value = JSON.parse(k.value); } return k; - }).should.deep.equal([ - { type: 'put', - key: 'btx-4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b', - value: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f' }, - { type: 'put', - key: 'txo-4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b-0', - value: - { satoshis: 5000000000, - script: '65 0x04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f OP_CHECKSIG' } }, - { type: 'put', - key: 'txa-1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa-4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b-0', - value: - { satoshis: 5000000000, - script: '65 0x04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f OP_CHECKSIG', - heightConfirmed: 0} } - ]); + }); + opsObj.should.deep.equal([{ + type: 'put', + key: 'btx-4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b', + value: '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f' + }, { + type: 'put', + key: 'txo-4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b-0', + value: { + satoshis: 5000000000, + script: '65 0x04678afdb0fe5548271967f1a67130b7105cd6a828e03909' + + 'a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7b' + + 'a0b8d578a4c702b6bf11d5f OP_CHECKSIG' + } + }]); callback(); }); }); @@ -113,52 +112,46 @@ describe('TransactionService', function() { k.value = JSON.parse(k.value); } return k; - }).should.deep.equal([ - { type: 'put', - key: 'btx-f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16', - value: '00000000d1145790a8694403d4063f323d499e655c83426834d4ce2f8dd4a2ee' }, - { type: 'put', - key: 'txo-f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16-0', - value: - { satoshis: 1000000000, - script: '65 0x04ae1a62fe09c5f51b13905f07f06b99a2f7159b2225f374cd378d71302fa28414e7aab37397f554a7df5f142c21c1b7303b8a0626f1baded5c72a704f7e6cd84c OP_CHECKSIG' } }, - { type: 'put', - key: 'txa-1Q2TWHE3GMdB6BZKafqwxXtWAWgFt5Jvm3-f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16-0', - value: - { satoshis: 1000000000, - script: '65 0x04ae1a62fe09c5f51b13905f07f06b99a2f7159b2225f374cd378d71302fa28414e7aab37397f554a7df5f142c21c1b7303b8a0626f1baded5c72a704f7e6cd84c OP_CHECKSIG', - heightConfirmed: 170 } }, - { type: 'put', - key: 'txo-f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16-1', - value: - { satoshis: 4000000000, - script: '65 0x0411db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3 OP_CHECKSIG' } }, - { type: 'put', - key: 'txa-12cbQLTFMXRnSzktFkuoG3eHoMeFtpTu3S-f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16-1', - value: - { satoshis: 4000000000, - script: '65 0x0411db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3 OP_CHECKSIG', - heightConfirmed: 170 } }, - { type: 'put', - key: 'txo-f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16-0', - value: - { prevTxId: '0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9', + }).should.deep.equal([{ + type: 'put', + key: 'btx-f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16', + value: '00000000d1145790a8694403d4063f323d499e655c83426834d4ce2f8dd4a2ee' + }, { + type: 'put', + key: 'txo-f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16-0', + value: { + satoshis: 1000000000, + script: '65 0x04ae1a62fe09c5f51b13905f07f06b99a2f7159b2225f374cd378d71302fa28414e7aab37397f554a7df5f142c21c1b7303b8a0626f1baded5c72a704f7e6cd84c OP_CHECKSIG' + } + }, { + type: 'put', + key: 'txo-f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16-1', + value: { + satoshis: 4000000000, + script: '65 0x0411db93e1dcdb8a016b49840f8c53bc1eb68a382e97b1482ecad7b148a6909a5cb2e0eaddfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8643f656b412a3 OP_CHECKSIG' + } + }, { + type: 'put', + key: 'txo-f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16-0', + value: { + prevTxId: '0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9', + outputIndex: 0, + sequenceNumber: 4294967295, + script: '71 0x304402204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd410220181522ec8eca07de4860a4acdd12909d831cc56cbbac4622082221a8768d1d0901', + heightConfirmed: 170 + } + }, ]); + /* TODO: This should work if address spent is accepted for public key. Add test for P2PKH if not accepted + * { type: 'put', + key: 'txas-12cbQLTFMXRnSzktFkuoG3eHoMeFtpTu3S-f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16-0', + value: + { heightSpent: 170, + spentTx: 'f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16', + spentTxInputIndex: 0, + spendInput: { prevTxId: '0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9', outputIndex: 0, sequenceNumber: 4294967295, - script: '71 0x304402204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd410220181522ec8eca07de4860a4acdd12909d831cc56cbbac4622082221a8768d1d0901', - heightConfirmed: 170 } }, - ]); - /* TODO: This should work if address spent is accepted for public key. Add test for P2PKH if not accepted - * { type: 'put', - key: 'txas-12cbQLTFMXRnSzktFkuoG3eHoMeFtpTu3S-f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16-0', - value: - { heightSpent: 170, - spentTx: 'f4184fc596403b9d638783cf57adfe4c75c605f6356fbc91338530e9831e9e16', - spentTxInputIndex: 0, - spendInput: { prevTxId: '0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9', - outputIndex: 0, - sequenceNumber: 4294967295, - script: '71 0x304402204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd410220181522ec8eca07de4860a4acdd12909d831cc56cbbac4622082221a8768d1d0901' }}}]);*/ + script: '71 0x304402204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd410220181522ec8eca07de4860a4acdd12909d831cc56cbbac4622082221a8768d1d0901' }}}]);*/ callback(); }); }); From 349299e26b4d6aa9e8b45673540c17fcd0639d42 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Sat, 25 Apr 2015 20:14:23 -0300 Subject: [PATCH 4/5] update package.json --- lib/networkmonitor.js | 1 - package.json | 22 +++++----------------- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/lib/networkmonitor.js b/lib/networkmonitor.js index 2bfbd692..fd82714b 100644 --- a/lib/networkmonitor.js +++ b/lib/networkmonitor.js @@ -17,7 +17,6 @@ function NetworkMonitor(eventBus, peer) { this.peer = peer; this.messages = new p2p.Messages({ network: this.peer.network, - magicNumber: this.peer.network.networkMagic.readUInt32LE(0) }); this.setupPeer(peer); } diff --git a/package.json b/package.json index a5cfec7d..915775c0 100644 --- a/package.json +++ b/package.json @@ -5,29 +5,17 @@ "author": "BitPay ", "repository": "git://github.com/bitpay/bitcore-node.git", "contributors": [ - { - "name": "Matias Alejo Garcia", - "email": "ematiu@gmail.com" - }, { "name": "Manuel Araoz", "email": "manuelaraoz@gmail.com" }, { - "name": "Mario Colque", - "email": "colquemario@gmail.com" + "name": "Yemel Jardi", + "email": "angel.jardi@gmail.com" }, { - "name": "Gustavo Cortez", - "email": "cmgustavo83@gmail.com" - }, - { - "name": "Juan Ignacio Sosa Lopez", - "email": "bechilandia@gmail.com" - }, - { - "name": "Ivan Socolsky", - "email": "jungans@gmail.com" + "name": "Esteban Ordano", + "email": "eordano@gmail.com" } ], "bugs": { @@ -47,7 +35,7 @@ "async": "0.9.0", "bitcoind-rpc": "^0.2.1", "bitcore": "bitpay/bitcore", - "bitcore-p2p": "^0.11.0", + "bitcore-p2p": "^0.13.0", "bluebird": "^2.9.12", "body-parser": "^1.12.0", "bufferput": "bitpay/node-bufferput", From 7076a006a041d4138a6d156da53fefd724894503 Mon Sep 17 00:00:00 2001 From: Manuel Araoz Date: Sat, 25 Apr 2015 20:19:43 -0300 Subject: [PATCH 5/5] fix comment formatting --- lib/services/transaction.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/services/transaction.js b/lib/services/transaction.js index b0b01d76..e4987d76 100644 --- a/lib/services/transaction.js +++ b/lib/services/transaction.js @@ -53,7 +53,8 @@ var Index = { output: 'txo-', // txo-- -> serialized Output spent: 'txs-', // txo---- -> block height of confirmation for spend address: 'txa-', // txa-
-- -> Output - addressSpent: 'txas-', // txa-
-- -> { + addressSpent: 'txas-', + // txa-
-- -> { // heightSpent: number, (may be -1 for unconfirmed tx) // spentTx: string, spentTxInputIndex: number, spendInput: Input // }