Commit Graph

345 Commits

Author SHA1 Message Date
Chris Kleeschulte
e87f628e7a Merge pull request #439 from braydonf/zmqcheck
bitcoind: added zmq precondition
2016-06-02 14:11:59 -04:00
Braydon Fuller
cf16a23408 bitcoind: added zmq precondition
Adds a state check that transaction and block events are over the same host
and port. This is to make sure that block events can be subscribed to and
that the tip of the chain stays up to date for correct confirmation counts.
2016-06-01 19:50:45 -04:00
Braydon Fuller
814576953c bitcoind: relative spawn.datadir handling
Will expand the datadir into an absolute path based on the location
of the configuration file. This is to avoid unexpected behavior in regards
to the location of configuration files.
2016-06-01 11:33:06 -04:00
Braydon Fuller
aa7f0d7c60 test: remove duplicated test 2016-05-26 10:23:42 -04:00
Braydon Fuller
e8a35e2bb5 bitcoind: bug with getting block hash from address
Fixes an issue where passing an address as the blockArg would get the blockhash
for the parsed integer of the address. `parseInt` would parse the address as
an integer and then get the block hash for 1. A regular expression now checks
that the string is numeric with only 0-9 and the length is less than 40, the
size of a ripemd160, and also less than the length of a sha256 hash.
2016-05-26 10:15:42 -04:00
Braydon Fuller
c7ec2dcc89 test: bitcoind test for undefined scriptPubKey.addresses 2016-05-26 09:16:08 -04:00
Braydon Fuller
2dddf01bb0 test: coverage for spawnChildProcess 2016-05-24 17:11:02 -04:00
Braydon Fuller
f76b206178 test: coverage for getBlockHeader 2016-05-24 16:39:22 -04:00
Braydon Fuller
1d9b89f187 test: coverage for getAddressHistory 2016-05-24 16:29:36 -04:00
Braydon Fuller
0cb795d980 test: add bitcoind test for early shutdown while connecting 2016-05-24 16:22:41 -04:00
Braydon Fuller
52cf300858 test: coverage for bitcoind getAddressSummary 2016-05-24 15:13:41 -04:00
Braydon Fuller
0c820c5987 test: unit tests for bitcoind address details 2016-05-24 14:30:54 -04:00
Braydon Fuller
86b1acd0be test: coverage for bitcoind getAddressUnspentOutputs 2016-05-24 14:06:03 -04:00
Braydon Fuller
9c90f05c73 test: more coverage for bitcoind 2016-05-24 13:35:08 -04:00
Braydon Fuller
3fef6f5ffc test: increase test coverage of bitcoind service 2016-05-24 13:07:51 -04:00
Braydon Fuller
35a1b6dd04 test: more coverage for bitcoind service
tests for catching errors in #_initChain
2016-05-24 10:21:28 -04:00
Braydon Fuller
ea3c813d51 test: check that caching is working 2016-05-23 16:47:57 -04:00
Braydon Fuller
2a53aad34a test: add test for respawn bitcoind 2016-05-23 16:21:03 -04:00
Braydon Fuller
f1a9f6d066 test: stub logging in bitcoind tests 2016-05-23 15:58:54 -04:00
Braydon Fuller
85a302ee9d test: unit tests for zmq socket setup 2016-05-23 15:57:38 -04:00
Braydon Fuller
a4888e5354 test: increase test coverage for lib/node.js 2016-05-23 15:45:13 -04:00
Braydon Fuller
202971ec0c test: increase test coverage for bitcoind
adds tests for subscribing with addresses
2016-05-23 15:44:33 -04:00
Braydon Fuller
584dd2cb98 test: add unit test for node getNetworkName 2016-05-23 13:46:03 -04:00
Braydon Fuller
cd9bbc8661 scaffold: expanded v2 config checks 2016-05-23 11:30:57 -04:00
Braydon Fuller
28ff52ece6 tests: add tests for addresstxid event 2016-05-18 11:20:23 -04:00
Braydon Fuller
6fbadb6c42 test: stub logging in unit tests 2016-05-18 00:33:57 -04:00
Braydon Fuller
bf080422ed web: get remoteAddress for socket with cloudflare header 2016-05-18 00:17:45 -04:00
Braydon Fuller
4df9b5f6cf bitcoind: add addresstxid event 2016-05-17 22:46:38 -04:00
Braydon Fuller
a48bcaf900 web: added logging for web socket events 2016-05-17 18:16:56 -04:00
Braydon Fuller
fa6474e85f bitcoind: handle block height number as string 2016-05-16 18:01:12 -04:00
Braydon Fuller
8f11a33834 test: add getBlockOverview unit tests and refactor 2016-05-16 17:34:40 -04:00
Braydon Fuller
cd4432652d main: remove transaction with populate methods
The methods populateInputs and populateSpentInfo are nolonger necessary or used
now that there is is getDetailedTransaction.
2016-05-13 18:52:12 -04:00
Braydon Fuller
8bddf4f0d6 bitcoind: add getDetailedTransaction method
Adds a new method getDetailedTransaction with a standard JavaScript object
with block information, address, amounts and fees. And removes the
getTransactionWithBlockInfo method since this new method is equivalent,
and will serialize over an API correctly.

Also includes a new method getBlockOverview to get the txids for a block,
that can be combined with getDetailedTransaction for viewing block
transactions with additional information.
2016-05-13 16:50:49 -04:00
Braydon Fuller
b597a05cb4 bitcoind: camelCase result from getBlockHeader
for consistency with other methods
2016-05-11 11:39:14 -04:00
Braydon Fuller
d399e9acea bitcoind: camelCase getInfo results
for consistency with other bitcoind api responses
2016-05-11 11:16:04 -04:00
Braydon Fuller
4757edc570 test: add missing property checks 2016-05-10 19:40:29 -04:00
Braydon Fuller
791047c10d bitcoind: bump max tx history default to 50 2016-05-10 19:30:36 -04:00
Braydon Fuller
8b0d16d5a3 test: check callcount for retry in bitcoind spawn child method 2016-05-10 18:54:02 -04:00
Braydon Fuller
75c43559d4 bitcoind: paginate txids in address summary
so that one request doesn't yield a 80MB response
2016-05-10 13:48:56 -04:00
Braydon Fuller
b0290899ce bitcoind: handle empty input from pid file 2016-04-28 16:19:33 -04:00
Braydon Fuller
2e912af9b4 bitcoind: subscribe to zmq event closer to 100% sync
Instead of subscribing at >= 0.995 subscribe at >= 0.9999 progress
2016-04-28 13:13:51 -04:00
Braydon Fuller
24d1bc82e9 logger: added option to disable formatting
- systemd journalctl includes timestamps in log messages already
- updated logger to use console.error, console.warn, console.info, and etc.
2016-04-27 13:46:50 -04:00
Braydon Fuller
ea792b692f scaffold: remove outdated logging of db service sync status 2016-04-27 12:00:47 -04:00
Braydon Fuller
92bae5f09a general: code cleanup, refactoring and formatting 2016-04-27 11:36:26 -04:00
Braydon Fuller
c1e9d5a3d9 test: added tests for stopSpawnedBitcoin 2016-04-26 17:29:40 -04:00
Braydon Fuller
c63e98f061 bitcoind: limit tx history range 2016-04-22 16:51:56 -04:00
Braydon Fuller
5e6600162a test: add unit test for getaddressunspentoutputs with mempool 2016-04-22 12:48:16 -04:00
Braydon Fuller
b901e10c9d bitcoind: update unspentoutputs with mempool 2016-04-21 17:13:24 -04:00
Braydon Fuller
d1cf9deef0 bitcoind: parse ints for pagination 2016-04-20 15:35:43 -04:00
Braydon Fuller
587602d080 bitcoind: stop failsafe timeout 2016-04-20 13:03:18 -04:00
Braydon Fuller
2015514e78 test: increase timeout for check synced test 2016-04-20 12:05:15 -04:00
Braydon Fuller
3e2492e6d4 scaffold: detect incompatible config 2016-04-20 11:55:45 -04:00
Braydon Fuller
019bc2a58c bitcoind: load network bitcoin.conf and set defaults 2016-04-20 11:41:02 -04:00
Braydon Fuller
c3dab07b30 bitcoind: fix clearInterval issue with Node.js 0.12 2016-04-19 20:27:52 -04:00
Braydon Fuller
40e7b24ea9 test: fix unstubbed uncaughException 2016-04-19 20:10:32 -04:00
Braydon Fuller
7d878adcf0 bitcoind: immediately subscribe with connect option 2016-04-19 17:23:27 -04:00
Braydon Fuller
458fe2f2b6 bitcoind: emit block events while polling before subscribing to zmq events 2016-04-19 16:53:00 -04:00
Braydon Fuller
b092adcc21 bitcoind: subscribe to zmq events without interval if already synced 2016-04-19 16:40:54 -04:00
Braydon Fuller
2b38f08175 bitcoind: subscribe to zmq events once synced
prevents flooding tx and and block events that can cause issues
2016-04-19 16:00:17 -04:00
Braydon Fuller
2975f27a8d bitcoind: add uacomment option to default config 2016-04-18 18:34:54 -04:00
Braydon Fuller
feb8038da6 bitcoind: fix check reindex interval 2016-04-18 16:05:09 -04:00
Braydon Fuller
bf67b932de bitcoind: fix check reindex method not found 2016-04-18 15:52:35 -04:00
Braydon Fuller
afda35962b test: mempool helper method unit tests 2016-04-18 13:37:37 -04:00
Braydon Fuller
7c37eba91e test: unit tests for connect and spawn processes 2016-04-18 13:24:47 -04:00
Braydon Fuller
e09cc3d1fc test: bitcoind start unit tests 2016-04-18 11:11:17 -04:00
Braydon Fuller
317fdbbdd8 test: bitcoind _getAddressStrings unit tests 2016-04-18 10:54:50 -04:00
Braydon Fuller
8fd405eedf test: getBlockHeader unit tests 2016-04-18 10:48:32 -04:00
Braydon Fuller
a4f5a6fa82 test: getblock unit tests 2016-04-18 10:37:33 -04:00
Braydon Fuller
bb726bac8b test: bitcoind getaddressbalance unit test 2016-04-15 16:35:31 -04:00
Braydon Fuller
24ca5ce053 web: option to enable/disable socket rpc handling 2016-04-15 11:20:38 -04:00
Braydon Fuller
69ff5423c2 bitcoind: rename exported events to rawtransaction and hashblock 2016-04-15 11:20:38 -04:00
Braydon Fuller
890b38744d test: update unit tests, refactoring and cleanup 2016-04-15 11:20:33 -04:00
Braydon Fuller
462e4e3cdd Merge pull request #407 from bitpay/opt/multiple-address-history
Opt/multiple address history
2016-02-11 12:15:15 -05:00
Matias Alejo Garcia
e36cdb717a rm empty keys 2016-02-11 10:42:30 -05:00
Chris Kleeschulte
afce33e5ff Fixed test to refer to variables.sh for the architecture. 2016-02-11 10:25:22 -05:00
Matias Alejo Garcia
4d03aaa73f use mocknode 2016-02-10 16:18:27 -05:00
Matias Alejo Garcia
6e600b5def refactor test 2016-02-10 16:08:27 -05:00
Matias Alejo Garcia
1a68ca4fae add tests to _updateAddressIndex 2016-02-10 15:38:02 -05:00
Matias Alejo Garcia
02f2234004 rm extra commas 2016-02-10 15:05:05 -05:00
Matias Alejo Garcia
3bb3d82aac add counter for address mempool index 2016-02-10 15:03:34 -05:00
Matias Alejo Garcia
d0c2fa61d8 fix tests 2016-02-09 10:57:40 -05:00
Matias Alejo Garcia
9f87156adc fix format 2016-02-09 10:26:09 -05:00
Matias Alejo Garcia
c65c2bad20 add mempoolADdressIndex test 2016-02-08 13:40:27 -05:00
Matias Alejo Garcia
c1d3f351f2 add address index to mempool + noBalance options 2016-02-08 13:21:53 -05:00
Braydon Fuller
83eba52657 Tests: Fix tests to use enable/disableRegtest 2016-02-04 17:26:17 -05:00
Braydon Fuller
98bd8ee560 DB Service: Include a version number for upgrading purposes 2016-01-28 12:08:05 -05:00
Braydon Fuller
a2acc0c80f Address Service: Fixed test for max address limit 2016-01-26 13:09:31 -05:00
Braydon Fuller
45029030f1 Address Service: Sort after unconfirmed and confirmed 2016-01-18 16:16:53 -05:00
Braydon Fuller
d4f2df5c51 Address Service: Sort mempool txids 2016-01-18 15:56:05 -05:00
Braydon Fuller
62934b4b66 Address Service: Removed event listeners prior to stopping 2016-01-18 15:00:55 -05:00
Braydon Fuller
687400eab2 Address Service: Added test for history getAddressDetailsForTransaction 2016-01-18 13:53:32 -05:00
Braydon Fuller
3d9b6d5532 Address Service: More tests for history 2016-01-18 12:59:49 -05:00
Braydon Fuller
e79c00db10 Address Service: Updated tests and fixed various bugs 2016-01-15 18:04:32 -05:00
Braydon Fuller
ead6c2f45f Address Service: Removed caching and added max query limits
Querying addresses that have millions of transactions is supported however
takes hundreds of seconds to fully calculate the balance. Creating a cache of
previous results wasn't currently working because the `isSpent` query is always
based on the current bitcoind tip. Thus the balance of the outputs would be included
however wouldn't be removed when spent as the output wouldn't be checked again
when querying for blocks past the last checkpoint. Including the satoshis in the
inputs address index would make it possible to subtract the spent amount,
however this degrades optimizations elsewhere. The syncing times or querying
for addresses with 10,000 transactions per address.

It may preferrable to have an additional address service that handles high-volume
addresses be on an opt-in basis so that a custom running client could select
high volume addresses to create optimizations for querying balances and history.
The strategies for creating indexes differs on these use cases.
2016-01-14 17:17:04 -05:00
Braydon Fuller
4fcec8755c Address Service: Fixed many bugs from tests
- Refactored getAddressSummary and added several tests
- Fixed bugs revealed from the integration regtests
- Updated many unit tests
2016-01-13 17:15:14 -05:00
Samuel Reed
3214390d4c
Fix #377; db must contain hash type, not just hash.
Prevents erroneous crediting of all transactions to both the
p2pkh and the corresponding p2sh address.
2016-01-11 09:47:00 -06:00
Patrick Nagurny
02620a5b47 Merge pull request #352 from braydonf/mem
Optimized address service mempool index size
2015-11-03 17:23:28 -05:00
Braydon Fuller
0ea035c4f0 Address: Fixed race condition with transaction event handlers 2015-11-03 17:12:13 -05:00
Braydon Fuller
378edd4186 Web: Changed to pass express subapp to services instead of the router. 2015-11-03 10:32:01 -05:00
Braydon Fuller
c5c8e21c6c Address: Fixed bug with isSpent confusion with prevTxId and txid 2015-11-03 10:26:32 -05:00
Braydon Fuller
a1bae366b3 Database: Removed runAllMempoolIndexes method
Replaced with using `tx` and `txleave` to manage the state of the mempool indexes.
2015-11-02 17:18:37 -05:00
Braydon Fuller
5ac3b1c61f Address: Added unit tests for new mempool index methods 2015-11-02 17:10:43 -05:00
Braydon Fuller
89ef28f0b7 Optimize mempool address index memory footprint
- Adds default to store a large portion of the mempool index in leveldb
- Includes an option to use memdown to have the mempool index in-memory
2015-10-30 18:36:16 -04:00
Braydon Fuller
086ba5fcfc Switch to remove items from mempool index as they leave asynchronously. 2015-10-29 19:16:56 -04:00
Braydon Fuller
f0ec424161 Added bindings to be able to listen to tx leaving mempool. 2015-10-29 16:15:00 -04:00
Braydon Fuller
bf97d7e70b Include node version in binary distribution. 2015-10-28 14:54:27 -04:00
Braydon Fuller
92382d69cc Add --testnet option to create command. 2015-10-21 15:28:28 -04:00
Braydon Fuller
e046f7294e Changes to be able to run with only a configuration file.
- Adds parameter to cli methods to be able to specify the location of services modules. This is useful for packages that wrap bitcore-node to be able to pass along a node_modules directory with services.
- Adds another parameter for including additional services in the default settings.
- Will use the `process.env.HOME + '/.bitcore` as the default configuration location.
- There are now two `getDefaultConfig`, one that will instatiate a `~/.bitcore` directory with a default if it doesn't exist, and `getBaseDefaultConfig` that will return a basic configuration without additional services enabled.
- Changes logic to use the global install if a local node_modules version is not available, this would previously assume that it was a local install because of the existence of a configuration file.
2015-10-20 12:33:53 -04:00
Braydon Fuller
21e0aa28b5 Added a Node.js version check based on the package.json engine. 2015-10-18 22:50:29 -04:00
Braydon Fuller
1dec93edd4 bitcore -> bitcore-lib 2015-10-17 00:56:29 -04:00
Braydon Fuller
d9b2a0969b Fixed bug with balance
There was a bug when getting unspent outputs that would include an output
that was spent in the mempool in addition to the new output with the change
address. This lead to a balance having an output counted twice towards the
end balance. The solution is to have the isSpent method for the address service
to also include if the output was spent in the mempool, as the isSpent
method exposed from bitcoind only includes if the output was spent in a block.
2015-10-12 09:29:49 -04:00
Patrick Nagurny
3e38d84d0b emit address/balance events for mempool transactions 2015-10-02 17:10:12 -04:00
Patrick Nagurny
9acb896f10 Wait for bitcoind to catch up if tip is not found 2015-10-02 13:35:42 -04:00
Braydon Fuller
539b263c67 Add spentTxId Index
- To be able to query an inputTxId and inputIndex that spends an outputTxId and outputIndex
- Extends the mempoolSpentIndex to include the inputTxId and inputIndex
2015-10-01 20:03:31 -04:00
Patrick Nagurny
26b27b292e update tests 2015-09-29 16:03:56 -04:00
Chris Kleeschulte
af7966f94a Removed unneeded getTxOutSetInfo 2015-09-25 11:33:51 -04:00
Braydon Fuller
1183e0cae7 Service Documentation 2015-09-23 18:14:37 -04:00
Chris Kleeschulte
d474d03cf2 Merge pull request #248 from braydonf/pubkeyout
Address compatibility with pay-to-publickey output scripts.
2015-09-21 14:39:42 -04:00
Braydon Fuller
7e82c933c0 Merge pull request #249 from kleetus/feature/getNextBlockHash
Next Block Hash Bindings
2015-09-21 14:30:30 -04:00
Chris Kleeschulte
402d01d7ac Next Block Hash Bindings
- Added bindings for next block hash
- Added the reg/unit tests
2015-09-21 14:07:14 -04:00
Braydon Fuller
e3096d3646 Address compatibility with pay-to-publickey output scripts. 2015-09-21 13:49:48 -04:00
Patrick Nagurny
b11ab97739 add tests 2015-09-18 14:06:26 -04:00
Patrick Nagurny
4a5031a917 Merge pull request #240 from braydonf/gettxoutsetinfo
Add binding for getting transaction output set information.
2015-09-18 13:20:46 -04:00
Braydon Fuller
68368397d3 Add binding to get the best block hash. 2015-09-17 18:11:47 -04:00
Braydon Fuller
4c674a8fbb Add binding for getting transaction output set information. 2015-09-17 17:52:23 -04:00
Chris Kleeschulte
0ba168e2a2 Fixed typo and added a test to prove that the inputs from the mempoolInputIndex are added on stream close. 2015-09-17 17:20:35 -04:00
Chris Kleeschulte
c3654120ee MempoolInputIndex and MempoolOutputIndex
- Added in memory indexes for mempool input and 
output by address.
2015-09-17 14:29:11 -04:00
Braydon Fuller
4343b90de2 Merge pull request #219 from pnagurny/feature/timestamp-blocks
Get block hashes by timestamp range
2015-09-16 13:47:00 -04:00
Patrick Nagurny
aa9504a402 Merge pull request #227 from braydonf/add-cmd-remote
Bitcore Node Add Command with Remote URLS
2015-09-16 13:34:24 -04:00
Patrick Nagurny
a0be38f074 check for timestamp out of bounds 2015-09-16 12:04:44 -04:00
Patrick Nagurny
7e1d433781 go from highest timestamp to lowest timestamp 2015-09-15 18:23:06 -04:00
Patrick Nagurny
00d3a0ba67 binary encode key and value 2015-09-15 16:55:14 -04:00
Braydon Fuller
bfba4a1b7f Address History: Include count in response results. 2015-09-15 13:17:15 -04:00
Patrick Nagurny
eaee098cf0 add getBlockHashesByTimestamp 2015-09-15 12:56:44 -04:00
Patrick Nagurny
696759849f Merge pull request #223 from braydonf/history
Pagination for Address History
2015-09-15 12:34:26 -04:00
Braydon Fuller
25e801126f Bitcore Node Add Command with Remote URLS 2015-09-15 11:08:55 -04:00
Braydon Fuller
0b2d5f4891 Merge pull request #220 from kleetus/script_helpers
gitignore, integration test, env
2015-09-15 10:20:57 -04:00
Braydon Fuller
5fbd8991ed Address History: Combine addresses so that history is txid unique. 2015-09-14 21:04:54 -04:00
Braydon Fuller
e7587564a7 Address History: Add getAddressHistoryCount to available API methods. 2015-09-14 17:29:43 -04:00
Braydon Fuller
b1b40c892e Address History: Add getAddressHistoryCount method 2015-09-14 16:48:28 -04:00
Braydon Fuller
a80b58e004 Address History: Fix sorting bug 2015-09-14 16:11:31 -04:00
Chris Kleeschulte
7b50f5ff3d Switched to using a flag instead of using a replacement. 2015-09-14 13:15:55 -04:00
Braydon Fuller
f88eee5a1c Improve db storage efficiency by ~2 times
Encodes and decodes keys and values for leveldb storage more efficiently.
2015-09-14 00:30:21 -04:00
Braydon Fuller
d3641f3b0a Pagination Optimization
- Sort and paginate before getting full transaction details.
- Only get detailed transaction information for items within the current page.
- Improves the performance with large sets of transactions.
2015-09-14 00:30:14 -04:00
Braydon Fuller
1cf34f2dd8 Address Block Handling Optimizations
- Changes to use ripemd160 hash directly instead of the base58check encoded values
- Speeds block handling performance by ~4 times
2015-09-12 19:56:13 -04:00
Braydon Fuller
c205f781a5 Pagination for Address History
- Reindexing the bitcore-node database is required with this change.
- Address indexes are updated to include address and height in spent index so that both inputs and outputs can be queried by address and height using "start" and "stop" to limit the range of the query.
- Address history also now supports paginated results using "from" and "to" values that indicate an index in the array.
2015-09-12 19:44:10 -04:00
Chris Kleeschulte
51355c51f1 Multiple sigints sent to the node process
- Added a simple replacement function after the first sigint is handled.
- Added unit tests for the exitHandler, requiring it to be exposed from the module.
2015-09-11 16:27:24 -04:00
Chris Kleeschulte
ef49264907 gitignore, integration test, env
- Added a very common way to launch a script using the env (saving keystrokes)
- Added a gitignore for the integration/data dir
- Added a bus integration test apart from the regtest and using a test service
2015-09-11 10:58:52 -04:00
Patrick Nagurny
c4d28c3947 wait for db operations to complete before closing leveldb 2015-09-10 12:45:00 -04:00
Patrick Nagurny
8b0b401d52 inherit https options from node 2015-09-10 11:08:48 -04:00