Compare commits

..

2179 Commits

Author SHA1 Message Date
Devon R. James
be373552f5 v 1.1.6
updated brcypto to 5.4.0 and bfilter to devon's fork
2021-04-16 12:16:13 -07:00
Sky Young
5ea8c38f35
Merge pull request #17 from mediciland/fix-bfilter-bug
Fix installation bug with `bfilter` and `mrmr`
2020-12-09 11:57:54 -07:00
Sky Young
9ed0967b68 v1.1.5 2020-12-09 11:36:16 -07:00
Sky Young
31765b1dff Use murmur3 inside of bcrypto 2020-11-19 14:12:00 -07:00
Sky Young
4819265745
Merge pull request #1 from oipwg/master
Pull changes from oipwg master
2020-11-19 14:03:48 -07:00
ohryan
a7486eaae1
Merge pull request #16 from oipwg/nlr
add nlr check to reorganize function
2020-07-23 09:33:43 -07:00
ohryan
5321251db3 set competitor chain tip to invaild
setting the competitor chain tip to invaild fixes the problem where the chain continues to sync after nlr. main chain will no longer sync with competitor after nlr
2020-07-21 14:01:48 -07:00
ohryan
83a11fbcb2 setInvalid instead of invalidate + strictEqual assert
instead of running this.invalidate which deadlocks the chain, set the hash to invalid manually with this.setInvalid.

update assertion to use strict equal
2020-07-20 17:43:34 -07:00
ohryan
36671d02ed pull loop variable outside for reassignment 2020-07-17 20:03:07 -07:00
ohryan
c6317a268d update invalidation stepping to use just the while loop and add missing await to assert check 2020-07-16 19:20:49 -07:00
ohryan
11534032f4 fix/update logger warning and fix incorrect assert usage 2020-07-16 19:07:39 -07:00
ohryan
9f9c536efc add missing awaits 2020-07-16 08:31:10 -07:00
ohryan
7a1816a3a8 refactor/update nlr function; check nlr for spv wallet 2020-07-15 19:07:25 -07:00
ohryan
430276b592 add nlr check to reorganize function 2020-07-15 17:45:56 -07:00
Sky Young
f3606f2fe6 v1.1.4 2020-06-04 17:57:43 -06:00
Sky Young
973383209d
Merge pull request #15 from oipwg/fix_coinbase_evaluation
Add FLO block halving limit (34 halvings)
2020-02-20 09:39:38 -08:00
metacoin
af2f9bbae7 Add FLO block halving limit (34 halvings) 2020-02-19 08:56:27 -05:00
Sky Young
8668e14066
Merge pull request #14 from OstlerDev/regtest-parameters
Add proper paramaters for Regtest
2020-01-09 11:49:09 -07:00
Sky Young
03db50ed6c v1.1.3 2020-01-09 08:40:44 -07:00
Sky Young
094e3d7875 Add proper paramaters for Regtest 2020-01-08 16:09:37 -07:00
Sky Young
c38e2af1de
Merge pull request #12 from OstlerDev/master
Fix Segwit Signature check by adding floData length
2019-10-28 13:55:29 -06:00
Sky Young
bd8dc9140e Bump version to v1.1.2 2019-10-28 13:02:42 -06:00
Sky Young
30b84f6c63 Add new start/test scripts 2019-10-28 13:02:19 -06:00
Sky Young
8024b466e9 Calculate the extra floData size to add to the Buffer when initializing 2019-10-28 13:01:59 -06:00
Sky Young
57e88d7762
Merge pull request #2 from oipwg/master
Pull in upstream changes
2019-10-28 09:06:32 -06:00
Sky Young
111fd46fd5
Merge pull request #11 from OstlerDev/tx-floData-as-buffer
Handle floData as Buffer inside Transaction
2019-09-09 15:36:22 -06:00
Sky Young
c9410e9509 Update to v1.1.1 2019-09-09 15:30:58 -06:00
Sky Young
fef6643742 Handle floData as a Buffer everywhere 2019-09-09 15:24:18 -06:00
Sky Young
632b62986c
Merge pull request #1 from oipwg/master
Pull in changes from oipwg/master
2019-09-09 15:23:12 -06:00
Sky Young
6d27eb0806
Merge pull request #10 from OstlerDev/bcoin-1.0.2
Merge upstream changes from `bcoin:master`
2019-07-25 10:21:21 -06:00
Sky Young
a065661f4e Update mainnet checkpoint and slowHeight 2019-07-24 17:33:58 -06:00
Sky Young
c388d4c1cf Add mainnet seed 2019-07-23 09:20:12 -06:00
Sky Young
88fd2c1f0b Update tests to use fclient 2019-07-19 11:47:01 -06:00
Sky Young
15979ef376 Use fcoin.conf 2019-07-19 11:46:49 -06:00
Sky Young
d0d750c1f5 Increase mempool max orphans 2019-07-19 11:46:40 -06:00
Sky Young
84aabe20a9 Fix transaction signing 2019-07-19 11:44:37 -06:00
Sky Young
5a300e785f Allow low fees
This commit basically disables the fee estimation logic. Currently this is not needed as tx traffic on FLO is relatively minor
2019-07-19 11:43:36 -06:00
Sky Young
bad3388cab Allow up to 101000 blocks to be batch requested 2019-07-19 11:42:45 -06:00
Sky Young
f73c9d2320 Add new checkpoints for Mainnet and Testnet 2019-07-18 12:09:24 -06:00
Sky Young
2caeac559a Fix Difficulty Retargeting 2019-07-18 12:08:33 -06:00
Sky Young
2bc297d93b Use package @oipwg/fclient 2019-07-18 11:52:43 -06:00
Sky Young
28dca48cd7
Merge branch 'master' into bcoin-1.0.2 2019-07-15 16:53:15 -06:00
Sky Young
c670ef2ed2 Fix things that were not merged properly 2019-07-15 16:18:46 -06:00
Sky Young
153da80920 Merge remote-tracking branch 'bcoin/master' into bcoin-1.0.2 2019-07-15 15:42:15 -06:00
Sky Young
cf52e9575e
Merge pull request #9 from OstlerDev/handle-sigint
Handle SIGINT close signal
2019-07-10 13:32:06 -06:00
Sky Young
40fa7f5550
Merge branch 'master' into handle-sigint 2019-07-10 13:29:37 -06:00
Sky Young
18a61841b2 Bump to 1.0.2 2019-07-10 13:28:23 -06:00
Sky Young
74d2fc6771 Add sigint handler 2019-07-10 13:26:47 -06:00
Braydon Fuller
cec3c3e788
Merge pull request #805 from docs-maxinbound
docs: update max-inbound default
2019-07-03 09:34:49 -07:00
Braydon Fuller
fed7f2997b
Merge pull request #789 from bucko13/indexer-listeners
add ability to track listeners and remove them on close for indexer
2019-07-03 09:26:39 -07:00
Braydon Fuller
4f7e79bfdf
Merge pull request #798 from bucko13/indexer-hasraw
move hasRaw check to txindexer
2019-07-03 09:08:52 -07:00
Buck Perley
f4b74003c4
indexer: add ability to track listeners and remove them on close for indexer 2019-07-03 10:55:20 -05:00
Buck Perley
b14cd52070
indexer: move hasRaw check to txindexer 2019-07-03 10:51:08 -05:00
Matthew Zipkin
618e3b1ec7
docs: update max-inbound default
It is actually `8`, not `30`:
0551096c0a/lib/net/pool.js (L3531)
2019-06-28 11:41:15 -07:00
Braydon Fuller
4542ec5d18
Merge pull request #804 from nodar-chkuaselidze/rpc-cleanup
Minor RPC Test updates
2019-06-27 12:06:04 -07:00
Nodar Chkuaselidze
c7605ac5d0
wallet-rpc-test: don't modify global coinbase. 2019-06-27 22:40:55 +04:00
Nodar Chkuaselidze
782801689e
rpc-test: move wallet rpc tests to wallet-rpc-tests file. 2019-06-26 18:16:42 +04:00
Braydon Fuller
fb753a4de3
Merge pull request #788 from braydonf/test-assert
Remove test assert util and use bsert
2019-06-06 20:12:32 -07:00
Braydon Fuller
a3a34dbfe6
test: remove test assert util and use bsert 2019-06-05 12:11:57 -07:00
Braydon Fuller
f00985fefb
node: consistent rpc error messages 2019-06-05 12:11:52 -07:00
Braydon Fuller
400d578716
indexer: fix error message 2019-06-05 11:59:28 -07:00
HiddenMan
0551096c0a
blockchain: fix spelling error 2019-05-31 12:52:41 -07:00
Braydon Fuller
1721bdfe92
Merge pull request #775 from braydonf/memory
node: use the same memory option
2019-05-31 12:43:32 -07:00
Braydon Fuller
b7252939ec
docs: fix memory option for examples 2019-05-31 12:21:50 -07:00
Braydon Fuller
87aaebc8e7
node: use the same memory option 2019-05-31 12:16:15 -07:00
Braydon Fuller
a35516d4e0
Merge pull request #779 from braydonf/net-tests
Add net tests
2019-05-24 18:02:19 -07:00
Braydon Fuller
fbe64cf4a2
test: add net pool getheaders, tx, and merkleblock handler tests 2019-05-24 17:58:26 -07:00
Braydon Fuller
357ad4c2c4
test: start net pool handler tests 2019-05-24 17:58:26 -07:00
Braydon Fuller
4f76cfe3b9
test: add net peer handler tests 2019-05-24 17:58:26 -07:00
Braydon Fuller
9db43a7e1f
test: add net packet, framer and common tests 2019-05-24 17:58:25 -07:00
Braydon Fuller
55979c17b4
Merge pull request #777 from nodar-chkuaselidze/depupdates
Dependency updates, support node v12
2019-05-24 17:48:09 -07:00
Nodar Chkuaselidze
6d2aca6f30
pkg: dedupe. 2019-05-25 02:37:19 +04:00
Nodar Chkuaselidze
d32bb8fba4
ci: use bslint. 2019-05-21 17:14:56 +04:00
Nodar Chkuaselidze
2a0a8ad45e
ci: switch to nyc. 2019-05-19 20:30:50 +04:00
Nodar Chkuaselidze
fc283caf80
test: close worker pool. limit workers to 2. 2019-05-19 20:17:39 +04:00
Nodar Chkuaselidze
091ba49408
pkg: upgrade deps. update ignore and rc files.
bench: remove chacha that is out of the scope, it was part of the bip151 implementation.
test: increase timeouts.
2019-05-19 18:42:07 +04:00
Braydon Fuller
c2c16e2dd3
Merge pull request #776 from nodar-chkuaselidze/blockstore-minor
blockstore-test: use try/catch instead of promise.catch/finally.
2019-05-18 08:55:22 -07:00
Nodar Chkuaselidze
1fceb14e32
blockstore-test: use try/catch instead of promise.catch/finally.
finally was introduce in node v10, so this test will fail on v8.6.0 node.
2019-05-18 16:36:38 +04:00
Braydon Fuller
4c49b088f0
Merge pull request #774 from nodar-chkuaselidze/indexer-minor
Indexer getPrefix
2019-05-17 10:57:10 -07:00
Nodar Chkuaselidze
cdca51a844
addrindexer: minor.
* allocate one buffer istead of concat.
* return results instead of mutating array.
2019-05-17 21:04:52 +04:00
Nodar Chkuaselidze
0f6ef910b0
addrindexer: use network for getPrefix. 2019-05-17 21:04:47 +04:00
Braydon Fuller
7e49be2a07
Merge pull request #758 from braydonf/indexer
Indexer fixes and improvements
2019-05-16 11:20:05 -07:00
Braydon Fuller
6c497d46f1
changelog: update and fix chain changes 2019-05-16 10:28:09 -07:00
Braydon Fuller
7e9d00a665
node: pass options from getTXByAddress to getMetaByAddress 2019-05-16 10:26:54 -07:00
Braydon Fuller
34e8f22b9b
indexer: update and fix documentation 2019-05-16 10:25:58 -07:00
Braydon Fuller
662a68cf10
blockchain: cleanup deprecated methods
Deprecation details are in CHANGELOG.md
2019-05-15 12:11:37 -07:00
Braydon Fuller
372b9f9803
changelog: update with new indexer fields for info endpoint 2019-05-15 12:11:37 -07:00
Braydon Fuller
ce16bc9239
node: simplify index-prefix option 2019-05-15 12:11:37 -07:00
Braydon Fuller
a6fd1bec1a
changelog: update with latest migration 2019-05-15 12:11:37 -07:00
Braydon Fuller
677b45f3d5
migrate: upgrade from chaindb 4 to 6 2019-05-15 12:11:37 -07:00
Javed Khan
5111af0615
migrate: update latest migration 2019-05-15 12:11:37 -07:00
Braydon Fuller
ed06c2184d
indexer: check that blocks are connected
There was a rare case that a block could be incorrectly added to
the indexer if the indexer was disabled during a reorg to a height
that matched the height that was expected, and the `sync` method
for the indexer wasn't called that would detect the reorg.
2019-05-15 12:11:37 -07:00
Braydon Fuller
cede31d86f
indexer: cleanup and check pruned and index options 2019-05-15 12:11:37 -07:00
Braydon Fuller
5d18f9ba2e
indexer: index the genesis block 2019-05-15 12:11:37 -07:00
Braydon Fuller
efb2551555
indexer: fix reset and reorg handling 2019-05-15 12:11:37 -07:00
Braydon Fuller
865f7401ba
test: add test for retroactively enabling indexer 2019-05-15 12:11:37 -07:00
Braydon Fuller
b4be8574e5
test: improve addrindex tests
- Vectors for p2wsh and p2sh.
- Edge case for witness program.
- Improve determinism by not comparing mtime.
- Various edge and error cases.
2019-05-15 12:11:32 -07:00
Braydon Fuller
69e9844f82
test: cleanup and add txindex tests 2019-05-15 12:11:05 -07:00
Braydon Fuller
fae647b9e9
indexer: simplify block meta and remove records 2019-05-15 12:11:05 -07:00
Nodar Chkuaselidze
f30276bc27
test: add mempool indexing tests 2019-05-15 12:11:05 -07:00
Nodar Chkuaselidze
80aaa148e4
test: add mempool index persistence test 2019-05-15 12:11:05 -07:00
Braydon Fuller
b37ac59973
test: add utility to wait for values 2019-05-15 12:11:05 -07:00
Braydon Fuller
bb797602e6
node: add http indexer info 2019-05-15 12:11:05 -07:00
Braydon Fuller
bd26dbf32d
mempool: update for addrindex 2019-05-15 12:11:05 -07:00
Braydon Fuller
4c8f11ed34
node: update http for addrindex 2019-05-15 12:11:05 -07:00
Braydon Fuller
06ef0e3615
indexer: simplify addrindex query 2019-05-15 12:11:05 -07:00
Braydon Fuller
ebc40a58d0
indexer: trim disk usage for tx and addr indexes 2019-05-15 12:11:01 -07:00
Braydon Fuller
93c6ff845e
indexer: fix, simplify and rewrite indexer base
- Write indexer state and index atomically.
- Simplify chain state with current height.
- Roll forward to best height.
- Synchronize the index with the chain with common method `sync` for
  the events 'connect', 'disconnect' and 'reset'. This will prevent
  any of the events from conflicting with each other.
- Fix the chain rollback and reset.
- Make sure blocks are connected in the correct order.
- Improve logging to log similar to chain.
2019-05-15 12:02:50 -07:00
Javed Khan
e2a6a92ebc
addrindexer: index by address prefix 2019-05-15 12:02:50 -07:00
Braydon Fuller
aa3f02d585
test: initial http tests for indexer 2019-05-15 12:02:49 -07:00
Javed Khan
9f86dbca28
chaindb: bump to v6 2019-05-15 12:02:49 -07:00
Javed Khan
7342952ec4
migrate: update chaindb5to6 migration 2019-05-15 12:02:49 -07:00
Braydon Fuller
32904c7940
changelog: fix memory and cpu exhaustion for addrindex 2019-05-15 12:02:48 -07:00
Braydon Fuller
7dc55c9c3c
indexer: remove address coin index 2019-05-15 12:02:48 -07:00
Braydon Fuller
05d55efb22
indexer: fix memory and cpu exhaustion for addrindex 2019-05-15 12:02:48 -07:00
Braydon Fuller
b9e8c7b8de
changelog: merge blockstore and indexer changes 2019-05-15 12:02:47 -07:00
Braydon Fuller
8bff122253
indexer: use chain and blocks for indexer, remove chain client 2019-05-15 12:02:47 -07:00
Braydon Fuller
f9aab08c46
indexer: add block position to tx 2019-05-15 12:02:47 -07:00
Javed Khan
9f89c79bd7
indexer: work with blockstore 2019-05-15 12:02:47 -07:00
Javed Khan
51ac4a720b
changelog: add indexer to changelog 2019-05-15 12:02:46 -07:00
Javed Khan
33de39ca0a
migrate: remove txindex and addrindex from chaindb 2019-05-15 12:02:46 -07:00
Javed Khan
05794f5cb3
indexer: add module indexer
module indexer introduces a extensible architecture for indexing the
chain. It provides a base class which handles syncing with the chain,
handling re-orgs, interruptions, dynamic toggling, etc. TXIndexer
and AddrIndexer are provided for indexing transactions and addresses,
using the same flags as before i.e --index-tx and --index-address.
Indexes are stored in a different database and can be maintained
independently of the chain.
2019-05-15 12:02:41 -07:00
Braydon Fuller
81b840a634
Merge pull request #769 from braydonf/wallet-tx-conflict
wallet: handle multiple conflicting inputs
2019-05-14 22:56:29 -07:00
Braydon Fuller
eba7bbeddc
wallet: handle multiple conflicting inputs 2019-05-14 14:29:41 -07:00
Orfeas Stefanos Thyfronitis Litos
07f7338503 Replace 285 with 293 in blockstore README (#767)
* Replace 285 with 293 in blockstore README

* Mention block size after boundaries
2019-05-12 17:55:48 +05:30
Braydon Fuller
af19d802f5
Merge pull request #765 from tuxcanfly/fix-fee-overflow-err
chain: add fee overflow test; rename error
2019-05-06 16:29:41 -07:00
Javed Khan
d53fa0a1c5
chain: extend try..finally; restore consts to copy 2019-05-07 03:59:15 +05:30
Javed Khan
49143b2c16
chain: reset consensus params on assert fail 2019-05-07 03:48:31 +05:30
Javed Khan
4bc0bb2366
chain: add fee overflow test; rename error 2019-05-07 03:27:42 +05:30
Javed Khan
812dc1a6f3
Merge pull request #764 from braydonf/checkpoint
blockchain: do not accept forked chain older than last checkpoint
2019-05-07 00:23:19 +05:30
Braydon Fuller
46f83fe5ae
Merge pull request #763 from pinheadmz/docslint
linter: cover docs/examples
2019-05-03 09:33:14 -07:00
Braydon Fuller
c54abb79f1
Merge pull request #760 from kilpatty/node-http-reset-enforce
node-http: add check for height being below tip
2019-05-03 09:19:08 -07:00
Braydon Fuller
b68207610c
blockchain: do not accept forked chain older than last checkpoint
This has been patched in both bitcoind and btcd around February 20th, 2014. It was
shortly followed by a headers-first synchronization of blocks.

- d8b4b49667
- 50b6e10b57
2019-05-02 14:44:10 -07:00
Matthew Zipkin
ff6570fa45
linter: cover docs/examples 2019-05-02 08:16:11 -07:00
kilpatty
d5514d9dcb
node-http: add check for height being below tip
This commit simply adds an enforce line to check that the height being
requested to reset to is below the chain tip. This way we return a bad
request error rather than a internal server error.
2019-04-30 21:43:48 -05:00
Sky Young
c7569ae8f6 Add package-lock.json for v1.0.1 2019-04-23 15:50:48 -06:00
Sky Young
be3af64462
Merge pull request #8 from oipwg/v1.0.1
Bump version for ancestor limit increase
2019-04-23 15:30:23 -06:00
Sky Young
e9e85ebcd0
Bump version for ancestor limit increase 2019-04-23 15:21:02 -06:00
Braydon Fuller
d601b6a303
Merge pull request #703 from braydonf/blockstore
Add file block storage
2019-04-12 10:55:27 -07:00
Braydon Fuller
54383578fb
test: configurable and unique test directory path
- Multiple parallel runs of the same test will not conflict
  as a unique identifier is added to the test directory.
- The base test directory can be configured for various
  environments, and can be changed via the environment
  variable `TEMP`, see the implementation of `os.tmpdir()`
  for specific details.
2019-04-11 10:15:51 -07:00
Braydon Fuller
50fe51ca32
blockstore: close file if write or read throws 2019-04-08 13:26:16 -07:00
Braydon Fuller
3457ccc91b
blockchain: remove blocks after commit 2019-04-08 13:24:54 -07:00
Braydon Fuller
83824d73b1
blockstore: optimize block read and index
There is potential for around a 10% to 23% increase to the performance
of block reads by using `allocUnsafe`, however there is already around
a 3 to 6 times increase to the performance. While it's safe to use
`allocUnsafe` as the number of bytes read is checked to be the same
size as the buffer allocation, there is a potential for test cases
to introduce _other_ behavior for `fs.read` that may not have the
same behavior, though this isn't currently the case.
2019-04-08 13:20:00 -07:00
Braydon Fuller
41ce504175
bcoin: expose blockstore module 2019-04-08 13:18:59 -07:00
Braydon Fuller
8337176e07
migrate: add time to migrate and compaction log message 2019-04-08 13:18:59 -07:00
Braydon Fuller
f3e517c3c0
blockstore: fix logger, improve messages 2019-04-08 13:18:58 -07:00
Braydon Fuller
f24f64b483
changelog: add blockstore changes and migration notes 2019-04-08 13:18:58 -07:00
Javed Khan
6af6353906
blockstore: add README and docs 2019-04-08 13:18:58 -07:00
Braydon Fuller
961f6eddb5
blockstore: index undo blocks from files 2019-04-08 13:18:57 -07:00
Braydon Fuller
8fc605c4a9
blockstore: index after write interrupt and use less memory 2019-04-08 13:18:57 -07:00
Braydon Fuller
5cbbcf5409
blockstore: do not write block twice 2019-04-08 13:18:57 -07:00
Braydon Fuller
58e623e30a
test: minor, cleanup and clarity 2019-04-08 13:18:56 -07:00
Braydon Fuller
747a8e707b
blockstore: tests and fixes for blockstore error cases 2019-04-08 13:18:56 -07:00
Braydon Fuller
0f0cb00c54
blockstore: minor, spelling 2019-04-08 13:18:56 -07:00
Braydon Fuller
bdcb392a9c
blockchain: do not check blockstore with spv 2019-04-08 13:18:56 -07:00
Braydon Fuller
d1e747cf2f
blockstore: minor, update comments and docs 2019-04-08 13:18:55 -07:00
Braydon Fuller
2ba3ee6354
migrate: move block undo coins to blockstore 2019-04-08 13:18:55 -07:00
Braydon Fuller
8b6ec89a64
blockchain: use blockstore for undo coins 2019-04-08 13:18:55 -07:00
Braydon Fuller
89d3253f29
blockstore: add ensure method to create directories 2019-04-08 13:18:54 -07:00
Braydon Fuller
0b0dd58a91
node: add blockstore to full node 2019-04-08 13:18:54 -07:00
Braydon Fuller
11af5456ce
blockstore: additional options and create function 2019-04-08 13:18:54 -07:00
Javed Khan
8748e4dd2d
migrate: move blocks to blockstore files 2019-04-08 13:18:53 -07:00
Javed Khan
6be21203af
blockchain: integrate blockstore into chaindb 2019-04-08 13:18:53 -07:00
Braydon Fuller
3cec13ef5e
blockstore: add block data types with an undo type 2019-04-08 13:18:53 -07:00
Braydon Fuller
abd2ae4b5d
blockstore: prevent blocks writes at the same position 2019-04-08 13:18:53 -07:00
Braydon Fuller
2d08b296f7
blockstore: recover from block write interrupt 2019-04-08 13:18:52 -07:00
Braydon Fuller
64fb7c1d88
bench: add bench json output for blockstore 2019-04-08 13:18:52 -07:00
Braydon Fuller
620f21d6f5
blockstore: await for level block store writes 2019-04-08 13:18:52 -07:00
Braydon Fuller
0609ce72fc
bench: add benchmarks for blockstore 2019-04-08 13:18:51 -07:00
Braydon Fuller
8435a116f1
blockstore: add file block storage 2019-04-08 13:18:47 -07:00
Braydon Fuller
f57bd51187
Merge pull request #730 from tynes/document-bech32-tests
test: document bech32 test vectors
2019-04-05 09:48:29 -07:00
Braydon Fuller
392b3836fc
Merge pull request #715 from pinheadmz/inspect
Use custom `inspect` for all objects to avoid deprecation warning
2019-04-05 09:41:24 -07:00
Braydon Fuller
7136c256fc
Merge pull request #745 from pinheadmz/hashstring
util: reverse buffers instead of strings
2019-04-05 08:36:47 -07:00
Matthew Zipkin
fc7fd3cb4b
bench: reverse hex string hash 2019-04-04 23:59:30 -07:00
Matthew Zipkin
1b868b6a9d
util: reverse buffers instead of strings 2019-04-02 16:53:46 -07:00
Braydon Fuller
7ceb8874ee
Merge pull request #736 from braydonf/coin-cache
Remove coin cache
2019-04-02 15:24:07 -07:00
Braydon Fuller
434589e314
Merge pull request #741 from tynes/remove-webpack-scripts
npm scripts: delete webpack
2019-04-02 15:14:45 -07:00
Javed Khan
6a01409b79
Merge pull request #739 from pinheadmz/scan
node-http: require Bloom filter is loaded for `rescan` socket call
2019-04-02 18:55:53 +05:30
Matthew Zipkin
2980b4e739
http-test: socket rescan 2019-04-01 12:38:30 -07:00
Mark Tyneway
0549065752
npm scripts: delete webpack 2019-03-30 15:19:24 -07:00
Matthew Zipkin
83639f151c
util: fallback for inspect 2019-03-27 07:36:22 -04:00
Braydon Fuller
01a71561b1
Merge pull request #731 from tynes/validateaddress-upgrade
validateaddress and getaddressinfo RPC Update
2019-03-26 16:29:30 -07:00
Mark Tyneway
6850a328bf
changelog: getaddressinfo, validateaddress 2019-03-26 16:18:57 -07:00
Mark Tyneway
a28ffa272a
wallet rpc: add getaddressinfo rpc command
update the rpc command to better match bitcoind.
add the ismine and iswatchonly fields and
segwit related fields such as witness_version
and witness_program.
2019-03-26 16:13:18 -07:00
Mark Tyneway
26a2000b01
node rpc: update validateaddress
updates validateaddress to match the changes
in bitcoind https://github.com/bitcoin/bitcoin/pull/10583.
removes the fields ismine and iswatchonly, those
are things that a wallet would know, not a node.
adds segwit related fields, witness_version and
witness_program. test changes to the node rpc method
validateaddress with p2pkh, p2sh, p2wpkh and p2wsh addresses
2019-03-26 16:03:23 -07:00
Matthew Zipkin
11d70432b3
node-http: require filter to scan 2019-03-26 10:17:10 -07:00
Braydon Fuller
a9ebeb3871
blockchain: remove coin cache 2019-03-21 15:15:51 -07:00
Mark Tyneway
9a56851e8d
test: document valid addresses 2019-03-20 11:37:16 -07:00
Mark Tyneway
10292b043d
test: document bech32 test vectors
adds additional information about the test vectors
pulled from https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki
2019-03-15 16:43:50 -07:00
Braydon Fuller
2b2e53d83d
Merge pull request #550 from pinheadmz/rpcfixandtest
RPC: fix several wallet RPC calls and add RPC tests
2019-03-11 15:09:26 -07:00
Matthew Zipkin
5751b8c330
rpc: multiple fixes and tests
wallet-rpc: fix listsinceblock height

wdb: fix getWalletPaths() always return nothing

wallet: add unlockCoins() for lockunspent rpc

wallet-rpc: correct num args for some rpc calls

wallet-rpc: fix args for importwallet and importprunedfunds

wallet-rpc: importprunedfunds error misleading

wallet-rpc: importPubkey args

wallet-rpc: listsinceblock arg count error

wallet-rpc: listTransactions ignoring account param

wallet-rpc: better sendMany error msgs

wallet-rpc: sendMany subtractfee is bool not obj

wallet-rpc: dont check if not implemented

test: add rpc-test
2019-03-11 14:36:13 -07:00
Matthew Zipkin
df4e287817
utils: custom inspect for objects 2019-03-11 14:28:45 -07:00
Braydon Fuller
c65eec566f
Merge pull request #719 from braydonf/tests
test: avoid port collision with a running regtest node
2019-03-11 14:24:42 -07:00
Braydon Fuller
3ab296ce22
test: avoid port collision with a running regtest node 2019-03-06 16:55:43 -08:00
Braydon Fuller
1a18040ad4
Merge pull request #557 from nodar-chkuaselidze/no-template
Wallet option to skip templates.
2019-03-05 09:55:07 -08:00
Nodar Chkuaselidze
c0fb984da6
wallet: create non-templated transaction. 2019-03-05 21:14:25 +04:00
Braydon Fuller
9472833011
Merge pull request #713 from braydonf/docs
Docs formatting and consistency
2019-03-04 12:01:29 -08:00
Braydon Fuller
c1f5975fb1
Merge pull request #705 from rsbondi/rpc-help
rpc help list commands
2019-03-04 11:12:33 -08:00
Richard Bondi
9aebfb74e0
rpc help list commands 2019-03-02 11:38:38 -06:00
Braydon Fuller
07f55479eb
Merge pull request #664 from pinheadmz/patch-9
Wallet: better error for send() if no outputs given
2019-03-01 12:36:10 -08:00
Matthew Zipkin
e40e1c263c
wallet-test: missing output error 2019-03-01 10:50:14 -08:00
Matthew Zipkin
a2bf18ff18
wallet: better wallet.send outputs error 2019-03-01 10:45:05 -08:00
Braydon Fuller
f13faa10d4
Merge pull request #702 from braydonf/changelog
Changelog updates
2019-03-01 09:24:24 -08:00
Braydon Fuller
4825ee66ef
Merge pull request #683 from braydonf/bench-updates
bench: update and fix api and dependencies
2019-03-01 09:19:19 -08:00
Braydon Fuller
da24f09bc5
Merge pull request #707 pinheadmz/bclient-bin-2
pkg: link bclient to bin
2019-03-01 09:12:40 -08:00
Braydon Fuller
38efc1a0d5
changelog: formatting and consistency 2019-02-28 21:59:20 -08:00
Braydon Fuller
e736a7ee39
docs: formatting and consistency 2019-02-28 21:52:39 -08:00
Braydon Fuller
c64ccf215e
Merge pull request #699 pinheadmz/docsupdate
Update /docs examples and guides
2019-02-28 15:56:40 -08:00
Braydon Fuller
a770c013b1
changelog: update with latest changes 2019-02-28 15:40:20 -08:00
Matthew Zipkin
7e8c575740
docs: remove miner example 2019-02-28 14:57:18 -08:00
Sky Young
00850e5e84 Increase maximum ancestor count to 1250 2019-02-27 11:17:59 -08:00
Matthew Zipkin
d296c13247
docs: update examples and readme 2019-02-27 10:18:41 -08:00
Mark Tyneway
de8b2f7ba2
example: watch only wallet 2019-02-22 18:36:56 -08:00
Braydon Fuller
ea1c6becb5
Merge pull request #700 pinheadmz/blockjson
block: inspect() expects buffer from getCommitmentHash()
2019-02-22 18:20:01 -08:00
Matthew Zipkin
67a258ea74
block: get wit-commit as buffer 2019-02-22 18:08:22 -08:00
bitspill
2da47b5531 swap priority of script hash prefixes
default to using `e`/`f` rather than `4` on P2SH addresses

example transaction https://livenet.flocha.in/tx/cfb1b7b0f57283a078c6cbd9bf7baf9f688b454814a3e4199f9508b901db40c6
2019-02-22 13:45:56 -08:00
Matthew Zipkin
c8db665992
bin: fully deprecate bcoin cli 2019-02-21 10:12:31 -08:00
Matthew Zipkin
08b23c1777
pkg: link bclient to bin 2019-02-20 15:05:11 -08:00
Braydon Fuller
f585d8616d
Merge pull request #470 nodar-chkuaselidze/fix/reject-cache
fix malleability check in mempool
2019-02-15 08:59:36 -08:00
Nodar Chkuaselidze
f0023cb489
test: mempool should reject non-standard p2sh 2019-02-14 23:47:19 +04:00
Nodar Chkuaselidze
a9193f052f
mempool: fix malleability check in mempool 2019-02-14 19:56:51 +04:00
Braydon Fuller
2cfb73e019
bench: update and fix api and dependencies 2019-02-12 10:21:07 -08:00
Braydon Fuller
375965c8a6
Merge pull request #639 from pinheadmz/watch
Wallet: require public key for watchonly
2019-02-11 14:34:52 -08:00
Braydon Fuller
bf32e86abe
test: independent watch-only tests and assert error 2019-02-11 14:31:05 -08:00
Matthew Zipkin
0090c59714
changelog: update for watch-only 2019-02-11 14:30:34 -08:00
Matthew Zipkin
1696b3c7bb
wallet: require pubkey for watchonly 2019-02-11 14:14:33 -08:00
Javed Khan
7c64fd845c
Merge pull request #684 from braydonf/update-tests
Update transaction and script tests
2019-02-11 21:38:44 +05:30
Matthew Zipkin
bb1ce25449
wallet-http: create account: remove unused 'watch-only' 2019-02-08 16:26:51 -08:00
Braydon Fuller
35a25e0d8b
protocol: clear regtest seeds
This prevents attempts to add itself as a peer that would
generate unnecessary error log messages when running a regtest node.
2019-02-07 18:56:51 -08:00
Steven Bower
fe5a6d7eff
wallet: improve logging (minor) 2019-02-07 17:01:37 -08:00
Braydon Fuller
4a634f1f73
Merge pull request #603 from pinheadmz/loghttp
http: identify log messages as node-http and wallet-http
2019-02-07 14:29:03 -08:00
Matthew Zipkin
f0806a54dd
rpc: remove handleError 2019-02-07 14:04:37 -08:00
Matthew Zipkin
7303d284d5
wallet-rpc: log queries 2019-02-07 14:04:37 -08:00
Matthew Zipkin
da2084f503
rpc: identify node/wallet in log 2019-02-07 14:04:37 -08:00
Matthew Zipkin
d9044960ad
http: identify node/wallet in log 2019-02-07 14:04:37 -08:00
Matthew Zipkin
fea7483762
docs: add only to configuration.md 2019-02-07 10:58:44 -08:00
Braydon Fuller
39684df605
Merge pull request #676 from tynes/update-regtest
Update Regtest Specific Params
2019-02-05 11:37:20 -08:00
Braydon Fuller
37fc9a78e4
script: update script tests and behavior
References:
- https://github.com/bitcoin/bitcoin/pull/12425
- https://github.com/bitcoin/bitcoin/pull/12167
- https://github.com/bitcoin/bitcoin/pull/10699
2019-02-01 16:32:39 -08:00
Braydon Fuller
efa78100e0
script: update tx standardness rules and more tx tests
References:
- https://github.com/bitcoin/bitcoin/pull/11423
- https://github.com/bitcoin/bitcoin/pull/12600
- https://github.com/bitcoin/bitcoin/pull/12082

Trivial References:
- https://github.com/bitcoin/bitcoin/pull/12393
- https://github.com/bitcoin/bitcoin/pull/6539
- https://github.com/bitcoin/bitcoin/pull/10742
- ecb11f561c
2019-02-01 16:32:31 -08:00
Node
d86033fa16
test: update licenses for test files 2019-02-01 16:24:45 -08:00
Javed Khan
a2e176d4cf
Merge pull request #361 from tuxcanfly/only-no-seeds
pool: --only - disable dns seed discover
2019-02-01 22:00:56 +05:30
Javed Khan
3c1fda4826
pool: fix this.options.discover 2019-02-01 21:56:57 +05:30
Braydon Fuller
fa877503a4
blockchain: enable segwit for regtest 2019-01-31 13:03:59 -08:00
Javed Khan
127fea663f
pool: disable discover with only 2019-01-31 20:27:47 +05:30
Mark Tyneway
b10aea8f3d
bugfix: regtest segwit start time 0
The deployments are written to and read
from a database and the start time is
a U32. Changing the value to -1 will cause
the value to be read incorrectly and cause
the tests to fail.
2019-01-28 15:31:59 -08:00
Javed Khan
70886c33e2
networks: restore regtest ports 2019-01-28 15:31:59 -08:00
Javed Khan
53a09b0a02
networks: always activate segwit for regtest 2019-01-28 15:31:57 -08:00
Javed Khan
48f38a4a65
networks: update regtest params 2019-01-28 15:31:56 -08:00
Javed Khan
7f736db0d7
Merge pull request #677 from nodar-chkuaselidze/fixlint
Fix lint configs
2019-01-28 16:32:02 +05:30
Nodar Chkuaselidze
f7b0cb8eea
lint: remove webpack files from eslintfiles. 2019-01-25 23:32:35 +04:00
Christopher Jeffrey
4eaff2638a
pkg: update deps and lock file. 2019-01-21 22:49:52 -08:00
Christopher Jeffrey
0a71b445e0
pkg: remove some files for now. 2019-01-21 22:02:17 -08:00
Javed Khan
6f1a561db5
Merge pull request #641 from nodar-chkuaselidze/fix/mempool-index
mempool: reflect spent coins in mempool coinview.
2019-01-21 18:52:34 +05:30
Javed Khan
bd7a0949b6
Merge pull request #632 from nodar-chkuaselidze/fix/addresses
address minor fixes
2019-01-04 20:45:34 +05:30
Javed Khan
b0bf2ddd37
Merge pull request #648 from OrfeasLitos/get-keys-from-multisig
Implement and test KeyRing.fromMultisigScript(script, i)
2019-01-04 20:35:35 +05:30
Javed Khan
aaec50fc4c
Merge pull request #652 from pinheadmz/patch-8
spvnode: parse --no-wallet flag
2019-01-04 20:34:03 +05:30
Javed Khan
54cdd16723
Merge pull request #633 from pinheadmz/patch-4
net: add testnet seeds (for browser)
2019-01-01 18:35:52 +05:30
Javed Khan
26a3d793d4
Merge pull request #638 from pinheadmz/patch-6
README: https for docs links
2019-01-01 18:34:36 +05:30
Christopher Jeffrey
208c40891f
pkg: upgrade bmocha (again). 2018-12-17 16:14:39 -08:00
Christopher Jeffrey
75de428308
pkg: upgrade bmocha. 2018-12-17 15:47:05 -08:00
Christopher Jeffrey
238b514b2c
pkg: update deps. 2018-12-17 03:22:40 -08:00
Javed Khan
7268bc27ff
Merge pull request #653 from jlopp/updateWikiLink
update link to bcoin docs
2018-12-11 22:03:53 +05:30
Jameson Lopp
2e47fb96c9
update link to bcoin docs 2018-12-11 10:49:39 -05:00
Matthew Zipkin
3377e6536e
spvnode: parse --no-wallet flag
To match behavior in `node` (fullnode) if a user wants to use `bmultisig` instead of the built-in wallet.
2018-12-10 15:06:16 -08:00
Orfeas Litos
7a9023f388
Add test for KeyRing.fromMultisigScript() 2018-12-09 22:11:48 +00:00
Orfeas Litos
6d48e41c96
Implement KeyRing.fromMultisigScript(script, i) 2018-12-09 22:11:44 +00:00
Christopher Jeffrey
0b70a940a3
test: get tests passing in chrome. 2018-12-08 02:40:49 -08:00
Christopher Jeffrey
06398780ef
pkg: upgrade bmocha and bsert. 2018-12-08 02:40:11 -08:00
Christopher Jeffrey
4e25ff8fcd
pkg: upgrade bmocha. 2018-12-05 09:27:16 -08:00
Javed Khan
f35790a069
Merge pull request #643 from pinheadmz/patch-7
docs/Configuration: SPV is command-line only
2018-12-05 22:41:04 +05:30
Matthew Zipkin
c4d2539191
docs/Configuration: include daemon in note 2018-12-05 08:54:06 -08:00
Christopher Jeffrey
46f2917166
pkg: upgrade bmocha. 2018-12-05 03:06:43 -08:00
Christopher Jeffrey
d88fa67147
pkg: upgrade bmocha. 2018-12-02 17:31:32 -08:00
Christopher Jeffrey
8bfac6d5d8
pkg: update bmocha. 2018-12-02 03:55:43 -08:00
Christopher Jeffrey (JJ)
314933cb9d
Merge pull request #642 from braydonf/pkg-lockfile
pkg: add lockfile
2018-11-30 12:18:40 -08:00
Braydon Fuller
7b734cd36b
docs: update installation details and requirements 2018-11-30 11:41:42 -08:00
Matthew Zipkin
4181ee6988
docs/Configuration: spv note lint 2018-11-30 10:02:06 -08:00
Matthew Zipkin
5b8915132e
docs/Configuration: SPV is command-line only
Addresses confusion similar to https://github.com/bcoin-org/bcoin-docker/issues/8
2018-11-30 10:00:06 -08:00
Braydon Fuller
a916bfa844
pkg: add lockfile 2018-11-29 09:43:49 -08:00
Christopher Jeffrey
b4173235e1
pkg: minor. 2018-11-29 09:10:21 -08:00
Christopher Jeffrey
df1e8c0621
pkg/circleci: remove instanbul from dev dependencies. 2018-11-29 04:14:32 -08:00
Christopher Jeffrey
1436c97dbe
pkg: switch to bmocha. 2018-11-29 03:22:57 -08:00
Christopher Jeffrey
869b76c450
pkg: update deps. 2018-11-28 06:41:45 -08:00
Nodar Chkuaselidze
32cba1bf4a
mempool: reflect spent coins in mempool coinview.
Currently coinview does not account for spent coins in the mempool,
This does not create problems because we have additional checks in
right places which detect double spends, but technically
coinview should help you detect double spent in the mempool as well.
This way it will be compatible with chain.getCoinView.

getSpentView will still return all outputs that are available
in the mempool. (This could also return spentView from indexers if
available, this method is used by `signrawtransaction`.)
2018-11-25 23:32:13 +04:00
Matthew Zipkin
d6ff2d7ef4
README: https for docs links 2018-11-22 09:35:28 -08:00
Matthew Zipkin
8b6eba165b
net: add testnet seeds (for browser)
bcoin browser mode can not use DNS to discover seeds, so they are hard-coded.
see: https://github.com/bcoin-org/bdns/blob/master/lib/dns-browser.js#L23
There's already plenty in `/lib/net/seeds/main.js` so this is just to get browser-nodes running on testnet.
Seeds were pulled from my own `hosts.json` file on a live testnet bcoin node
2018-11-15 17:22:23 -08:00
Buck Perley
f97e3f3225
readme: update browser link 2018-11-15 16:02:25 -08:00
Nodar Chkuaselidze
579a98a531
address: minor fixes 2018-11-15 17:39:25 +04:00
Buck Perley
e305d900d6
pkg: add currency and other info (#623)
matches expected outputs from hsd
2018-11-01 12:44:08 -07:00
Matthew Zipkin
78eeae6763 browser: update script import (#622)
* browser: update since refactor

* docs: redirect browser to new guide
2018-11-01 11:58:28 -07:00
Sky Young
31ee7f6367 Bump up coinbase expectations now that we include flodata 2018-10-20 14:17:24 -06:00
Sky Young
c41ab92f78 Add more checkpoints to mainnet and testnet :) 2018-10-20 14:10:55 -06:00
Sky Young
8ab224a6ae vbeta.33 2018-10-20 13:56:23 -06:00
Sky Young
5131accc21 Check coinbase transaction for floData and include it in the size. 2018-10-20 13:55:50 -06:00
Sky Young
16005103e0 Get witness data as well for Coinbase Transaction. 2018-10-20 13:25:54 -06:00
Sky Young
60e19a7b02 Include version check 2018-10-20 13:07:58 -06:00
Sky Young
92184992ea Add in floData to other Witness serizliation/deserialization functions 2018-10-20 13:03:53 -06:00
Sky Young
ecde63c8d8 Update to beta.29 -- Added Segwit TX Support! 2018-10-20 12:16:54 -06:00
Sky Young
4d7b920048 Calculate the size of floData and add it to the bufferwriter initial size 2018-10-20 12:15:30 -06:00
Sky Young
36f88b398f Create segwit signature hash with floData included :) 2018-10-20 11:32:12 -06:00
Sky Young
86dc7c601a Replace Bitcoin and bcoin with Flo and fcoin respectively 2018-10-20 11:25:37 -06:00
Javed Khan
fe340265c8
Merge pull request #444 from nodar-chkuaselidze/wallet-api/create-tx
Allow optional signing in createTX http endpoint
2018-10-19 23:22:54 +05:30
Sky Young
2cf4091bcc Lower the other two amounts back to the old value 2018-10-18 19:27:00 -06:00
Sky Young
6fffcaef3d Drop size down 4 bytes 2018-10-18 18:57:16 -06:00
Sky Young
0b15b43564 Update to v1.0.0-beta.25 2018-10-18 18:22:55 -06:00
Sky Young
e78fd5e578 Fix testnet activation windows 2018-10-18 18:22:14 -06:00
bitspill
f82d851dc2
Allow batch RPC calls 2018-10-16 14:51:41 -07:00
bitspill
d10de7fa72
Allow batch RPC calls 2018-10-16 14:27:23 -07:00
Sky Young
cc8b496a96 Update to v1.0.0-beta.24 2018-10-16 14:59:24 -06:00
Sky Young
42ff0302a8
Merge pull request #3 from bitspill/patch-2
bump size to include floData
2018-10-16 14:58:35 -06:00
bitspill
bc82a1526d
bump size to include floData 2018-10-16 13:56:49 -07:00
Sky Young
d58630904e Update to v1.0.0-beta.23 2018-10-16 14:54:24 -06:00
Sky Young
3f7ea8ebcd
Merge pull request #2 from bitspill/patch-1
Include FloData in weight
2018-10-16 14:51:37 -06:00
bitspill
efb135d1c3
Include FloData in weight 2018-10-16 13:45:38 -07:00
Sky Young
1daca7b701 Update version to 1.0.0-beta.22 2018-10-04 13:47:23 -06:00
Sky Young
12ef3c901f Log the error stack as well (for finding bugs) 2018-10-04 13:47:12 -06:00
Sky Young
dd259ea6bd Set default tx version to 2 2018-10-04 13:46:59 -06:00
Javed Khan
125e8182fd
Merge pull request #614 from tuxcanfly/fix-lint
circleci: fix eslint
2018-10-04 09:51:55 +05:30
Javed Khan
d3ec72526e
circleci: fix eslint 2018-10-04 07:54:04 +05:30
Javed Khan
625edb9579
Merge pull request #604 from nodar-chkuaselidze/ci-updates
pkg: update ci
2018-09-30 21:40:34 +05:30
Christopher Jeffrey
e0863d4a91
deps: upgrade to bcrypto 2.0. upgrade other deps. 2018-09-29 14:38:53 -07:00
Javed Khan
8630a8ee51
Merge pull request #396 from tuxcanfly/sigint-close
bin: handle close when interrupted
2018-09-17 23:57:48 +05:30
Javed Khan
beb7f8fb1d
node: move closed message to handleClose 2018-09-17 23:54:36 +05:30
Javed Khan
b18a8a3f13
bin: handle close when interrupted 2018-09-17 23:54:34 +05:30
Javed Khan
fcba00ef5b
Merge pull request #609 from pinheadmz/patch-3
spvnode: add new option `file` instead of config
2018-09-13 22:47:14 +05:30
Matthew Zipkin
e6b3697784
spvnode: add new option file instead of config
Addresses #608 and extends #563
2018-09-13 09:38:31 -07:00
Nodar Chkuaselidze
a411e31c62
pkg: update ci
Use cache only when installing
Use workspaces to share node_modules
2018-09-07 18:42:29 +04:00
Javed Khan
15b024a392
Merge pull request #598 from pinheadmz/broadcasttx
Fixes pool.getBroadcasted() error item.hash is not a function
2018-08-31 22:06:53 +05:30
Matthew Zipkin
7d2caa072b
pool: fixes getBroadcasted() error 2018-08-31 09:30:40 -07:00
Javed Khan
91db3a55ac
Merge pull request #596 from tuxcanfly/fix-addr-gethash-2
pool: watchAddress continue to accept addr string
2018-08-30 22:39:38 +05:30
Javed Khan
f01e2fb626
pool: watchAddress continue to accept addr string 2018-08-29 23:18:28 +05:30
Javed Khan
1bde15b9a2
Merge pull request #593 from bucko13/webpack-compat
remove bcrypto/compat from compat webpack
2018-08-28 23:25:50 +05:30
Matthew Zipkin
149558072d docs: Different formats for parameters (#592) 2018-08-28 10:11:07 -07:00
bucko13
0ecee1bfaa
remove bcrypto/compat from compat webpack 2018-08-27 17:47:01 -07:00
Javed Khan
e4f41db5ab
Merge pull request #576 from braydonf/ac
Tab completion of API in Node.js REPL
2018-08-27 22:26:19 +05:30
Javed Khan
8d2d795e78
Merge pull request #588 from bucko13/webpack-fix
remove bcrypto/compat
2018-08-25 11:57:33 +05:30
bucko13
656c942758
remove bcrypto/compat 2018-08-24 13:57:13 -07:00
Javed Khan
3e87598dfe
Merge pull request #587 from braydonf/getnewaddress
wallet: get correct address for `getnewaddress` rpc
2018-08-25 01:49:56 +05:30
Braydon Fuller
fb9cee7176 wallet: get correct address for getnewaddress rpc 2018-08-24 13:07:04 -07:00
Javed Khan
ac0179ca9b
Merge pull request #581 from tuxcanfly/fix-addr-gethash
http: fix address/coins by address to use Address instead of string
2018-08-25 01:23:20 +05:30
Javed Khan
175ff7906d
http: use Address instead of string 2018-08-25 00:22:12 +05:30
Matthew Zipkin
7178d9b2cd docs: describes wallet- prefix for CLI config (#584)
Had a few support chats about connecting to a remote bcoin server from a local client.
Indicating here how to launch bcoin with node and wallet configs in one line.
Also users might not realize that you can run bclient on its own locally,
and the config files are still in the same place as bcoin itself.
2018-08-22 09:37:16 -07:00
Ron Gross
0e799eb2db
docs: fix npm install windows-build-tools
Fixes #522
2018-08-20 21:28:08 +05:30
ATheCoder
9dba78d2bb
docs: configuration - add spv option
Fixes #476
2018-08-20 20:34:23 +05:30
Braydon Fuller
0e93cbaec4 bcoin: enumerate properties 2018-08-17 14:58:49 -07:00
Javed Khan
b3fd9656f9
Merge pull request #563 from tuxcanfly/fix-config-file
multi: pass new Node option `file` to wallet plugin
2018-08-13 17:50:39 +05:30
Javed Khan
7f4494e278
multi: pass new Node option file to wallet plugin
`file` is similar to `config`, but it propogates to the wallet plugin
and loads the wallet config file only if set to true.

This is useful to disable config files for both node and wallet when
running a full node, for example in a test environment.
2018-08-13 17:36:21 +05:30
Javed Khan
f4bf9816a5
Merge pull request #566 from tuxcanfly/fix-lint
multi: fix lint warnings
2018-08-13 17:34:34 +05:30
Javed Khan
9a22976631
multi: fix lint warnings 2018-08-13 17:30:30 +05:30
Christopher Jeffrey
f10d7b8363
pkg: remove bn.js dependency. 2018-08-10 16:33:38 -07:00
Christopher Jeffrey
85ed59c842
pool: fix handleGetBlocks. 2018-08-10 16:28:23 -07:00
Christopher Jeffrey
92feb1be52
node: do not alter pool size. 2018-08-10 16:27:19 -07:00
Christopher Jeffrey
a15b1e2d62
net: remove redundant item resolving. 2018-08-10 16:25:38 -07:00
Christopher Jeffrey
acecd5ee37
pkg: update deps. 2018-08-10 16:24:10 -07:00
Christopher Jeffrey
dc5b8c373d
net: properly clear timers. 2018-08-10 16:24:10 -07:00
Christopher Jeffrey
a0ac953079
bcoin: update logger usage. 2018-08-10 16:24:10 -07:00
Christopher Jeffrey
5b56323310
pkg: update deps. 2018-08-10 16:24:10 -07:00
Christopher Jeffrey
9ee3854828
bdb: upgrade bdb usage for keys. 2018-08-10 16:24:10 -07:00
Christopher Jeffrey
189da2968b
pkg: update deps. 2018-08-10 16:24:10 -07:00
Christopher Jeffrey
09e74977d3
pkg: update deps. 2018-08-10 16:24:10 -07:00
Christopher Jeffrey
a45e683eb2
bcoin: switch to bsert for everything. 2018-08-10 16:23:46 -07:00
Christopher Jeffrey
b92839c82a
bcoin: use buffer-map. see #533. 2018-08-10 16:23:46 -07:00
Steven Bower
eea4013dcf
Revert "test: http-test - don't read wallet.conf"
See issue #561

This reverts commit 469abb03fe.
2018-08-08 14:48:16 -07:00
Sky Young
a755d7c6ef Update Version 2018-08-06 15:46:34 -07:00
Sky Young
dea7e6042f Return Transaction Errors from RPC 2018-08-06 15:45:28 -07:00
Javed Khan
ddeb73a396
Merge pull request #514 from pinheadmz/walletdocs
docs: wallet.conf details
2018-08-06 22:54:11 +05:30
Javed Khan
7354fd3377
Merge pull request #553 from braydonf/test-timeout
net: clear broadcast timers on pool close
2018-08-06 22:52:26 +05:30
Braydon Fuller
7ea95b5795 net: revolve pending broadcast items
If `pool.close()` is called if the pool is not connected, timers
won't be cleared. Transactions can be added to the pool while
it's not connected.
2018-08-06 10:18:07 -07:00
Braydon Fuller
d6c4aa215e pkg: bump bsock and bweb with timeout fixes 2018-08-06 10:17:51 -07:00
Matthew Zipkin
1a51983554 docs: wallet.conf details 2018-08-06 16:30:46 +00:00
Javed Khan
86ba087f27
Merge pull request #535 from tuxcanfly/tests-no-config
test: http-test - don't read wallet.conf
2018-08-06 20:55:36 +05:30
Javed Khan
469abb03fe
test: http-test - don't read wallet.conf 2018-08-06 20:50:34 +05:30
Nodar Chkuaselidze
1b92e7b4ea
wallet-http: sign parameter to create transaction without signatures. 2018-07-20 17:52:05 +04:00
Javed Khan
f24a9b674f
Merge pull request #529 from tuxcanfly/test-fix-pow
test: fix get block proof equivalent time
2018-07-16 20:27:10 +05:30
Christopher Jeffrey
58ea98dadb
v1.0.2 2018-07-13 13:29:16 -07:00
Christopher Jeffrey
7647145614
networks: add one more checkpoint for testnet. 2018-07-13 13:28:58 -07:00
Christopher Jeffrey
da944371fb
v1.0.1 2018-07-13 13:17:03 -07:00
Christopher Jeffrey
08a04b53c3
net: update default mainnet seeds. 2018-07-13 12:57:29 -07:00
Christopher Jeffrey
44e856d36b
networks: update checkpoints and chainwork. 2018-07-13 12:57:12 -07:00
Javed Khan
944f29fe16
test: fix get block proof equivalent time
the test was randomly failing when getProofTime returns -0. Fixed
by replacing strictEqual with ok.
2018-07-13 00:05:45 +05:30
Christopher Jeffrey
b0155b663c
v1.0.0 2018-07-12 10:20:50 -07:00
Christopher Jeffrey
fa84b8cb12
pkg: update deps. 2018-07-12 10:17:13 -07:00
Christopher Jeffrey
e15d7917fa
mtx: allow passing of preferred inputs to coin selector. 2018-07-12 10:17:13 -07:00
Christopher Jeffrey
97e4d09baf
pkg: update deps. 2018-07-12 10:17:13 -07:00
Christopher Jeffrey
cfeacb309e
chain: mark historical bad merkle block as mutable. 2018-07-12 10:17:13 -07:00
Christopher Jeffrey
395811a86f
changelog: add mention of bip151 & bip150. 2018-07-12 10:17:13 -07:00
Christopher Jeffrey
41af7acfd6
net: remove bip150/bip151 support. 2018-07-12 10:17:13 -07:00
Christopher Jeffrey
b6d067ec93
consensus: fail early on pow check when target > 256 bits. 2018-07-12 10:17:12 -07:00
Christopher Jeffrey
05c38853d7
net: add more aggressive dos prevention. 2018-07-12 10:17:12 -07:00
Christopher Jeffrey
4876e80631
pkg: update deps. 2018-07-12 10:17:12 -07:00
Christopher Jeffrey
22830cf6f3
chain: earlier sanity checks. 2018-07-12 10:16:58 -07:00
Christopher Jeffrey
1ca3738699
pkg: minor. 2018-07-12 10:16:58 -07:00
Javed Khan
f826174f9c
Merge pull request #525 from tuxcanfly/fix-circleci-tests
test: fix timeout for node test
2018-07-10 17:14:13 +05:30
Javed Khan
6cf81d3490
test: fix timeout for node test 2018-07-10 17:09:11 +05:30
Javed Khan
2eb42d66d8
Merge pull request #524 from tuxcanfly/fix-circleci-tests
test: increase timeout for ci
2018-07-10 17:01:02 +05:30
Javed Khan
58ab9ba267
test: increase timeout for ci 2018-07-10 16:45:03 +05:30
Javed Khan
5261339b52
Merge pull request #523 from tuxcanfly/pkg-bcrypto
pkg: update bcrypto
2018-07-10 16:30:21 +05:30
Javed Khan
ceebd652b7
pkg: update bcrypto
bcrypto@0.3.3 has a few API changes which breaks the integration
with bcoin. Fix the version @0.3.2 for now.
2018-07-10 15:54:05 +05:30
Javed Khan
21bf114dc6
Merge pull request #491 from nodar-chkuaselidze/ci
Enable CircleCI + CodeCov for CI and Coverage respectively.
2018-07-10 15:12:41 +05:30
Nodar Chkuaselidze
2086385f38
pkg: add ci 2018-07-10 15:11:13 +05:30
Matthew Zipkin
b371b3ecda test/txmeta: fix lint 2018-07-05 22:43:03 +05:30
Christopher Jeffrey (JJ)
5c26307db1
Merge pull request #467 from tuxcanfly/pow-tests
test: add pow-tests
2018-07-04 15:37:05 -07:00
Christopher Jeffrey (JJ)
575cce78e4
Merge pull request #517 from tuxcanfly/orfeas-fix-typos
wallet: fixed typos; pool: minor jsdoc (#511)
2018-07-04 15:34:39 -07:00
Orfeas Stefanos Thyfronitis Litos
208dcfd1d5
wallet: fixed typos; pool: minor jsdoc (#511) 2018-07-04 17:49:00 +05:30
Nodar Chkuaselidze
92ebbbdde7 wallet-node: fix client cfg parsing 2018-07-04 17:12:06 +05:30
Nodar Chkuaselidze
ef43dad9ee wallet-account: fix change derivation path 2018-07-03 13:03:27 +05:30
Matthew Zipkin
64ba4c7567 txmeta: fix JSON confirmations value when unconfirmed, add test 2018-07-03 11:30:50 +05:30
Javed Khan
5af767159a
test: add pow-tests 2018-06-20 11:42:13 +05:30
Nodar Chkuaselidze
ce1f1fbcb2
http-test: close wclient. 2018-06-15 02:44:53 +04:00
Buck Perley
f00ed98eea
Merge pull request #487 from bucko13/sort-outputs
pass sort option through http
2018-06-14 10:23:25 -07:00
bucko13
3a49d53372 pass sort option through http 2018-06-13 10:40:11 -07:00
Christopher Jeffrey
bc07492eba
pkg: update deps. 2018-06-08 22:53:51 -07:00
Christopher Jeffrey
5db6446be3
pkg: update deps. 2018-06-08 06:49:21 -07:00
Christopher Jeffrey
84bae8160d
test: remove old utils tests. 2018-06-08 04:19:18 -07:00
Christopher Jeffrey
6ddf452e96
pkg: remove package-lock for now. 2018-06-08 04:17:21 -07:00
Christopher Jeffrey
9f744fe64b
pkg: update deps. 2018-06-08 04:17:07 -07:00
Christopher Jeffrey
0977c5c133
net: fix nonce creation. 2018-06-08 04:16:59 -07:00
Steven Bower
25da26c415
Merge pull request #453 from bucko13/accounts-fix
add account option to create and send
2018-05-25 07:04:16 +08:00
Steven Bower
06a00424c2
Merge pull request #456 from pinheadmz/spvfix
fix SPV mode
2018-05-24 00:50:31 +08:00
Sky Young
2d5bfb45e2 Update testnet rpcPort 2018-05-21 13:34:29 -07:00
Sky Young
195b97c1e8 Update Version Number to beta.19 2018-05-21 13:11:03 -07:00
Sky Young
2c0482a7be Testnet has a block that has an issue with this 2018-05-21 13:09:50 -07:00
Sky Young
f6aaf70c3d Add support for all 3 difficulty calculation algorithms 2018-05-21 13:08:47 -07:00
Sky Young
d2d2400a8e Add Testnet Checkpoints 2018-05-21 13:08:05 -07:00
Sky Young
0e21984228 Fix testnet halving interval 2018-05-21 13:07:38 -07:00
Sky Young
ba20ad4a90 Fix testnet magic 2018-05-21 13:07:22 -07:00
Sky Young
2bed9f7ef4 return floData on .format 2018-05-18 17:52:56 -07:00
Sky Young
9184bf1cfa Validate signatures from both 0.8.7 and 0.10.4 using OMIT_TX_COMMENT flag 2018-05-15 14:10:40 -07:00
Sky Young
a764fa2eca Remove Seeds (always pull from DNS) 2018-05-14 16:38:43 -07:00
Sky Young
c9d676efb4 Update Difficulty Calculations 2018-05-14 16:38:03 -07:00
Sky Young
4c03efc1ca Fix target calculations (only V3) 2018-05-10 14:37:25 -07:00
Sky Young
2c1d46c206 Max Satosis of Flo > MAX_JAVASCRIPT_INT 2018-05-10 14:36:28 -07:00
Sky Young
426431b251 Update last checkpoint number 2018-05-10 13:54:36 -07:00
Sky Young
242fb759e6 Split value into wholeCoin and Satoshis when serialized & recombine on deserialization 2018-05-10 13:54:01 -07:00
Sky Young
5ea942b54b Fix package.json formatting 2018-05-09 14:36:49 -07:00
Sky Young
8c03f88d5f Update rltc to rflo 2018-05-09 14:36:29 -07:00
Sky Young
54431ea341 Add reverseHex helper script 2018-05-09 14:35:54 -07:00
Sky Young
90fc371355 Change miner User Agent to fcoin & update version reported 2018-05-09 14:34:17 -07:00
Sky Young
8e72b51c43 Serialize & Deserialize Tx Data properly 2018-05-09 14:33:46 -07:00
Sky Young
9746bf81b5 Add Flo checkpoints every 100k blocks 2018-05-09 14:33:19 -07:00
Sky Young
93781c712a Fix RPC port 2018-05-09 14:32:48 -07:00
Sky Young
add5821d52 Reverse hex byte array order for checkpoint hashes & magic 2018-05-09 14:32:39 -07:00
Matthew Zipkin
d6ffee09b2 spv write to disk 2018-05-09 06:36:40 +00:00
Sky Young
eddc878476 Switch to hex numbers vs decimal 2018-05-08 13:56:23 -07:00
Sky Young
3653da2d01 Flo-ify 2018-05-08 13:40:23 -07:00
EC2 Default User
4b64b06450 fix spvnode 2018-05-08 19:11:15 +00:00
bucko13
50263dfc0b add account option to create and send 2018-05-01 17:39:42 -07:00
Buck Perley
a59feadf49
Merge pull request #452 from tuxcanfly/install-windows
docs: update windows install guide
2018-04-27 09:34:16 -07:00
Javed Khan
c4cf4c22ef
docs: update windows install guide 2018-04-27 18:52:10 +05:30
Christopher Jeffrey
e093b2bdf6
pkg: add package-lock. 2018-04-06 17:03:07 -07:00
Christopher Jeffrey
0f33e58ebd
pkg: update more deps. 2018-04-06 16:46:30 -07:00
Christopher Jeffrey
d9c8e3daf9
pkg: update deps. 2018-04-06 16:34:58 -07:00
Christopher Jeffrey
bca5c1db55
pkg: update deps. 2018-04-06 16:26:05 -07:00
Christopher Jeffrey
a85ff2bbe9
pool: fix public port option. 2018-04-06 16:15:10 -07:00
Christopher Jeffrey
0c3657e167
networks: update checkpoints. 2018-04-06 16:15:10 -07:00
Christopher Jeffrey (JJ)
9fb9b1c4ad
Merge pull request #440 from nodar-chkuaselidze/mtx/from-json
MTX - Recover view from JSON
2018-04-06 16:12:35 -07:00
Christopher Jeffrey (JJ)
6208323195
Merge pull request #346 from sangaman/rpc-getaddressesbyaccount
Catch non-errors in rpc importaddress and getaddressesbyaccount
2018-04-06 16:09:57 -07:00
Christopher Jeffrey (JJ)
935c34f317
Merge branch 'master' into rpc-getaddressesbyaccount 2018-04-06 16:09:33 -07:00
Christopher Jeffrey (JJ)
3f8e337cae
Merge pull request #347 from amitkumarj441/patch-1
Update installation
2018-04-06 16:04:13 -07:00
Christopher Jeffrey (JJ)
4188a8431f
Merge pull request #377 from nodar-chkuaselidze/fix/rescan-log
walletdb: fix scan log
2018-04-06 16:03:50 -07:00
Christopher Jeffrey (JJ)
bb93599eb3
Merge branch 'master' into fix/rescan-log 2018-04-06 16:03:14 -07:00
Steven Bower
10e6b9a0c4
Merge pull request #443 from tuxcanfly/update-examples
docs: updated examples
2018-04-06 15:59:02 -07:00
Christopher Jeffrey (JJ)
b312f0e9b8
Merge pull request #360 from bucko13/outpoint-tests
Outpoint tests
2018-04-06 15:57:17 -07:00
Christopher Jeffrey (JJ)
a0333d105c
Merge branch 'master' into outpoint-tests 2018-04-06 15:56:39 -07:00
Javed Khan
886960b5f6
docs: updated examples 2018-04-07 04:05:34 +05:30
Nodar Chkuaselidze
916d42af57
mtx: receover view from JSON 2018-04-06 11:02:03 -07:00
Christopher Jeffrey (JJ)
447d0c8208
Merge pull request #439 from nodar-chkuaselidze/fix/account
account: fix create methods
2018-04-06 10:11:55 -07:00
Steven Bower
9bc81cac9c
Merge pull request #398 from tynes/Docs-fix-network-list
docs: replace unsupported option with supported
2018-04-03 10:35:01 -07:00
Steven Bower
11630e9134
Merge pull request #437 from BluSyn/conf-cors
Docs: Update sample conf w/ wallet.conf + http cors option
2018-04-03 10:31:32 -07:00
Steven Bower
22a41ded0d
Merge pull request #438 from nodar-chkuaselidze/tx-test
Test: Update bufferWriter
2018-04-03 10:30:16 -07:00
Nodar Chkuaselidze
022e08737a
account: fix create methods 2018-03-30 20:29:34 -07:00
Nodar Chkuaselidze
2fa6452002
test-tx: update bufferWriter pkg 2018-03-30 18:57:21 -07:00
Steven Bower
275b8e58a4
Docs: Update sample conf w/ wallet.conf + http cors option 2018-03-30 19:07:19 +00:00
Christopher Jeffrey (JJ)
7edefa6136
Merge pull request #367 from nodar-chkuaselidze/test/tx
test-tx: add tx tests
2018-03-29 22:38:46 -07:00
Christopher Jeffrey
c7d844ea37
node/wallet: add cors option. see #397. 2018-03-29 22:22:47 -07:00
Christopher Jeffrey (JJ)
6c8cf8c56a
Merge pull request #412 from sangaman/patch-1
Updating min node version in docs
2018-03-29 22:16:11 -07:00
Christopher Jeffrey
2efa5275d5
pkg: rename bcoin-wallet to bwallet. 2018-03-29 22:15:24 -07:00
Nodar Chkuaselidze
d25e553605
bin-wallet: fix bcoin wallet and add bin file to package.json 2018-03-29 22:14:47 -07:00
Orfeas Stefanos Thyfronitis Litos
2b0e5f5935
Document sendTX() return value 2018-03-29 22:12:01 -07:00
Orfeas Stefanos Thyfronitis Litos
8f3de71719
Handle broadcast() errors in sendTX()
Replace this.pool.broadcast(tx) with this.broadcast(tx) in case of a
selfish node because the latter handles broadcast errors, whereas the
former does not.
2018-03-29 22:11:50 -07:00
Orfeas Stefanos Thyfronitis Litos
c15cfbc081
Correct scriptVector() return value to {Stack}
The previously documented return value was {Boolean}.
2018-03-29 22:10:09 -07:00
Nodar Chkuaselidze
179c53d97f
wdb: fix hasAccount 2018-03-29 22:07:11 -07:00
Nodar Chkuaselidze
5f47b23736
wallet-http: provide info if key was added/removed to db 2018-03-29 22:07:00 -07:00
Javed Khan
37a1d02e76
networks: update simnet bech32 prefix 2018-03-29 22:06:48 -07:00
Steven Bower
432a33c012
CHANGELOG: Update configuraiton changes to include CLI/ENV differences from wallet.conf 2018-03-29 22:06:38 -07:00
Steven Bower
7e282c1ff3
CHANGELOG: Add section regarding wallet.conf 2018-03-29 22:06:29 -07:00
Steven Bower
8429c08ac6
Wallet: Minor log change
Makes it easier to distinguish between node HTTP server and wallet HTTP server in debug logs
2018-03-29 22:06:15 -07:00
Nodar Chkuaselidze
339dd50bf1
wallet: remove watchOnly check from wallet.fund 2018-03-29 22:06:05 -07:00
Christopher Jeffrey
8c609c6e9e
pkg: update deps. fix utils index. 2018-03-29 21:56:53 -07:00
Christopher Jeffrey
c388498ab0
pkg: update deps. 2018-03-29 21:56:53 -07:00
Christopher Jeffrey
319ec82997
wallet: fix depth incrementation. 2018-03-29 21:56:53 -07:00
Christopher Jeffrey
bd76939f4c
pkg: update bcrypto. 2018-03-29 21:56:53 -07:00
Christopher Jeffrey
1cf34273b3
pkg: update deps. 2018-03-29 21:56:53 -07:00
Christopher Jeffrey
ec876215a6
bip152: minor. 2018-03-29 21:56:53 -07:00
Christopher Jeffrey
d357ecb159
pkg: update deps. 2018-03-29 21:56:53 -07:00
Christopher Jeffrey
fac9c714db
bin: drop bin/cli. 2018-03-29 21:56:53 -07:00
Christopher Jeffrey
febc55b586
minor: lint. 2018-03-29 21:56:53 -07:00
Christopher Jeffrey
f1672a8b86
types: cleanup types. 2018-03-29 21:56:53 -07:00
Christopher Jeffrey
5b448b5bce
wallet: add wid->id index. 2018-03-29 21:56:53 -07:00
Christopher Jeffrey
c9d2037af6
pkg: add package-lock. 2018-03-29 21:56:52 -07:00
Christopher Jeffrey
1474d49231
script: remove useless vars. 2018-03-29 21:56:52 -07:00
Christopher Jeffrey
78df4f4d84
pkg: update deps. 2018-03-29 21:56:52 -07:00
Christopher Jeffrey
6787c001d2
build: improve no-compat webpack build. 2018-03-29 21:56:52 -07:00
Christopher Jeffrey
761ae4a80c
browser: fix error display. 2018-03-29 21:56:52 -07:00
Christopher Jeffrey
94fd001e88
wallet/http: require admin token. 2018-03-29 21:56:52 -07:00
Christopher Jeffrey
8f44352f63
pkg: update deps. 2018-03-29 21:56:52 -07:00
Christopher Jeffrey
dcfe25038b
pkg: start getting changelog ready. 2018-03-29 21:56:52 -07:00
Christopher Jeffrey
09b9f94a70
pkg: minor. 2018-03-29 21:56:52 -07:00
Christopher Jeffrey
c63e977ccf
chaindb: minor. 2018-03-29 21:56:52 -07:00
Christopher Jeffrey
d5a2609f75
peer: add reverse dns lookup. 2018-03-29 21:56:52 -07:00
Christopher Jeffrey
03ddc79dfc
script/address: fix addr checking for nested p2sh inputs. 2018-03-29 21:56:52 -07:00
Christopher Jeffrey
2054524fd7
bcoin: get browserify working. 2018-03-29 21:56:52 -07:00
Christopher Jeffrey
11c7dab3c4
browser: improve webpack build. 2018-03-29 21:56:51 -07:00
Christopher Jeffrey
e4ad8b457f
net: update seed list. 2018-03-29 21:56:51 -07:00
Christopher Jeffrey
99a7eb5fa5
wallet/bcoin: refactor exposure. 2018-03-29 21:56:51 -07:00
Christopher Jeffrey
425b8780f7
wallet: better option parsing for wallet plugin. 2018-03-29 21:56:51 -07:00
Christopher Jeffrey
e01a492489
cli: drop anti-replay. 2018-03-29 21:56:51 -07:00
Christopher Jeffrey
cd7c63d95d
wallet: always use separate http server. 2018-03-29 21:56:51 -07:00
Christopher Jeffrey
fcb3a10318
net: use bdns to resolve ip address. 2018-03-29 21:56:51 -07:00
Christopher Jeffrey
76c4321448
migrate: latest migration script. 2018-03-29 21:56:51 -07:00
Christopher Jeffrey
30597b83f6
wallet: refactor. 2018-03-29 21:56:51 -07:00
Christopher Jeffrey
aa3988aa2f
wallet/hostlist: minor. 2018-03-29 21:56:51 -07:00
Christopher Jeffrey
417b37b0c3
db: remove backend option. 2018-03-29 21:56:51 -07:00
Christopher Jeffrey
bad028ab67
chaindb: refactor. 2018-03-29 21:56:51 -07:00
Christopher Jeffrey
cb978df380
db: drop old migrations. avoid using encoding. 2018-03-29 21:56:51 -07:00
Christopher Jeffrey
83e1de2e98
db: stop relying on encoding. 2018-03-29 21:56:51 -07:00
Christopher Jeffrey
dbde501444
db: use bdb key object. 2018-03-29 21:56:50 -07:00
Christopher Jeffrey
167304666b
db: migrate to key objects. 2018-03-29 21:56:50 -07:00
Christopher Jeffrey
a8e2001015
txdb: use new bucket system. 2018-03-29 21:56:50 -07:00
Christopher Jeffrey
aa115c2e9d
wallet: refactor removal. 2018-03-29 21:56:50 -07:00
Christopher Jeffrey
a43a2102e6
masterkey: minor. 2018-03-29 21:56:50 -07:00
Christopher Jeffrey
9dc6ebd8cf
wallet: add removing wallet functionality. 2018-03-29 21:56:50 -07:00
Christopher Jeffrey
d896e221c0
migrate: add logs for wallet migration. 2018-03-29 21:56:50 -07:00
Christopher Jeffrey
86dc53f9dd
wallet: smarter path serialization. 2018-03-29 21:56:50 -07:00
Christopher Jeffrey
efca42b138
wallet: migrate paths. 2018-03-29 21:56:50 -07:00
Christopher Jeffrey
e2ef35b24b
wallet: more migrations. 2018-03-29 21:56:50 -07:00
Christopher Jeffrey
0055c82f22
migrate: add walletdb 6-to-7 migration. 2018-03-29 21:56:50 -07:00
Christopher Jeffrey
f99064750a
net: move netaddress. 2018-03-29 21:56:50 -07:00
Christopher Jeffrey
5ea218b373
bcoin: require bn.js directly. 2018-03-29 21:56:49 -07:00
Christopher Jeffrey
3c82ac0486
bcoin: use util.revHex again. 2018-03-29 21:56:49 -07:00
Christopher Jeffrey
f2abdf68cb
bcoin: move encoding constants around. 2018-03-29 21:56:49 -07:00
Christopher Jeffrey
9b269dd1f0
script: remove mast. 2018-03-29 21:56:49 -07:00
Christopher Jeffrey
163e89fc29
bcoin: lint. 2018-03-29 21:56:49 -07:00
Christopher Jeffrey
73664efcd0
bcoin: classify everything else. 2018-03-29 21:56:49 -07:00
Christopher Jeffrey
bad24a6f31
workers: classify. 2018-03-29 21:56:49 -07:00
Christopher Jeffrey
f313ca166d
wallet: classify. 2018-03-29 21:56:49 -07:00
Christopher Jeffrey
9240d2f827
protocol: classify. 2018-03-29 21:56:49 -07:00
Christopher Jeffrey
93fe6669bf
node: classify. 2018-03-29 21:56:49 -07:00
Christopher Jeffrey
4ebfb5d9ff
net: classify. 2018-03-29 21:56:49 -07:00
Christopher Jeffrey
8be995bd78
miner: classify. 2018-03-29 21:56:49 -07:00
Christopher Jeffrey
5c8a755d63
mempool: classify. 2018-03-29 21:56:49 -07:00
Christopher Jeffrey
32b81f0d95
btc: classify. 2018-03-29 21:56:48 -07:00
Christopher Jeffrey
51e3341252
script: classify. 2018-03-29 21:56:48 -07:00
Christopher Jeffrey
91ee6077b1
lru: minor. 2018-03-29 21:56:48 -07:00
Christopher Jeffrey
405feef9ce
bcoin: clean up requires. 2018-03-29 21:56:48 -07:00
Christopher Jeffrey
21ab415769
refactor: switch to bio module. 2018-03-29 21:56:48 -07:00
Christopher Jeffrey
bf4f5e3bac
bcoin: bstring requires. 2018-03-29 21:56:48 -07:00
Christopher Jeffrey
6a5d5c1e48
chain: no return await. 2018-03-29 21:56:48 -07:00
Christopher Jeffrey
3565d5dfe7
chaindb: minor. 2018-03-29 21:56:48 -07:00
Christopher Jeffrey
280d5d38e5
net/miner/hd: classify. 2018-03-29 21:56:48 -07:00
Christopher Jeffrey
daa55a05bc
primitives: classify primitives. 2018-03-29 21:56:48 -07:00
Christopher Jeffrey
ca08d6d97e
bcoin: rename bufio and bstring. 2018-03-29 21:56:48 -07:00
Christopher Jeffrey
3c3f6b953c
network/fees: minor. 2018-03-29 21:56:48 -07:00
Christopher Jeffrey
8dbf7e8ba2
pkg: add deps. 2018-03-29 21:56:47 -07:00
Christopher Jeffrey
7bdd6e3519
minor: s/breq/brq/g 2018-03-29 21:56:47 -07:00
Christopher Jeffrey
73892701e8
utils: switch to bevent. 2018-03-29 21:56:47 -07:00
Christopher Jeffrey
4535cd1827
utils: start using bmutex. 2018-03-29 21:56:47 -07:00
Christopher Jeffrey
a79c2b0b1a
bcoin: start switching to class syntax. 2018-03-29 21:56:47 -07:00
Christopher Jeffrey
f9eba3f5a6
crypto: start using hash.digest(). 2018-03-29 21:56:47 -07:00
Christopher Jeffrey
8332b93721
utils: remove dependence on co. 2018-03-29 21:56:47 -07:00
Christopher Jeffrey
277ac9a62a
net: start using bsocks and bupnp. 2018-03-29 21:56:47 -07:00
Christopher Jeffrey
ce8b6f483f
net: start using btcp and bdns. 2018-03-29 21:56:47 -07:00
Christopher Jeffrey
424370bc1f
utils: stop using asyncobject. 2018-03-29 21:56:47 -07:00
Christopher Jeffrey
cbef19047a
bcoin: cleanup. fix bsock calls. 2018-03-29 21:56:47 -07:00
Christopher Jeffrey
401829db5a
node: start using blgr and bcfg. 2018-03-29 21:56:47 -07:00
Christopher Jeffrey
fe03b42936
utils: start using bval. 2018-03-29 21:56:47 -07:00
Christopher Jeffrey
77403b0a3e
utils: start using binet. 2018-03-29 21:56:46 -07:00
Christopher Jeffrey
d4685e6e6c
utils: start using bstr. 2018-03-29 21:56:46 -07:00
Christopher Jeffrey
41925d495c
utils: start using bbuf. 2018-03-29 21:56:46 -07:00
Christopher Jeffrey
e92b1f4cec
utils: start using bfilter. 2018-03-29 21:56:46 -07:00
Christopher Jeffrey
3a722481f9
utils: use bfile over utils/fs. 2018-03-29 21:56:46 -07:00
Christopher Jeffrey
658d3db928
encoding: refactor. remove bip70. 2018-03-29 21:56:46 -07:00
Christopher Jeffrey
8ef82606e1
bcoin: cleanup. remove rbt. 2018-03-29 21:56:46 -07:00
Christopher Jeffrey
79260891e4
hd: move nfkd to hd directory. 2018-03-29 21:56:46 -07:00
Christopher Jeffrey
9c81a00236
pkg: update deps. 2018-03-29 21:56:46 -07:00
Christopher Jeffrey
d1e4be8343
bcoin: use bdb. 2018-03-29 21:56:46 -07:00
Christopher Jeffrey
771a4ef17f
wallet: client refactor. 2018-03-29 21:56:46 -07:00
Christopher Jeffrey
aedbe27b6e
wallet: rename some methods. 2018-03-29 21:56:46 -07:00
Christopher Jeffrey
eaf2fa5ea2
wallet: add logs. 2018-03-29 21:56:46 -07:00
Christopher Jeffrey
b39554fa98
txdb: minor. 2018-03-29 21:56:45 -07:00
Christopher Jeffrey
37fdc7c08b
cli: improve wallet support. 2018-03-29 21:56:45 -07:00
Christopher Jeffrey
11ac46e051
wallet/client: different parsing solution. 2018-03-29 21:56:45 -07:00
Christopher Jeffrey
a313ac244c
wallet/client: fix arg parsing. 2018-03-29 21:56:45 -07:00
Christopher Jeffrey
749d4edc11
wallet: fixes for wallet server. 2018-03-29 21:56:45 -07:00
Christopher Jeffrey
877cecbedc
config: fix env parsing. 2018-03-29 21:56:45 -07:00
Christopher Jeffrey
cc91e3ea7b
http: move to node module. 2018-03-29 21:56:45 -07:00
Christopher Jeffrey
5a23ba96d0
wallet: get server working. 2018-03-29 21:56:45 -07:00
Christopher Jeffrey
d0ed214067
bcoin: remove dependence on util.js. 2018-03-29 21:56:45 -07:00
Christopher Jeffrey
1a5782fa06
script: do not use util.reverse. 2018-03-29 21:56:45 -07:00
Christopher Jeffrey
636d66a5c7
bcoin: use bcrypto. remove crypto module. 2018-03-29 21:56:45 -07:00
Christopher Jeffrey
c84afad1f6
http: use bsock instead of socket.io. 2018-03-29 21:56:45 -07:00
Christopher Jeffrey
a6dc571c2d
http: use bclient. 2018-03-29 21:56:45 -07:00
Christopher Jeffrey
f6ca348566
http: minor. 2018-03-29 21:56:44 -07:00
Christopher Jeffrey
a87260c959
http: rpc improvements. minor fixes. 2018-03-29 21:56:44 -07:00
Christopher Jeffrey
5ed8c0f4fe
walletclient: cleanup. 2018-03-29 21:56:44 -07:00
Christopher Jeffrey
649f8cc171
http: stop using socket.io. 2018-03-29 21:56:44 -07:00
Christopher Jeffrey
f617283539
wallet: remove useless server. 2018-03-29 21:56:44 -07:00
Christopher Jeffrey
fe2a6eb793
http: refactor to make separation easier. 2018-03-29 21:56:44 -07:00
Christopher Jeffrey
fc3b31836b
wallet/http: improve validation. 2018-03-29 21:56:44 -07:00
Christopher Jeffrey
645cafe653
wallet: minor. 2018-03-29 21:56:44 -07:00
Christopher Jeffrey
9a8106f4f7
refactor: avoid using utils in crypto and vice versa. 2018-03-29 21:56:44 -07:00
Christopher Jeffrey
f3b94ded65
wallet/bcoin: stop tracking network everywhere. 2018-03-29 21:56:44 -07:00
Christopher Jeffrey
40bb08aed6
wallet: better/less property tracking. 2018-03-29 21:56:44 -07:00
Christopher Jeffrey
fe261db706
wallet: track account balances. 2018-03-29 21:56:44 -07:00
Christopher Jeffrey
175f169504
test: add more wallet double spend tests. 2018-03-29 21:56:44 -07:00
Christopher Jeffrey
bd4367a2d1
txdb: fixes for input writing. 2018-03-29 21:56:43 -07:00
Christopher Jeffrey
abcf48cbe9
wallet: update rpc calls for getHashes. 2018-03-29 21:56:43 -07:00
Christopher Jeffrey
c16e85e485
wallet: all async methods. 2018-03-29 21:56:43 -07:00
Christopher Jeffrey
c6d7c43485
wallet: tests passing. 2018-03-29 21:56:43 -07:00
Christopher Jeffrey
55f5ff9493
wallet: use batches. 2018-03-29 21:56:43 -07:00
Christopher Jeffrey
969fd8f704
wallet-rewrite 2018-03-29 21:56:43 -07:00
Christopher Jeffrey
d7d390afb9
Revert "Fix confirmations not found"
This reverts commit e59ed00b57.
2018-03-29 21:56:34 -07:00
Christopher Jeffrey
9967f780df
Revert "http: fix block call."
This reverts commit 4ff93746a0.
2018-03-29 21:56:26 -07:00
Christopher Jeffrey
31651ce76e
Revert "mtx: allow multiple indicies for subtractIndex."
This reverts commit d489238711.
2018-03-29 21:55:36 -07:00
Daniel McNally
2f84f93784
Updating min node version
Updating the minimum node.js version to match the minimum version specified in package.json.
2018-02-11 12:55:13 -05:00
tynes
469aeb0139 docs: replace unsupported option with supported 2018-01-05 21:21:31 -07:00
ultragtx
5abec93d80 Litecoin: readme 2017-12-08 16:03:52 +08:00
ultragtx
4e7675cc7a Litecoin: litecoinify 2017-12-08 16:03:46 +08:00
Nodar Chkuaselidze
52584af3c2
walletdb: fix scan log 2017-11-22 19:57:23 +04:00
Node
bbafb98fcc
test-tx: add tx tests 2017-11-08 18:25:00 +04:00
Buck
dd69f18cc3 fixed lint errors 2017-11-05 14:48:37 -08:00
Buck
c51cc88ef6 PR cleanup 2017-11-05 14:46:02 -08:00
Christopher Jeffrey
d489238711
mtx: allow multiple indicies for subtractIndex. 2017-11-04 12:16:28 -07:00
Christopher Jeffrey
4ff93746a0
http: fix block call. 2017-11-04 12:16:28 -07:00
Buck
48d41ed55d tests for outpoint 2017-11-03 18:42:33 -07:00
Buck
68b3ddf482 fixed outpoint bug and added first test 2017-11-03 14:51:37 -07:00
Daniel McNally
b9b4e5f182 Catch 'already exists' error in importAddress 2017-10-20 21:49:31 -04:00
Buck Perley
bab42bbed8 Merge pull request #345 from nodar-chkuaselidze/fix/confirms
Fix confirmations not found
2017-10-20 11:06:37 -07:00
Amit Kumar Jaiswal
9bdf1c1df6 Update installation
Signed-off-by: Amit Kumar Jaiswal <amitkumarj441@gmail.com>
2017-10-20 22:31:37 +05:30
Daniel McNally
d77838d3a2 Catch 'not found' error in getAddressesByAccount 2017-10-20 11:50:04 -04:00
Node
e59ed00b57
Fix confirmations not found 2017-10-20 15:00:56 +04:00
Christopher Jeffrey
6bc8701f23
bcoin: some code cleanup. 2017-10-19 02:05:40 -07:00
Christopher Jeffrey (JJ)
a1ec1c255e Merge pull request #307 from Bucko13/setpassphrase-fix
More consistent behavior around setting passphrase on unencrypted wallet
2017-10-18 22:44:02 -07:00
Christopher Jeffrey (JJ)
5ba79e4729 Merge pull request #316 from Bucko13/lock-coin-bug
use req.wallet for lock coin endpoints
2017-10-18 22:42:42 -07:00
Christopher Jeffrey (JJ)
a4858e274b Merge pull request #295 from Bucko13/segwit-keyring
pass options on keyring creation
2017-10-18 22:40:08 -07:00
Christopher Jeffrey (JJ)
340f2176fc Merge pull request #292 from nodar-chkuaselidze/fix/rpc-getbalance-default
RPC: change default to getbalance
2017-10-18 22:39:20 -07:00
Christopher Jeffrey (JJ)
26f9f975b2 Merge pull request #286 from Bucko13/retoken-passphrase
pass the passphrase to retoken
2017-10-18 22:31:43 -07:00
Christopher Jeffrey (JJ)
c44293acd8 Merge pull request #282 from nodar-chkuaselidze/fix/createrawtransaction
RPC: Create/Sign Raw Transaction fix
2017-10-18 22:31:23 -07:00
Christopher Jeffrey (JJ)
bdeb72a035 Merge pull request #281 from Bucko13/import-key-passphrase
pass passphrase for key import
2017-10-18 22:30:10 -07:00
Christopher Jeffrey (JJ)
af64e2dd0a Merge pull request #324 from tuxcanfly/test-coin
Primitives tests: coin
2017-10-18 22:26:10 -07:00
Christopher Jeffrey (JJ)
9098d4dcd6 Merge pull request #298 from nodar-chkuaselidze/fix/rpc-verifytxoutproof
rpc: fix verifytxoutproof
2017-10-18 22:25:50 -07:00
Christopher Jeffrey (JJ)
783f57e4a9 Merge pull request #291 from tuxcanfly/test-address
Primitives tests - addresses
2017-10-18 22:25:12 -07:00
Christopher Jeffrey (JJ)
61906d7564 Merge pull request #300 from tuxcanfly/passphrase-fix
client: use 'new' passphrase param
2017-10-18 22:24:03 -07:00
Christopher Jeffrey (JJ)
4c0f8840b1 Merge pull request #319 from tuxcanfly/docs-workers
Docs: update worker options
2017-10-18 13:22:45 -07:00
Christopher Jeffrey (JJ)
c1144a9955 Merge pull request #327 from nodar-chkuaselidze/test-input
Tests: Input
2017-10-18 13:21:41 -07:00
Christopher Jeffrey (JJ)
8883da8a7d Merge pull request #308 from Bucko13/createTX-signature
remove outputs from function signature
2017-10-18 13:20:53 -07:00
Christopher Jeffrey (JJ)
1a3c5e8a22 Merge pull request #323 from tuxcanfly/test-headers
Primitives tests - headers
2017-10-18 13:17:46 -07:00
Christopher Jeffrey (JJ)
e137288b78 Merge pull request #325 from sangaman/master
Adding confirmations property to block and tx getJSON
2017-10-18 13:17:17 -07:00
Christopher Jeffrey (JJ)
8c091f6e08 Merge pull request #329 from nodar-chkuaselidze/fix/http-client
Fix bcoin.http.Client errors
2017-10-18 13:11:49 -07:00
Christopher Jeffrey (JJ)
3e3f3143d0 Merge pull request #334 from sangaman/watch-only-cli-fix
Allow --watch without accountKey value for cli createWallet
2017-10-18 13:08:27 -07:00
Christopher Jeffrey (JJ)
4bf7426566 Merge pull request #342 from nodar-chkuaselidze/enhancement/cli-bech32
CLI to accept bech32 addresses
2017-10-18 13:06:46 -07:00
Christopher Jeffrey
57181f27ee
walletdb: increase bloom filter size to 3m addrs. 2017-10-18 12:58:22 -07:00
Christopher Jeffrey
bfde70f2ab
db: improve iterator perf. 2017-10-18 12:58:22 -07:00
Christopher Jeffrey
4d8ca8c16f
db: change iterator api to be more loop-friendly. 2017-10-18 12:58:21 -07:00
Christopher Jeffrey
1c1e429383
fs/co: add fs.exists and wait for promise on co.clearInterval. 2017-10-18 12:58:21 -07:00
Christopher Jeffrey
aeb3d8f352
http: minor fixes. 2017-10-18 12:58:21 -07:00
Christopher Jeffrey
86746e2bd0
siphash: add siphash32 and siphash64. 2017-10-18 12:58:21 -07:00
Node
3a802cacd6
cli: accept bech32 addresses in getTX/getCoin 2017-10-16 23:49:02 +04:00
Javed Khan
a1b5cdc88a docs: add workers-timeout under worker options 2017-10-17 00:45:38 +05:30
Buck Perley
54b930baba Merge pull request #333 from nodar-chkuaselidze/docs/clean-up
Docs: Update
2017-10-16 11:52:23 -07:00
Daniel McNally
126a24479a Create distinct --key & --watch
Creates a separate --key argument to be separate from --watch and avoid confusion.
2017-10-13 13:25:38 -04:00
Daniel McNally
3104220f1b Allow --watch without accountKey value
Fixes a bug with `cli wallet create` where if no value is specified for the --watch option, the accountKey is assigned a value of "true" which is invalid and causes errors downstream. This fix leaves accountKey as null, and the resulting functionality appears to match wallet creation via HTTP request where `watchOnly` is true and `accountKey` is not given a value.
2017-10-12 02:49:12 -04:00
Node
d76ca37d0d
rpcclient: check body.error first 2017-10-11 16:23:37 +04:00
Node
89716b2edd
docs: reorganize, update links 2017-10-09 21:18:31 +04:00
Node
b40ac6e081
http-client: fix returned errors 2017-10-05 18:52:14 +04:00
Daniel McNally
4f317992f5 Fixes to TX & Block confirmations property
TX `confirmations` property set to 0 for unconfirmed transactions. Block
`confirmations` property set to -1 for orphaned blocks. Fixing to add +1
to `confirmations` to match bitcoind behavior and corresponding bcoin
rpc  methods - block or tx at tip of main chain starts with 1
confirmation (not zero).
2017-10-02 00:58:48 -07:00
Daniel McNally
c2cef86296 Adding 'confirmations' property to block getJSON
Adds a 'confirmations' property to the JSON returned by `cli tx [hash]`
as well as the Rest `/tx/:hash` call by subtracting block height from
chain height
2017-09-28 23:41:13 -04:00
Daniel McNally
0f68427778 Adding 'confirmations' property to TX getJSON
Adds a 'confirmations' property to the JSON returned by cli tx [hash] as
well as the REST '/tx/:hash' call by subtracting TX height from chain
height
2017-09-28 22:47:50 -04:00
Javed Khan
b9f19038ba tests: add coin tests 2017-09-28 19:46:54 +05:30
Javed Khan
7b73402377 tests: add headers tests 2017-09-27 19:54:45 +05:30
Christopher Jeffrey
ca4e938a75
mempool: fix orphan resolution edge case. 2017-09-26 20:22:54 -07:00
Christopher Jeffrey
1aa78e2248
mempool: sanitize after reorg. 2017-09-26 17:20:16 -07:00
Christopher Jeffrey
459a9f25f4
chain/mempool: optimize coinview handling. fix mempool orphan edge case. 2017-09-26 13:07:01 -07:00
Node
104dd9344b
test: add input test 2017-09-25 23:33:05 +04:00
Javed Khan
966ac168aa docs: update common options related to workers 2017-09-21 20:37:49 +05:30
Node
05e069dc56
test: Add input tests 2017-09-20 22:33:25 +04:00
Christopher Jeffrey
17e473fda5
upnp: minor. 2017-09-19 17:52:19 -07:00
Bucko
e27408dc58 getCoin was unnecessarily passing account 2017-09-19 15:43:34 -07:00
Bucko
d9ebfcc2f9 coin lock methods weren't handling parameters correctly in http client 2017-09-19 14:28:26 -07:00
Christopher Jeffrey
991213d303
chain: fix typo. 2017-09-19 13:30:53 -07:00
Christopher Jeffrey
4c18dc5d0e
chain/util: minor style change. 2017-09-19 13:10:40 -07:00
Christopher Jeffrey
4150623eb0
v1.0.0-beta.15 2017-09-19 12:51:07 -07:00
Bucko
e3ac717ada use req.wallet for lock coin endpoints 2017-09-18 18:55:44 -07:00
Christopher Jeffrey
fdca08b498
chain: minor. 2017-09-06 23:06:41 -07:00
Christopher Jeffrey
f63c19cb19
bn: stop using bn#cmp. 2017-09-06 22:51:06 -07:00
Christopher Jeffrey
5107cfd27a
consensus: clean up some functions. 2017-09-06 22:38:23 -07:00
Christopher Jeffrey
d78df4b79c
miner: minor. 2017-09-06 14:21:23 -07:00
Christopher Jeffrey
eb5469088c
chain: refactor checkpoints handling. other misc refactoring. 2017-09-06 14:17:39 -07:00
Christopher Jeffrey
5f82c0d8c2
chain: alias all db methods. remove chainentry spaghetti code. 2017-09-06 10:20:40 -07:00
Christopher Jeffrey
b81643473e
encoding: refactor int64 handling. 2017-09-05 21:17:58 -07:00
Christopher Jeffrey
79d1bbd823
bench: fix coins benchmarks. 2017-09-05 11:46:14 -07:00
Christopher Jeffrey
83178e9333
encoding: minor. 2017-09-05 09:41:02 -07:00
Christopher Jeffrey
4046202b3f
lint: minor. 2017-09-04 16:46:47 -07:00
Christopher Jeffrey
a2c3e70f09
bip151: use buffer pool. 2017-09-04 13:12:10 -07:00
Javed Khan
4516adca3b Delete unnecessary test data file 2017-09-04 16:12:05 +05:30
Javed Khan
dc9b1b6b51 Fix wrong test data - p2sh address 2017-09-04 16:08:39 +05:30
Christopher Jeffrey
7e456595de
workers: minor. 2017-09-03 22:16:06 -07:00
Christopher Jeffrey
d00e924965
hd: use buffer pool for key derivation. 2017-09-03 11:29:59 -07:00
Christopher Jeffrey
45e41b1bb4
writer: alloc pool lazily. 2017-09-03 00:56:15 -07:00
Christopher Jeffrey
a543648310
writer: use 100kb pool for sighashing. 2017-09-03 00:05:47 -07:00
Christopher Jeffrey
e0eb1cdbe3
refactor: remove all duck typing. 2017-09-02 21:29:38 -07:00
Christopher Jeffrey
bc25bdb016
workers: drop all static methods for packets. 2017-09-02 21:09:22 -07:00
Christopher Jeffrey
d871751bba
test: use utils for gcs test. 2017-09-01 20:56:42 -07:00
Christopher Jeffrey
ad4c7e81c8
tx: minor. 2017-09-01 18:05:50 -07:00
Christopher Jeffrey
55f594d616
stack: remove useless checks. 2017-09-01 18:05:26 -07:00
Bucko
4329907e86 fixed signature as well as call 2017-08-30 16:38:43 -07:00
Bucko
df52cbe6f9 remove outputs from function signature 2017-08-30 16:36:30 -07:00
Bucko
778e118378 implement tux's fix for changing property name and more consistent behavior around setting passphrase on unencrypted wallet 2017-08-30 14:32:24 -07:00
Christopher Jeffrey
57b98b2368
tx: refactor hasStandardWitness. 2017-08-30 10:14:51 -07:00
Christopher Jeffrey
063f55f448
script: remove instances of script.getSmall(). 2017-08-30 10:07:07 -07:00
Christopher Jeffrey
7022c6649f
tx: minor. 2017-08-28 06:08:50 -07:00
Christopher Jeffrey
b87f557823
tx/script/chain: refactor locktime handling. 2017-08-27 19:07:57 -07:00
Christopher Jeffrey
73b84cc1a7
lint: remove useless parens. 2017-08-27 16:50:23 -07:00
Javed Khan
9b777ac7e5 client: use 'new' passphrase param 2017-08-27 15:14:43 +05:30
Christopher Jeffrey
9d48c1385b
mtx: rename subtractFee to subtractIndex. 2017-08-26 12:37:08 -07:00
Christopher Jeffrey
3c2c8ea955
hd: pass purpose number to bip44 derivation. drop bip45 support. 2017-08-26 02:41:27 -07:00
Christopher Jeffrey
26f6fb5277
wallet: enforce settxfee for all functions. 2017-08-26 01:35:36 -07:00
Christopher Jeffrey
6742482445
mtx: subtract fee evenly from all outputs. 2017-08-26 01:21:25 -07:00
Christopher Jeffrey
c6b76ec73f
Revert "wallet/mtx: add extraOutputs option."
This reverts commit 3957f83a59.
2017-08-26 00:13:24 -07:00
Christopher Jeffrey
140eece7dd
script: improve perf of getScripthash. 2017-08-25 20:54:56 -07:00
Christopher Jeffrey
49154be76d
script: refactor opcode and optimize. 2017-08-25 18:54:51 -07:00
Christopher Jeffrey
eabcf21f49
fuzz: lint. 2017-08-25 18:10:29 -07:00
Christopher Jeffrey
87b8ba4ec4
test: minor. 2017-08-25 16:22:52 -07:00
Christopher Jeffrey
3957f83a59
wallet/mtx: add extraOutputs option. 2017-08-25 15:10:30 -07:00
Christopher Jeffrey
b0a75baa5a
test: minor. 2017-08-25 15:06:12 -07:00
Christopher Jeffrey
5fae0c50a1
script: enforce stack size on unexecuted branches.
This primarily only affects zero-length scripts. An input script which pushed
this many items onto the stack without failing _is not possible_, but with
segwit, it is possible. However, a witness program would fail due to cleanstack
before there would be any kind of consensus fault. In other words, without this
fix, we still remain in consensus with bitcoin core, but ideally we should want
to fail for the same reason.
2017-08-25 08:08:47 -07:00
Javed Khan
5bfbab2bb7 p2sh test case: Use fromScript 2017-08-25 20:14:19 +05:30
Javed Khan
6a038930f5 tests: Add address tests 2017-08-25 20:14:19 +05:30
Node
1c25d8913e
rpc: fix revHex arg in verifytxoutproof 2017-08-25 15:24:54 +04:00
Christopher Jeffrey
7145d21c9c
script: improve isCode. 2017-08-24 23:47:22 -07:00
Christopher Jeffrey
47eb484657
script: include opcode and instruction pointer in stack size errors. 2017-08-24 23:13:31 -07:00
Christopher Jeffrey
13892b3b38
encoding: rename written to offset. 2017-08-24 22:36:59 -07:00
Christopher Jeffrey
22a879f154
opcode: fix uncatchable error on .equals(). 2017-08-24 22:24:39 -07:00
Christopher Jeffrey
f1ac30a6c1
fuzz: update fuzzer to use bitcoinconsensus. 2017-08-24 22:23:53 -07:00
Christopher Jeffrey
af132c8818
opcode: handle OP_1NEGATE in opcode.toNum. 2017-08-24 18:22:45 -07:00
Christopher Jeffrey
d6ce66bce9
script: refactor script and stack mutation.
This allows more reasonable signing behavior and eliminates all polymorphism.
2017-08-24 17:34:20 -07:00
Bucko
ed4e7b1243 pass options on keyring creation 2017-08-24 17:19:05 -07:00
Node
82595b95eb
rpc: getbalance default minconf=1 2017-08-24 20:57:27 +04:00
Christopher Jeffrey
9d74c837e8
bench: sigops benchmarks. 2017-08-21 20:59:21 -07:00
Christopher Jeffrey
5468465e88
bench: tx benchmark. 2017-08-21 15:04:35 -07:00
Christopher Jeffrey
a6b2c23a41
script: start using scriptnum implementation. 2017-08-20 15:13:17 -07:00
Christopher Jeffrey
1b0ae3ca79
refactor: use defineProperty instead of __define[GS]etter__. 2017-08-20 15:10:58 -07:00
Christopher Jeffrey
c54ba4c5ab
http/client: lint. 2017-08-20 14:35:42 -07:00
Christopher Jeffrey
6c8c18f2a0
opcode: improve perf of opcode.from methods. 2017-08-20 12:52:35 -07:00
Christopher Jeffrey
2647d011dc
opcode: experiment with using cached opcodes. 2017-08-19 23:14:30 -07:00
Christopher Jeffrey
5047028511
script: stop using new Opcode. 2017-08-19 23:14:18 -07:00
Christopher Jeffrey
040e798d9f
rpc: fix getTXOutProof. 2017-08-19 19:36:28 -07:00
Bucko
4085e3d9b9 pass the passphrase to retoken 2017-08-18 19:18:23 -07:00
Node
29f9d401e4
rpc: signrawtransaction input name fix 2017-08-18 14:35:12 +04:00
Node
4fb2df7789
rpc: createrawtransaction from inputs 2017-08-18 11:01:43 +04:00
Christopher Jeffrey
c69e7195b9
pkg: upgrade n64. 2017-08-17 23:35:52 -07:00
Christopher Jeffrey
8f9f5dfc06
pool: fix map.clear call in stopSync. fixes #274. 2017-08-17 19:51:54 -07:00
Bucko
af32c5d4c2 pass passphrase for key import 2017-08-17 18:24:40 -07:00
Christopher Jeffrey (JJ)
b7789c763c Merge pull request #269 from nodar-chkuaselidze/docs/examples
Docs/examples
2017-08-17 17:24:16 -07:00
Christopher Jeffrey (JJ)
d44d93486f Merge pull request #279 from Bucko13/check-for-id-param
check in http client that an id is passed to create wallet
2017-08-17 17:23:47 -07:00
Christopher Jeffrey (JJ)
fd5dcec680 Merge pull request #278 from Bucko13/wallet-options
add documentation for mnemonic option in wallet creation
2017-08-17 17:23:21 -07:00
Christopher Jeffrey (JJ)
2c8fcafa0a Merge pull request #265 from nodar-chkuaselidze/fix/rpc-requests
REST API fixes
2017-08-17 17:23:04 -07:00
Christopher Jeffrey (JJ)
87a31093f6 Merge pull request #276 from nodar-chkuaselidze/fix/invalidate
Chain: Fix _invalidate
2017-08-17 17:21:33 -07:00
Christopher Jeffrey
5415147d4e
encoding: encoding improvements for base128 varints. 2017-08-17 10:55:30 -07:00
Christopher Jeffrey
51cdd6156b
encoding: lint. 2017-08-17 10:04:51 -07:00
Christopher Jeffrey
846aae9f98
eslintrc: indent is making eslint crash. 2017-08-17 10:03:36 -07:00
Christopher Jeffrey
a47d68024a
scriptnum: improve encoding. 2017-08-17 09:59:17 -07:00
Christopher Jeffrey
668202b2f9
encoding: start using int64 objects instead of BNs. 2017-08-17 09:56:57 -07:00
Christopher Jeffrey
411db44a76
workers: fix ErrorResultPacket. 2017-08-17 09:56:22 -07:00
Christopher Jeffrey
a91bd5c958
script: improve new scriptnum. 2017-08-16 20:36:09 -07:00
Christopher Jeffrey
ad3bc3c8d6
pkg: upgrade n64. 2017-08-16 20:17:22 -07:00
Bucko
64b7e4d0df check in http client that an id is passed to create wallet 2017-08-16 17:58:37 -07:00
Bucko
c3d8c6c377 add param for mnemonic in documentation for wallet creation options 2017-08-16 16:47:19 -07:00
Christopher Jeffrey
772025a4a1
script: a better scriptnum implementation. 2017-08-16 15:33:44 -07:00
Christopher Jeffrey
1f5fd553de
pkg: update deps. 2017-08-16 15:32:56 -07:00
Christopher Jeffrey
d277d55560
bn: use toArrayLike instead of toBuffer. 2017-08-16 15:32:24 -07:00
Node
15b22c03fa
chain: fix _invalidate 2017-08-16 21:06:08 +04:00
Christopher Jeffrey
f9eca70374
pkg: upgrade n64. 2017-08-15 18:47:34 -07:00
Christopher Jeffrey
2ce2f1f9f7
rpc: refactor getTXOutProof and mining calls. 2017-08-14 17:52:31 -07:00
Christopher Jeffrey
09a2dc0f55
cpuminer: avoid division by zero. 2017-08-14 17:51:40 -07:00
Christopher Jeffrey
453bc82a8d
test: remove forEach loop in tx-test. 2017-08-14 17:51:16 -07:00
Node
0bf76001cf
docs/examples: Get InputValue and OutputValue on tx 2017-08-14 17:16:45 +04:00
Christopher Jeffrey
0bdfe51097
pkg: update deps. 2017-08-14 00:43:21 -07:00
Christopher Jeffrey
e8c375b372
test: remove useless .fill() calls. 2017-08-13 14:25:02 -07:00
Christopher Jeffrey
b013b2f0f9
util: add toFloat function. 2017-08-13 13:15:56 -07:00
Christopher Jeffrey
46af7f5760
test: move consensus tests out of utils tests. 2017-08-13 13:01:43 -07:00
Christopher Jeffrey
b021f7cdd4
util: minor. 2017-08-13 12:21:56 -07:00
Christopher Jeffrey
ebb79e5ff1
secp256k1: es6ify length normalization. 2017-08-13 12:21:44 -07:00
Christopher Jeffrey
e1e71a6e81
test: minor. 2017-08-13 08:05:37 -07:00
Christopher Jeffrey
b3f02eb70a
test: run sigops tests without cache. 2017-08-13 08:03:34 -07:00
Christopher Jeffrey
d33443186c
minor: lint. 2017-08-13 07:52:17 -07:00
Christopher Jeffrey
2e8d8f59c6
test: change file naming convention. 2017-08-12 20:29:27 -07:00
Christopher Jeffrey
0e7d5d7ab9
test: more sigops counting test vectors. 2017-08-12 20:02:44 -07:00
Christopher Jeffrey
e37d299049
test: create better interface for block/tx test vectors. 2017-08-12 19:38:58 -07:00
Christopher Jeffrey
5a751d9ba7
test: add some new functions to test/util/common. 2017-08-12 18:12:45 -07:00
Christopher Jeffrey
c522c79c58
test: more refactoring of various tests and assert module. 2017-08-12 12:51:52 -07:00
Christopher Jeffrey
3a7484d782
test: refactor assertions. 2017-08-11 18:25:54 -07:00
Christopher Jeffrey
28d2f1478e
workers: do not listen for close event. 2017-08-11 15:21:16 -07:00
Christopher Jeffrey
b8f57df90c
hd: use a u32 for fingerprints. 2017-08-11 14:47:54 -07:00
Christopher Jeffrey
aa327131e8
hd: improve arg parsing. 2017-08-11 05:12:18 -07:00
Christopher Jeffrey
e6cd60f919
hd: better path parsing. 2017-08-11 05:07:04 -07:00
Christopher Jeffrey
60b345f59c
util: revert to old toFixed behavior. 2017-08-11 04:52:51 -07:00
Christopher Jeffrey
1735fe6a6c
hd: refactor hardening handling. 2017-08-11 04:47:51 -07:00
Christopher Jeffrey
e03182367f
amount: allow overloading for num vs. str by default. 2017-08-11 04:36:17 -07:00
Christopher Jeffrey
1a48ba78f1
migrate: less memory usage for chaindb2to3. see #271. 2017-08-11 00:29:48 -07:00
Christopher Jeffrey
f41724046e
migrate: fix error for pruned in chaindb2to3 migration. see #272. 2017-08-11 00:13:00 -07:00
Christopher Jeffrey
e7bc53c995
test: refactor script and tx test parsing. 2017-08-11 00:07:48 -07:00
Christopher Jeffrey
6c96a8e6ba
script: lint. 2017-08-10 23:37:42 -07:00
Christopher Jeffrey
5c7c66332f
timedata: whitespace. 2017-08-10 12:32:49 -07:00
Christopher Jeffrey
7db5fd1537
memdb: fix typo. 2017-08-10 12:08:53 -07:00
Christopher Jeffrey
aee1767dd8
test: minor refactor for block-test. 2017-08-10 11:31:31 -07:00
Christopher Jeffrey
4e2af473ab
test: add better assertion methods. 2017-08-10 11:17:10 -07:00
Christopher Jeffrey
acfeede8e2
test: minor improvements for tx tests. 2017-08-10 10:01:03 -07:00
Christopher Jeffrey
5327398037
test: pull in script/tx test vectors. 2017-08-10 09:46:10 -07:00
Christopher Jeffrey
87e3ee1971
script: do not use return values for script.execute and Script.verify. 2017-08-10 09:41:01 -07:00
Christopher Jeffrey
6f96e64f70
test: enable worker pool for all tests. 2017-08-10 07:27:08 -07:00
Christopher Jeffrey
413f26584d
mnemonic: refactor parsing and serialization for phrases. 2017-08-10 06:55:01 -07:00
Christopher Jeffrey
50b8dd2b2c
mnemonic: better parsing. 2017-08-10 06:22:33 -07:00
Christopher Jeffrey
bff9e25796
mnemonic: optimize fromPhrase. 2017-08-09 18:17:25 -07:00
Christopher Jeffrey
fbd99ea1b9
util: add util.fromDouble for convenience. 2017-08-09 17:45:10 -07:00
Christopher Jeffrey
9f3a040758
mnemonic: fix an error for certain languages. 2017-08-09 17:44:06 -07:00
Christopher Jeffrey
ed4ce0f032
test: minor. 2017-08-09 17:43:21 -07:00
Christopher Jeffrey
aec9474ba7
walletdb: use passed-in worker pool. 2017-08-09 15:45:02 -07:00
Christopher Jeffrey
8f73ec53e9
refactor: use assert.strictEqual instead of assert.equal. 2017-08-09 15:40:39 -07:00
Christopher Jeffrey
8146fb28f0
test: use better asserts. 2017-08-09 15:38:33 -07:00
Christopher Jeffrey
853ef18ad9
lint: fix some linting errors. 2017-08-09 15:32:46 -07:00
Christopher Jeffrey
15adc17dea
bip150: stricter parsing for known-peers and auth-peers. 2017-08-09 15:29:06 -07:00
Christopher Jeffrey
78dfe005c7
config: use stricter arg and config file parsing. 2017-08-09 15:28:52 -07:00
Christopher Jeffrey
b892aeab2f
browser: minor. 2017-08-09 15:28:31 -07:00
Christopher Jeffrey
2cf45c84cf
test: refactor a number of tests. 2017-08-09 15:28:03 -07:00
Christopher Jeffrey
7d4d2e6c7c
scripts: fix dump script. 2017-08-09 15:26:54 -07:00
Christopher Jeffrey
a5b736b3f5
mtx: expose commit method returning a tx and view. 2017-08-09 15:26:33 -07:00
Christopher Jeffrey
bb008c50a1
bench: refactor tx bench. 2017-08-09 15:26:00 -07:00
Christopher Jeffrey
ff8b0418b1
keyring: minor. 2017-08-09 15:25:46 -07:00
Christopher Jeffrey
edebc51d18
primitives: use equals instead of equal for consistency. 2017-08-09 15:25:01 -07:00
Node
8714952119
docs: fix link for tx-from-chain 2017-08-09 16:40:08 +04:00
Node
1d9d52e0d3
docs: Move examples to docs 2017-08-09 16:39:39 +04:00
Node
1d8cfe85e0
Update example links 2017-08-09 14:17:36 +04:00
Node
d7c1210515
Update examples 2017-08-09 14:15:24 +04:00
Christopher Jeffrey
33c32d32c1
bip152: minor. add assertion. 2017-08-08 14:31:58 -07:00
Christopher Jeffrey
de9f37b290
merkleblock: minor. style. 2017-08-08 14:31:42 -07:00
Christopher Jeffrey
7de854ce3f
http: require json bodies to be an object. 2017-08-07 15:56:15 -07:00
Christopher Jeffrey
e268e00adb
chain: minor. 2017-08-07 15:31:57 -07:00
Christopher Jeffrey
58ec9b3fab
package: minor. 2017-08-07 03:17:41 -07:00
Christopher Jeffrey
b719f54448
lint: add .eslintfiles. 2017-08-07 01:27:31 -07:00
Christopher Jeffrey
36523e2f56
tx: do not track flags byte. 2017-08-07 00:55:26 -07:00
Christopher Jeffrey
3bc47f5a3c
lint: enforce function names. 2017-08-06 21:36:48 -07:00
Christopher Jeffrey
62152a1005
util: remove util.inherits. inline inheritance. 2017-08-06 19:45:10 -07:00
Christopher Jeffrey
4ce070fad4
validation: use stricter validation for ints. 2017-08-06 14:43:22 -07:00
Christopher Jeffrey
d8aea55f97
gitignore/npmignore: ignore package-lock for now. 2017-08-06 13:47:15 -07:00
Christopher Jeffrey
cc1462f697
utils/util: reorganize functions. 2017-08-06 04:00:08 -07:00
Christopher Jeffrey
422d2d4133
config: consistency changes. 2017-08-06 03:33:17 -07:00
Christopher Jeffrey
a290e6880d
encoding: rename read int methods to readIx. 2017-08-06 03:27:06 -07:00
Christopher Jeffrey
1df577cb74
validation: refactor. 2017-08-06 03:23:37 -07:00
Christopher Jeffrey
5513563892
util: minor. 2017-08-06 01:35:25 -07:00
Christopher Jeffrey
faabd36f9e
config/validator/utils: fix fixed parsing/serialization. 2017-08-05 18:52:24 -07:00
Christopher Jeffrey
2fea1319d9
cli: fix errors. 2017-08-05 14:41:28 -07:00
Christopher Jeffrey
ae1c040cd7
mempool: minor verification refactor. 2017-08-04 14:14:15 -07:00
Christopher Jeffrey
1d33816d89
config: fix and refactor arg parsing. 2017-08-03 20:17:58 -07:00
Christopher Jeffrey
d3675bfcf8
config: fix --n vs -n aliases. 2017-08-03 19:42:40 -07:00
Christopher Jeffrey
2084e26d0d
wallet/http: fix signing. 2017-08-03 19:39:15 -07:00
Christopher Jeffrey
f701af0b74
cli: fix createtx. 2017-08-03 19:38:58 -07:00
Christopher Jeffrey
cfd1715c9f
primitives: show hex on json. 2017-08-03 19:38:43 -07:00
Node
7cf63990d9
http-client: seperate address and addresses methods 2017-08-04 03:48:01 +04:00
Node
e6120039fc
http-api: Normalize API calls, fix getCoins by addr/addresses 2017-08-04 03:17:54 +04:00
Christopher Jeffrey
00e85cc7c2
cli: add --no-replay flag. 2017-08-02 17:27:02 -07:00
Christopher Jeffrey
bb6110c609
chain/pool: make checkpoints option permanent. 2017-08-02 15:23:10 -07:00
Christopher Jeffrey
1b8115d03f
test: fixes for compact block tests. 2017-08-02 15:21:15 -07:00
Christopher Jeffrey
a76442acde
chain: minor. 2017-08-02 00:19:24 -07:00
Christopher Jeffrey
a085214d54
test: refactor several tests. clean up test data. 2017-08-02 00:19:08 -07:00
Christopher Jeffrey
bec1aee604
http: fix basic auth options. 2017-08-01 16:02:49 -07:00
Christopher Jeffrey
ee7ad9dc86
chain: determine sync state using last checkpoint's chainwork. 2017-08-01 15:17:55 -07:00
Christopher Jeffrey
860e51e390
test: refactor and clean up a few tests. 2017-08-01 15:17:17 -07:00
Christopher Jeffrey
1d7b8ca7c1
http: better handling of api keys. 2017-08-01 01:38:36 -07:00
Christopher Jeffrey
1a4268544f
chain: better checkpoint handling. 2017-08-01 01:38:04 -07:00
Christopher Jeffrey
1f38f36077
wallet: fix layout style. 2017-07-31 18:59:25 -07:00
Christopher Jeffrey
f58feb0035
wallet/http: fixes for deserialization. 2017-07-31 18:54:46 -07:00
Christopher Jeffrey
c7ce985648
http: do not destroy socket on error. see #257. 2017-07-31 18:52:33 -07:00
Christopher Jeffrey
dfd63f12bb
networks: update testnet chainwork. 2017-07-31 18:21:04 -07:00
Christopher Jeffrey
6acf96457d
chaindb: fix cache invalidation. 2017-07-31 18:21:04 -07:00
Christopher Jeffrey
1fa800e9fd
networks: checkpoints and chainwork update. 2017-07-31 18:21:04 -07:00
Christopher Jeffrey
3fbe8174a4
compress: set max compress types to 6. 2017-07-31 18:21:03 -07:00
Christopher Jeffrey
57df561299
migrate: more pertxout migration optimizations. 2017-07-31 18:21:03 -07:00
Christopher Jeffrey
35068cb82b
coinentry: refactor. 2017-07-31 18:21:03 -07:00
Christopher Jeffrey
1bbe36ec1a
chaindb: minor. 2017-07-31 18:21:03 -07:00
Christopher Jeffrey
34421c1653
ip: minor. 2017-07-31 18:21:03 -07:00
Christopher Jeffrey
e38da91065
lint: no extra parens around !await. 2017-07-31 18:21:03 -07:00
Christopher Jeffrey
88ef28d837
lint: no implicit casting. 2017-07-31 18:21:03 -07:00
Christopher Jeffrey
6ba8eb9951
eslint: more style rules. 2017-07-31 18:21:03 -07:00
Christopher Jeffrey
ddda6c9dbd
dns: minor. 2017-07-31 18:21:03 -07:00
Christopher Jeffrey
749cd9323f
aes: move lookup tables. 2017-07-31 18:21:03 -07:00
Christopher Jeffrey
5eb6620431
lint: consistent return values. 2017-07-31 18:21:03 -07:00
Christopher Jeffrey
5e73e51177
lint: fix function names. 2017-07-31 18:21:03 -07:00
Christopher Jeffrey
55cf07a871
refactor: style for const/let and returns. 2017-07-31 18:21:02 -07:00
Christopher Jeffrey
6f3988e861
refactor: use const as much as possible. 2017-07-31 18:21:02 -07:00
Christopher Jeffrey
9cc5c393b4
eslint: use prefer-const. 2017-07-31 18:21:02 -07:00
Christopher Jeffrey
42fe56459e
migrate: drop next hash for sentinel hash in chaindb2to3. 2017-07-31 18:20:49 -07:00
Christopher Jeffrey
63ff27d5d6
migrate: allow in-place pruning for chaindb2to3. 2017-07-31 18:20:49 -07:00
Christopher Jeffrey
7f5649dbd8
migrate: fixes and optimizations for chaindb2to3. 2017-07-31 18:20:49 -07:00
Christopher Jeffrey
70a2f64de6
compress: minor refactor. 2017-07-31 18:20:49 -07:00
Christopher Jeffrey
723c99d15e
coins: remove useless undo method. 2017-07-31 18:20:49 -07:00
Christopher Jeffrey
8b0ec7b179
coins: refactor compression. 2017-07-31 18:20:48 -07:00
Christopher Jeffrey
d57dac13e0
coins: refactor method names. add isUnspent. 2017-07-31 18:20:48 -07:00
Christopher Jeffrey
0805babec1
coins: get rid of return value polymorphism. 2017-07-31 18:20:48 -07:00
Christopher Jeffrey
50c75aeea8
script: minor. 2017-07-31 18:20:48 -07:00
Christopher Jeffrey
ec475d6d1c
bench: sighash benchmarks. 2017-07-31 18:20:48 -07:00
Christopher Jeffrey
ca81520875
migrate: pertxout migration improvements. 2017-07-31 18:20:48 -07:00
Christopher Jeffrey
5602001348
coinview: fixes. 2017-07-31 18:20:48 -07:00
Christopher Jeffrey
a1601b8f3a
chaindb: alter hasCoins. 2017-07-31 18:20:48 -07:00
Christopher Jeffrey
82bdd73f05
chaindb: fix getCoin. 2017-07-31 18:20:48 -07:00
Christopher Jeffrey
aa71ae690a
coins: refactor prevout methods. 2017-07-31 18:20:48 -07:00
Christopher Jeffrey
492c05c378
coinview: refactor api. 2017-07-31 18:20:48 -07:00
Christopher Jeffrey
f8deb0cdfd
coinview: remove view.spend. 2017-07-31 18:20:48 -07:00
Christopher Jeffrey
5a116923c5
test: block-test. 2017-07-31 18:20:48 -07:00
Christopher Jeffrey
deede064df
minor: lint. 2017-07-31 18:20:48 -07:00
Christopher Jeffrey
fbb2500281
layout: aggressive asserts. 2017-07-31 18:20:47 -07:00
Christopher Jeffrey
b5fef64aa1
migrate: minor. 2017-07-31 18:20:47 -07:00
Christopher Jeffrey
536497a204
test: update undocoins. 2017-07-31 18:20:47 -07:00
Christopher Jeffrey
517a66309c
migrate: chaindb2to3 fixes. 2017-07-31 18:20:47 -07:00
Christopher Jeffrey
b6e6442026
migrate: refactor/improve. 2017-07-31 18:20:47 -07:00
Christopher Jeffrey
79f88b93b3
chaindb: v3. 2017-07-31 18:20:47 -07:00
Christopher Jeffrey
e7c5be451d
migrate: add pertxout migration. 2017-07-31 18:20:47 -07:00
Christopher Jeffrey
345f0c90ac
coins: refactor. 2017-07-31 18:20:47 -07:00
Christopher Jeffrey
a1af3ab980
chaindb: switch to pertxout. 2017-07-31 18:20:47 -07:00
Christopher Jeffrey
396ba5ee5f
mtx: minor. 2017-07-31 18:20:47 -07:00
Christopher Jeffrey (JJ)
17443593b2 Merge pull request #254 from nodar-chkuaselidze/docs/wallet-rpc
[WIP] Fix REST-RPC-API docs
2017-07-27 19:51:02 -07:00
Christopher Jeffrey (JJ)
c3d7be42ad Merge pull request #255 from nodar-chkuaselidze/fix/miner-workers
Worker Options in Miner
2017-07-27 19:50:38 -07:00
Node
d809f66bf8
miner: pass workers option to miner 2017-07-27 23:42:22 +04:00
Node
4438cb6bab
docs: update rest-rpc-api urls 2017-07-27 00:45:49 +04:00
Christopher Jeffrey
8036c301a1
address: fix isMixedCase. 2017-07-25 16:48:30 -07:00
Christopher Jeffrey
9a2d39c751
address: minor var name change. 2017-07-25 16:38:12 -07:00
Christopher Jeffrey
957c4e8c93
network/address: remove segnet4 support. fix bech32 parsing. 2017-07-25 16:31:27 -07:00
Christopher Jeffrey
9c87804b08
test: refactor walletdb usage. 2017-07-25 15:56:02 -07:00
Christopher Jeffrey
87d664784c
refactor: s/ts/time. s/ps/mtime. 2017-07-25 14:23:10 -07:00
Christopher Jeffrey
3f9d57f680
wallet: refactor mappings to use maps and sets. 2017-07-25 13:39:38 -07:00
Christopher Jeffrey
02e4dda012
refactor: cleanup for..of loops. 2017-07-25 11:39:12 -07:00
Christopher Jeffrey
6f1f81dcbe
refactor: lint. 2017-07-25 11:21:43 -07:00
Christopher Jeffrey
d9a726a358
walletdb: use set for querying wallets by tx. 2017-07-25 11:19:53 -07:00
Christopher Jeffrey
2d74bda89b
wallet: refactor syncOutputDepth. 2017-07-25 05:34:44 -07:00
Christopher Jeffrey
32c93af2c4
node/rpc: throw errors on shutdown. minor changes. 2017-07-25 05:30:22 -07:00
Christopher Jeffrey
7eefb773be
refactor: use maps and sets wherever possible. 2017-07-25 05:15:47 -07:00
Christopher Jeffrey
590c4350e9
rpc: fix submitwork. 2017-07-25 02:20:17 -07:00
Christopher Jeffrey
1e9855a4fa
block/tx: refactor size calculation. 2017-07-25 02:12:35 -07:00
Christopher Jeffrey
0993bbacbf
memblock: fix isMemBlock. 2017-07-25 01:57:46 -07:00
Christopher Jeffrey
cd795cf96f
block: remove addTX. 2017-07-25 01:53:58 -07:00
Christopher Jeffrey
8c212d797f
block: rename some more methods. refactor bip152 ptx vector. 2017-07-25 01:16:25 -07:00
Christopher Jeffrey
7ed36ec2ba
block: rename "abbr" methods to "head". 2017-07-25 00:08:28 -07:00
Christopher Jeffrey
23397dd753
refactor: change for..of loop usage. 2017-07-24 19:45:46 -07:00
Christopher Jeffrey
9743e8e314
bip150: use map objects. 2017-07-24 19:37:47 -07:00
Christopher Jeffrey
963c2173dd
util: improve inspection. 2017-07-24 19:05:23 -07:00
Christopher Jeffrey
340d4e3272
bip152: minor. 2017-07-23 22:17:55 -07:00
Christopher Jeffrey
6c901a19fa
bip152: add extra limit to avoid hashdos. 2017-07-23 21:22:32 -07:00
Christopher Jeffrey
69b862df42
bip152: minor refactor. 2017-07-23 20:56:27 -07:00
Christopher Jeffrey
9d90704b83
v1.0.0-beta.14 2017-07-23 08:33:37 -07:00
Christopher Jeffrey
2fa5fe6513
pkg: remove bcoin* from npmignore and gitignore. 2017-07-23 08:32:23 -07:00
Christopher Jeffrey
6d838ad91c
v1.0.0-beta.13 2017-07-23 08:24:52 -07:00
Christopher Jeffrey
906a6bf13a
http/tcp: remove reject listener on success. 2017-07-23 08:18:06 -07:00
Christopher Jeffrey
c347add2fd
pool: refactor assertion. 2017-07-23 08:17:43 -07:00
Christopher Jeffrey
342d89d103
cli: drop amount serialization for now. 2017-07-23 07:42:20 -07:00
Christopher Jeffrey
5dd18d5fa6
chain: fix unknown versionbits log. 2017-07-23 07:41:19 -07:00
Christopher Jeffrey
3a0c9b60e2
chain: implement bip91 and bip148. 2017-07-23 07:32:18 -07:00
Christopher Jeffrey
9219e23d8c
hd/wallet: add bip48 arg to prepare for bip48 support. see #238. 2017-07-23 07:22:53 -07:00
Christopher Jeffrey
75adfe5ec0
mnemonic: refactor fromPhrase. 2017-07-23 07:22:53 -07:00
Christopher Jeffrey (JJ)
63423c7748 Merge pull request #245 from nodar-chkuaselidze/fix/config-bip150
Fix Pool bip150 assert
2017-07-23 07:03:10 -07:00
Christopher Jeffrey (JJ)
296492e7f8 Merge pull request #243 from mnaamani/fix-net-listen
net/http: correctly reject promise return by listen()
2017-07-23 07:01:56 -07:00
Christopher Jeffrey (JJ)
d67d089c53 Merge pull request #247 from nodar-chkuaselidze/move-docs
Move docs
2017-07-23 06:59:59 -07:00
Christopher Jeffrey (JJ)
a56d05d6d7 Merge pull request #248 from jcsmesquita/patch-1
Update node engine requirement to >=7.6.0
2017-07-23 06:57:37 -07:00
João Mesquita
c3f6bc9a09 Update node engine requirement to >=7.6.0
Async/await support comes by default in node version 7.6.0
2017-07-21 20:12:45 +01:00
Christopher Jeffrey
ffec8ff2d7
chain: improve version display. fix getLocator. 2017-07-20 17:22:59 -07:00
Christopher Jeffrey
6a7c5eac8d
http: smarter handling of decodeURIComponent calls. 2017-07-20 17:18:18 -07:00
Christopher Jeffrey
a915545a1a
block: minor. 2017-07-20 14:28:47 -07:00
Node
2807c5e636
Update main README 2017-07-21 00:49:58 +04:00
Node
a534d7c429
Move docs from wiki 2017-07-21 00:40:02 +04:00
Christopher Jeffrey
beacd48462
timedata: refactor time.add(). 2017-07-20 13:23:38 -07:00
Node
361ffd2705 Fix bip150 and bip151 configuration parsing 2017-07-20 16:44:41 +04:00
Christopher Jeffrey
7ef658049c
block: minor. 2017-07-20 01:56:06 -07:00
Christopher Jeffrey
a11a1ab4ad
timedata: minor. 2017-07-20 01:10:22 -07:00
Christopher Jeffrey
bd56c75d0d
merkle: refactor loops. 2017-07-20 01:04:44 -07:00
Christopher Jeffrey
a4a16f6ec0
bench: add merkle bench. 2017-07-19 20:02:37 -07:00
Christopher Jeffrey
de680d62c8
deps: upgrade bcoin-native. 2017-07-19 20:00:54 -07:00
Christopher Jeffrey
f50416eaf9
merkle: minor. 2017-07-19 19:55:14 -07:00
Christopher Jeffrey
6a73f61a91
crypto: do not call out for merkle building. 2017-07-19 19:47:31 -07:00
Mokhtar Naamani
c9f736d33f net/http: correctly reject promise return by listen() 2017-07-19 00:21:35 +03:00
Christopher Jeffrey
26ade82a0b
deps: upgrade to leveldown 1.7.2. 2017-07-18 06:17:12 -07:00
Christopher Jeffrey
d57bf2cf37
deps: upgrade n64. 2017-07-18 06:15:11 -07:00
Christopher Jeffrey
98c975de8b
pool: fix bad orphan event handling. 2017-07-17 22:39:11 -07:00
Christopher Jeffrey
2fb16a6c97
crypto: expose root256 function. 2017-07-17 22:24:00 -07:00
Christopher Jeffrey
76eb6b354b
crypto/random: minor. comments. 2017-07-17 22:22:52 -07:00
Christopher Jeffrey
76679a0650
bin: fix error handling. 2017-07-17 16:40:16 -07:00
Christopher Jeffrey
615adfd3ef
examples: fix a few examples. 2017-07-17 16:36:01 -07:00
Christopher Jeffrey
ffc7a9bd6f
examples: fix miner example. 2017-07-17 16:26:47 -07:00
Christopher Jeffrey
20da155a08
sha256: minor. 2017-07-17 14:26:44 -07:00
Christopher Jeffrey
94b5487847
workers: minor. 2017-07-17 14:26:44 -07:00
Christopher Jeffrey
4eb3c2172d
workers: refactor jobs. 2017-07-17 14:26:43 -07:00
Christopher Jeffrey
18cc0a013c
node: lint. 2017-07-17 14:26:43 -07:00
Christopher Jeffrey
b52a5e3fd2
node: add node.get() for plugins. 2017-07-17 14:26:43 -07:00
Christopher Jeffrey
7530359b55
workers: minor. 2017-07-17 14:26:43 -07:00
Christopher Jeffrey
498264b417
workers: better errors for verification. 2017-07-17 14:26:43 -07:00
Christopher Jeffrey
053561f2ba
errors: fix stack traces. 2017-07-17 14:26:43 -07:00
Christopher Jeffrey
cedc54436a
lowlevelup: automatic dummies. 2017-07-17 14:26:43 -07:00
Christopher Jeffrey
37da047a34
digest: avoid extra allocations. 2017-07-17 14:26:43 -07:00
Christopher Jeffrey
2f51fd1c50
api: use satoshi values for everything. 2017-07-17 14:26:43 -07:00
Christopher Jeffrey
47adb5a5a7
tx: refactor sighashing and hasStandardWitness. 2017-07-17 14:26:43 -07:00
Christopher Jeffrey
ff856fd6c2
chain: post-verify transactions due to potential of rejected promises. 2017-07-17 14:26:42 -07:00
Christopher Jeffrey
d7970882b3
bip70: minor. 2017-07-17 14:26:42 -07:00
Christopher Jeffrey
cf795e1cd3
script: minor. 2017-07-17 14:26:42 -07:00
Christopher Jeffrey
4771f2d0a8
chaindb: minor. 2017-07-17 14:26:42 -07:00
Christopher Jeffrey
a627f00a3f
poly1305: fix. 2017-07-17 14:26:42 -07:00
Christopher Jeffrey
6893d5aa99
chain: minor. 2017-07-17 14:26:42 -07:00
Christopher Jeffrey
19f0f42717
http: minor. 2017-07-17 14:26:42 -07:00
Christopher Jeffrey
f2a939de70
poly1305: minor. 2017-07-17 14:26:42 -07:00
Christopher Jeffrey
18c1476de9
chain: refactor getLocks. 2017-07-17 14:26:42 -07:00
Christopher Jeffrey
8a1eb9f5e1
chain: minor. 2017-07-17 14:26:42 -07:00
Christopher Jeffrey
797016630c
chaindb: minor. 2017-07-17 14:26:42 -07:00
Christopher Jeffrey
0ffabd7a9a
chaindb: more cases for genesis block. 2017-07-17 14:26:42 -07:00
Christopher Jeffrey
e65f6e26c3
chain: remove isCoinbase calls. 2017-07-17 14:26:42 -07:00
Christopher Jeffrey
73e61e864a
chaindb: minor. 2017-07-17 14:26:42 -07:00
Christopher Jeffrey
278265536e
external: minor. 2017-07-17 14:26:41 -07:00
Christopher Jeffrey
15ba37099e
test: enable workers for node. 2017-07-17 14:26:41 -07:00
Christopher Jeffrey
4ab48c5f54
workers: saner env sending. 2017-07-17 14:26:41 -07:00
Christopher Jeffrey
a93f82db73
workers: minor. 2017-07-17 14:26:41 -07:00
Christopher Jeffrey
647b6909c6
dns: add custom timeout. 2017-07-17 14:26:41 -07:00
Christopher Jeffrey
7d9d3f979d
workers: minor. 2017-07-17 14:26:41 -07:00
Christopher Jeffrey
006d4d1fef
coinview: lint. 2017-07-17 14:26:41 -07:00
Christopher Jeffrey
0fa577a47d
workers: lint. 2017-07-17 14:26:41 -07:00
Christopher Jeffrey
f591e577f1
workers: minor. 2017-07-17 14:26:41 -07:00
Christopher Jeffrey
27c60ce76e
workers: refactor for browser vs node. 2017-07-17 14:26:41 -07:00
Christopher Jeffrey
8419392d44
cli: lint. 2017-07-17 14:26:41 -07:00
Christopher Jeffrey
6154ca8b4c
workers/build: require only one worker file. 2017-07-17 14:26:41 -07:00
Christopher Jeffrey
f4f5abefef
browser: add debug page. 2017-07-17 14:26:41 -07:00
Christopher Jeffrey
8451fab965
deps: switch to new uglifyjs plugin. 2017-07-17 14:26:40 -07:00
Christopher Jeffrey
b570769eed
http: safer path parsing. 2017-07-17 14:26:40 -07:00
Christopher Jeffrey
1860064da0
babel: improve perf. 2017-07-17 14:26:40 -07:00
Christopher Jeffrey
3d65488108
crypto: fix duplicate names. 2017-07-17 14:26:40 -07:00
Christopher Jeffrey
ca48ab748f
bn: use toBuffer instead of toArrayLike. 2017-07-17 14:26:40 -07:00
Christopher Jeffrey
f4685fab34
cli: minor. 2017-07-17 14:26:40 -07:00
Christopher Jeffrey
1bd42c526a
webpack: use uglify-es for node. 2017-07-17 14:26:40 -07:00
Christopher Jeffrey
8d6f8f7cdf
workers/framer: lint. 2017-07-17 14:26:40 -07:00
Christopher Jeffrey
6690bd7e9d
workers/webpack: fixes for build and workers. 2017-07-17 14:26:40 -07:00
Christopher Jeffrey
886008a182
workers: misc fixes. 2017-07-17 14:26:40 -07:00
Christopher Jeffrey
4ebe557807
workers: make worker files configurable. 2017-07-17 14:26:40 -07:00
Christopher Jeffrey
8f295a376d
workers: refactor exiting. 2017-07-17 14:26:40 -07:00
Christopher Jeffrey
0250cf4296
workers: better signal handling. 2017-07-17 14:26:40 -07:00
Christopher Jeffrey
90f783fd05
workers: remove parser-client. 2017-07-17 14:26:40 -07:00
Christopher Jeffrey
972d98e0db
hostlist: es6 fixes. 2017-07-17 14:26:39 -07:00
Christopher Jeffrey
5b62a87a21
mempool: fix coinindex. 2017-07-17 14:26:39 -07:00
Christopher Jeffrey
fdc9bca468
script: minor. 2017-07-17 14:26:39 -07:00
Christopher Jeffrey
ba94eb106d
wsproxy: minor. 2017-07-17 14:26:39 -07:00
Christopher Jeffrey
db0567fc01
node/browser: fix browser build. 2017-07-17 14:26:39 -07:00
Christopher Jeffrey
10b73f697d
webpack: minor. 2017-07-17 14:26:39 -07:00
Christopher Jeffrey
1b94d670c2
upnp: minor. 2017-07-17 14:26:39 -07:00
Christopher Jeffrey
3f3516ca18
coinview: remove old serialization methods. 2017-07-17 14:26:39 -07:00
Christopher Jeffrey
15d0b88308
bip152/merkleblock: use Map objects. 2017-07-17 14:26:39 -07:00
Christopher Jeffrey
a071a58380
config: fix parseArg. 2017-07-17 14:26:39 -07:00
Christopher Jeffrey
4f68d4cde0
node: minor. 2017-07-17 14:26:39 -07:00
Christopher Jeffrey
5e78cf4998
node: fix close bug. 2017-07-17 14:26:39 -07:00
Christopher Jeffrey
3a6fbc4d21
pkg: upgrade deps. 2017-07-17 14:26:39 -07:00
Christopher Jeffrey
296e65d0fd
refactor: use es6 template strings everywhere. 2017-07-17 14:26:39 -07:00
Christopher Jeffrey
3af014119a
refactor: switch to template strings for errors. 2017-07-17 14:26:38 -07:00
Christopher Jeffrey
7932a25abe
mtx: fix verify methods. 2017-07-17 14:26:38 -07:00
Christopher Jeffrey
c732333554
client: fix typo. 2017-07-17 14:26:38 -07:00
Christopher Jeffrey
10672784e5
refactor: rename tx functions. more es6 features. 2017-07-17 14:26:38 -07:00
Christopher Jeffrey
c651136d83
refactor: refactor clients. 2017-07-17 14:26:38 -07:00
Christopher Jeffrey
3e7c921ad3
tx: minor. 2017-07-17 14:26:38 -07:00
Christopher Jeffrey
fdb668aea3
refactor: use rest args where possible. 2017-07-17 14:26:38 -07:00
Christopher Jeffrey
e89f285e9a
script: refactor execution. 2017-07-17 14:26:38 -07:00
Christopher Jeffrey
7f1b23223c
wallet: fix server workers. 2017-07-17 14:26:38 -07:00
Christopher Jeffrey
0ea25b0c1c
wallet: move nodeclient. 2017-07-17 14:26:38 -07:00
Christopher Jeffrey
074c065262
node: automatically bind to errors for plugins. 2017-07-17 14:26:38 -07:00
Christopher Jeffrey
8c7279518f
refactor: de-globalize workerpool. 2017-07-17 14:26:38 -07:00
Christopher Jeffrey
c53f4cf89e
refactor: switch to const/let. 2017-07-17 14:26:37 -07:00
Christopher Jeffrey
e00472891d
refactor: start using for...of. 2017-07-17 14:26:37 -07:00
Christopher Jeffrey
78d62c73b8
refactor: start using multiple return values. 2017-07-17 14:26:37 -07:00
Christopher Jeffrey
aa05bb5df7
refactor: use es6 maps for everything. 2017-07-17 14:26:37 -07:00
Christopher Jeffrey (JJ)
5eb3e478da Merge pull request #235 from elopio/snapcraft
Add the packaging metadata to build the bcoin snap
2017-07-08 13:42:57 -07:00
Christopher Jeffrey
98a59e814d
workers: fix build for workers. 2017-06-28 18:26:16 -07:00
Christopher Jeffrey
307e7dd698
webpack: get bcoin building in webpack for node. 2017-06-28 18:04:20 -07:00
Leo Arias
9685a4836f Add the packaging metadata to build the bcoin snap 2017-06-28 22:10:25 +00:00
Christopher Jeffrey
275580f4ac
refactor: fix linting for empty modules. 2017-06-28 13:04:04 -07:00
Christopher Jeffrey
24cd81a1bd
webpack: use -browser convention instead of aliases. 2017-06-28 12:45:38 -07:00
Christopher Jeffrey
3763b5309a
node: allow non-string plugins in config. 2017-06-28 02:47:05 -07:00
Christopher Jeffrey
09d41d32a2
rsa: minor. 2017-06-28 02:34:26 -07:00
Christopher Jeffrey
9d9d8e2133
refactor: lint. 2017-06-28 02:32:00 -07:00
Christopher Jeffrey
f9fdcb58f8
protoreader/protowriter: minor. 2017-06-28 02:30:21 -07:00
Christopher Jeffrey
82f67fa87f
test: improve bech32 test. 2017-06-28 02:29:34 -07:00
Christopher Jeffrey
2a5a8cdc93
pbkdf2: fix for browser. 2017-06-27 18:22:19 -07:00
Christopher Jeffrey
be1ec1c22d
utils: refactor. 2017-06-27 09:28:37 -07:00
Christopher Jeffrey
62e7f97359
refactor: module index. 2017-06-27 09:28:18 -07:00
Christopher Jeffrey
d4cc22e1c5
refactor: crypto. 2017-06-27 07:27:53 -07:00
Christopher Jeffrey
63e6a97de3
refactor: lint. 2017-06-27 03:54:14 -07:00
Christopher Jeffrey
fa3e98b274
crypto: rename ec to secp256k1. 2017-06-27 02:48:19 -07:00
Christopher Jeffrey
5d6e089c92
crypto: refactor pk.js. 2017-06-27 02:34:17 -07:00
Christopher Jeffrey
f6fb3ba3b5
config: fix browser build. 2017-06-27 02:01:11 -07:00
Christopher Jeffrey
56252921c1
bcoin: refactor. 2017-06-27 01:57:34 -07:00
Christopher Jeffrey
1aa0858f7c
encoding: avoid division in write64. 2017-06-27 01:28:05 -07:00
Christopher Jeffrey
b26b82ab97
util: start using path module. remove some functions. 2017-06-27 01:24:27 -07:00
Christopher Jeffrey
8358fa59c6
util: drop all homemade polyfills. 2017-06-27 00:36:13 -07:00
Christopher Jeffrey
d9342cd81c
util: rely on polyfill for nextTick and typed arrays. 2017-06-26 23:31:32 -07:00
Christopher Jeffrey
8b2a0ce446
util: do not use util.global. 2017-06-26 23:07:06 -07:00
Christopher Jeffrey
7317076243
bcoin: remove env.js. 2017-06-26 23:02:49 -07:00
Christopher Jeffrey
65aefbd99c
httpbase: minor. 2017-06-26 21:39:59 -07:00
Christopher Jeffrey
8b74d95280
http: fix broadcast call. 2017-06-26 21:29:24 -07:00
Christopher Jeffrey
33c4ede940
pkg: update ignore files. 2017-06-26 17:55:30 -07:00
Christopher Jeffrey
32fb5e9d1b
pkg: fix level-js dep. 2017-06-26 17:49:59 -07:00
Christopher Jeffrey
7ab6818210
env: fix environment. 2017-06-26 17:45:15 -07:00
Christopher Jeffrey
19f236f740
Merge branch 'webpack'. Closes #178. 2017-06-26 17:43:50 -07:00
Christopher Jeffrey
bf5ea72863
webpack: fix babelification. upgrade to webpack3. 2017-06-26 17:42:18 -07:00
Boyma Fahnbulleh
fb2a5c8534
edit make clean 2017-06-26 13:53:53 -07:00
Boyma Fahnbulleh
c8cdb8c3e2
remove transform.js 2017-06-26 13:53:12 -07:00
Boyma Fahnbulleh
0d831b0c57
only output minimized files 2017-06-26 13:52:54 -07:00
Boyma Fahnbulleh
6048581f05
remove browserify 2017-06-26 13:52:54 -07:00
Boyma Fahnbulleh
096aaaebb2
s/PATHS/paths 2017-06-26 13:51:33 -07:00
Boyma Fahnbulleh
48d60eeaab
make package.json browser field compatible with webpack 2017-06-26 13:51:33 -07:00
Boyma Fahnbulleh
9113f03107
remove transform 2017-06-26 13:48:56 -07:00
Boyma Fahnbulleh
64f9b6b0a8
update dns browser import 2017-06-26 13:48:56 -07:00
Boyma Fahnbulleh
84bfb4f8cb
lib: fix webpack import issues 2017-06-26 13:48:40 -07:00
Christopher Jeffrey
722118df6c
external/gcs: docs. 2017-06-26 13:36:01 -07:00
Christopher Jeffrey
e02d645c07
util: optimize isUInt32 and isInt32. 2017-06-26 12:44:32 -07:00
Christopher Jeffrey
edd095bfae
pool: refactor http ip discovery. 2017-06-26 04:27:21 -07:00
Christopher Jeffrey
b65d2dcae7
peer: allong pong msg to bypass lock. 2017-06-26 04:06:55 -07:00
Christopher Jeffrey
724c9f66e7
peer: remove co.wait call. 2017-06-26 03:49:50 -07:00
Christopher Jeffrey
f1f112b6c6
bech32: minor. 2017-06-26 03:48:07 -07:00
Christopher Jeffrey
518484cac0
util: remove util.nextTick. 2017-06-26 03:43:09 -07:00
Christopher Jeffrey
03303d670d
nexttick-browser: minor. 2017-06-26 03:38:08 -07:00
Christopher Jeffrey
6875fc99c6
nexttick: minor. 2017-06-26 03:37:11 -07:00
Christopher Jeffrey
edb5bb73af
utils: refactor nexttick module. 2017-06-26 03:35:21 -07:00
Christopher Jeffrey
055e811333
pkg: update deps. 2017-06-25 12:21:32 -07:00
Christopher Jeffrey
effa1e00b8
browser: fix compilation for async/await. 2017-06-24 14:54:22 -07:00
Christopher Jeffrey
f70d6b8b45
refactor: lint tests, benchmarks, etc. 2017-06-24 14:35:10 -07:00
Christopher Jeffrey
d3b24da2e1
lint: require strict mode. 2017-06-24 05:11:54 -07:00
Christopher Jeffrey
a0bd9680fe
pkg: require node.js 7. 2017-06-24 04:48:37 -07:00
Christopher Jeffrey
2ef4d137e6
pkg: switch from jshint to eslint. 2017-06-24 04:45:46 -07:00
Christopher Jeffrey
84eccc29fa
refactor: switch to async/await. see #227. 2017-06-24 02:39:06 -07:00
Christopher Jeffrey
68a3209a96
schnorr: add hmac-drbg. refactor. 2017-06-22 05:22:06 -07:00
Christopher Jeffrey
33ffb780b3
refactor: expose int64 and big numbers as modules. 2017-06-22 03:59:49 -07:00
Christopher Jeffrey
d0482520d9
networks: remove mast for the time being. 2017-06-22 03:43:20 -07:00
Christopher Jeffrey
9238d29a28
chain: minor. 2017-06-22 02:22:15 -07:00
Christopher Jeffrey
cea12d7a3e
pkg: update deps. 2017-06-20 15:27:19 -07:00
Christopher Jeffrey
fbd7e618c7
pkg: update deps. 2017-06-18 21:31:49 -07:00
Christopher Jeffrey
7129370b2b
walletkey: fix getType in toJSON. 2017-06-17 18:49:28 -07:00
Christopher Jeffrey
3db140e119
util: improve isSafeAddition. 2017-06-17 18:39:47 -07:00
Christopher Jeffrey
be0e7e02d2
util: add isSafeAddition. 2017-06-17 18:19:12 -07:00
Christopher Jeffrey
5bf68a765f
gcs: refactor. 2017-06-17 17:41:24 -07:00
Christopher Jeffrey
fcc468fb3c
txdb: fix txid() call. 2017-06-16 23:47:04 -07:00
Christopher Jeffrey
7c1786d584
rpc: minor. 2017-06-16 23:46:53 -07:00
Christopher Jeffrey
f04ad612b2
wallet: expose witness option over http. 2017-06-16 23:46:30 -07:00
Christopher Jeffrey
041be74232
pkg: update deps. 2017-06-16 16:11:48 -07:00
Christopher Jeffrey
9058e7d78a
gcs: rename fromData. 2017-06-16 16:08:15 -07:00
Christopher Jeffrey
3324d18f5f
gcs: replace multiplication with shifts. 2017-06-16 15:11:52 -07:00
Christopher Jeffrey
b994c278f2
utils: preliminary GCS filter support. 2017-06-16 14:35:50 -07:00
Christopher Jeffrey
015fb8b0b6
siphash: return objects instead of buffers. 2017-06-16 14:30:25 -07:00
Christopher Jeffrey
5bde338a53
rpc: fix verifytxoutproof. 2017-06-16 10:27:17 -07:00
Christopher Jeffrey
6ca3a3fda6
chain: minor. 2017-06-16 00:18:59 -07:00
Christopher Jeffrey
b8c788c207
chain: getLocator refactor. 2017-06-16 00:13:29 -07:00
Christopher Jeffrey
fb8b9fac2b
chain: fix getProofTime. 2017-06-16 00:07:50 -07:00
Christopher Jeffrey
71f8b25d3c
chain: refactor getLocator. 2017-06-16 00:04:26 -07:00
Christopher Jeffrey
fb262042a3
deps: upgrade bcoin-native. 2017-06-15 23:44:56 -07:00
Christopher Jeffrey
731a56114f
pkg: add hmac-drbg dep. 2017-06-15 22:52:33 -07:00
Christopher Jeffrey (JJ)
dd16950fe2 Merge pull request #219 from jjz/master
Add tes new test file of key-address-test
2017-06-15 22:50:44 -07:00
Christopher Jeffrey
ea26a0e70a
tx: minor. 2017-06-15 22:34:56 -07:00
Christopher Jeffrey
182784c8e0
utils: remove usage of isBrowser. some refactoring. 2017-06-15 22:28:06 -07:00
Christopher Jeffrey
2b569883bf
refactor: lint. 2017-06-14 20:32:11 -07:00
Christopher Jeffrey
8593bd9410
script: less static methods. 2017-06-13 18:45:42 -07:00
Christopher Jeffrey
b722e5f6e9
ec: remove historical and high params. 2017-06-13 18:31:04 -07:00
Christopher Jeffrey
eba457ae11
script: minor. 2017-06-13 11:49:35 -07:00
Christopher Jeffrey
a3c7a49c80
refactor: replace util.equal with Buffer#equals. 2017-06-12 03:00:08 -07:00
Christopher Jeffrey
be457ee581
script: refactor branch/disabled opcodes. 2017-06-12 00:34:56 -07:00
Christopher Jeffrey
85ec9ae2c3
script: remove disabled ops permanently. 2017-06-11 23:40:35 -07:00
Christopher Jeffrey
a1e9999f29
script: refactor execution. 2017-06-11 23:37:55 -07:00
Christopher Jeffrey
3fd229d9ee
script: remove disabled opcode code. 2017-06-10 01:27:19 -07:00
Christopher Jeffrey
30b8a458ed
script: do not pass flags to Script.num. 2017-06-10 01:22:01 -07:00
Christopher Jeffrey
8893131e08
script: move static methods off of script constructor. 2017-06-10 01:20:05 -07:00
Christopher Jeffrey
49976e7d6f
crypto: better siphash addition. 2017-06-05 05:18:44 -07:00
Christopher Jeffrey
f0b43764b1
crypto: better addition for siphash. 2017-06-03 03:47:39 -07:00
Christopher Jeffrey
a4a2ba7c6f
crypto: improve siphash u64 handling. 2017-06-01 08:48:37 -07:00
Christopher Jeffrey
95ac218ef2
pkg: require node v4.5.0. 2017-05-31 06:26:26 -07:00
Christopher Jeffrey
312d0db92b
pkg: update deps. 2017-05-31 06:25:55 -07:00
Christopher Jeffrey
28cd43045d
refactor: avoid using new Buffer() due to its new perf implications. 2017-05-30 21:11:10 -07:00
Christopher Jeffrey
8763600e53
chaindb: minor. 2017-05-28 13:43:25 -07:00
jjz
46edf8c591 1. add scripts of test single file
2. add  key-address-test.js
2017-05-27 15:06:10 +08:00
jjz
ccaa0be5dc hmac-drbg is npm library , It is not in the “elliptic/lib/elliptic” 2017-05-27 11:03:41 +08:00
Christopher Jeffrey
46b34677f1
address/wallet: refactor usage of Address.getHash. 2017-05-25 23:27:37 -07:00
Christopher Jeffrey
e8fd4db0d6
network: fix isNetwork. 2017-05-25 23:26:20 -07:00
Christopher Jeffrey
76c20eddf1
rpc: do not use Address.getHash. 2017-05-21 21:42:35 -07:00
Christopher Jeffrey
7d61cda3aa
chain/mempool: more aggressive asserts. 2017-05-21 18:40:43 -07:00
Christopher Jeffrey
6b5cba635a
mempool: fix handleOrphans. 2017-05-21 14:45:53 -07:00
Christopher Jeffrey
1eaafb1a09
chain: minor refactor. 2017-05-21 09:05:35 -07:00
Christopher Jeffrey
75c279169c
peer: comments. 2017-05-19 22:05:46 -07:00
Christopher Jeffrey
7728a00470
node: fix entry cache option. 2017-05-19 21:05:07 -07:00
Christopher Jeffrey
0ceca23cb5
chain/mempool: store peer id and punish invalid orphans. 2017-05-19 17:02:06 -07:00
Christopher Jeffrey
0b13452df1
net: implement peer ids. 2017-05-15 03:53:30 -07:00
Christopher Jeffrey
028fee9eee
chain: compact db after pruning. 2017-05-15 03:42:14 -07:00
Christopher Jeffrey
d9c7d7e874
rpc: fix pruneblockchain. 2017-05-15 03:23:33 -07:00
Christopher Jeffrey
612f6a987c
rpc: better errors. 2017-05-15 03:22:09 -07:00
Christopher Jeffrey
11a90dd7da
http: minor. 2017-05-15 01:13:38 -07:00
Christopher Jeffrey
15da585b68
pkg: update deps. 2017-05-15 00:58:37 -07:00
Christopher Jeffrey
27f89186a5
lowlevelup: refactor option handling. 2017-05-15 00:47:31 -07:00
Christopher Jeffrey
f0cc8eb128
chain: rename some methods. remove unused methods. 2017-05-14 22:11:55 -07:00
Christopher Jeffrey
18cadc7803
address: minor fixes. 2017-05-14 15:45:17 -07:00
Christopher Jeffrey
4812cc8ddb
address: minor. 2017-05-14 15:33:48 -07:00
Christopher Jeffrey
df4c8cc68c
http: fix block by height. 2017-05-14 15:30:14 -07:00
Christopher Jeffrey
f0bc6d5925
rpc: implement pruneblockchain. 2017-05-14 15:24:32 -07:00
Christopher Jeffrey
7089735fb0
hd: cleanup some methods. 2017-05-13 23:39:22 -07:00
Christopher Jeffrey
11a660aeab
network: add more helper functions. 2017-05-13 21:35:58 -07:00
Christopher Jeffrey
2997333122
btc: update uri for bech32 addresses. 2017-05-13 20:54:34 -07:00
Christopher Jeffrey
5ff46dd36d
wallet: more specific hd key functions. 2017-05-13 20:04:23 -07:00
Christopher Jeffrey
7496cf8d47
networks: more network uniqueness. 2017-05-13 19:55:21 -07:00
Christopher Jeffrey
fa5f987775
address: fix bech32 hrp check. 2017-05-13 18:57:40 -07:00
Christopher Jeffrey
6c32fbd283
networks: minor. 2017-05-13 18:36:26 -07:00
Christopher Jeffrey
6643f0a308
networks: make networks more unique. 2017-05-13 18:35:58 -07:00
Christopher Jeffrey
e55ca1eb3d
address: sanity checks. 2017-05-13 17:22:32 -07:00
Christopher Jeffrey
d64bffdd17
bech32: sanity checks. 2017-05-13 16:23:32 -07:00
Christopher Jeffrey
c1dbac3a4a
bech32: optimize bits conversion. 2017-05-13 15:51:51 -07:00
Christopher Jeffrey
44f6dd9386
address: lint. 2017-05-13 15:23:20 -07:00
Christopher Jeffrey
a9ea4e5531
bech32: refactor. 2017-05-13 15:13:42 -07:00
Christopher Jeffrey
83060ee964
bech32: rewrite and improve perf. 2017-05-13 13:54:11 -07:00
Christopher Jeffrey
c1e684dc12
rpc: throw on no addresses for miner. 2017-05-13 04:22:00 -07:00
Christopher Jeffrey
b5375f576d
rpc: minor. 2017-05-13 04:10:05 -07:00
Christopher Jeffrey
c78707ed6a
rpc: update getaddednodeinfo args. 2017-05-13 03:57:59 -07:00
Christopher Jeffrey
b790dfea6d
merkleblock: remove useless method. 2017-05-13 03:52:58 -07:00
Christopher Jeffrey
e0c2eb122b
rpc: improve some network rpc calls. 2017-05-13 03:51:01 -07:00
Christopher Jeffrey
4cf82c442f
http/client: better unauth error message. 2017-05-13 02:48:15 -07:00
Christopher Jeffrey
af0ab46f21
config/validator: add some validation methods. 2017-05-13 02:39:03 -07:00
Christopher Jeffrey
677d85de1c
node: make plugin methods optional. 2017-05-13 02:01:22 -07:00
Christopher Jeffrey
5915338407
address: improve isNull. 2017-05-13 00:34:01 -07:00
Christopher Jeffrey
41d9493cc7
minor: lint. 2017-05-13 00:31:18 -07:00
Christopher Jeffrey
168012f4c5
networks: update minimum chainworks. 2017-05-13 00:29:56 -07:00
Christopher Jeffrey
0ea341772c
address: make bech32 addrs more sane. 2017-05-13 00:21:51 -07:00
Christopher Jeffrey
1eb08d39f4
package: upgrade bcoin-native. 2017-05-12 23:24:22 -07:00
Christopher Jeffrey
5e0898d920
rpc: minor. 2017-05-12 23:15:08 -07:00
Christopher Jeffrey
1ae6205e24
wallet/http: remove admin check for now. see #185. 2017-05-12 15:57:01 -07:00
Christopher Jeffrey
9080bba0e0
readme: remove reference to bitcoin core slack. 2017-05-12 15:52:18 -07:00
Christopher Jeffrey
2b970e2e40
wallet/http: treat sign call tx as an mtx. fixes #149. 2017-05-12 15:52:18 -07:00
Christopher Jeffrey
0de2cfdec9
readme: remove reference to bitcoin core slack. 2017-05-12 15:52:18 -07:00
Christopher Jeffrey
fa91d9f8a0
readme: cleanup. 2017-05-12 15:52:18 -07:00
Christopher Jeffrey
93df5e7913
template: set default commitment of zeroes. 2017-05-12 15:52:18 -07:00
Christopher Jeffrey (JJ)
a3b0d10c30 Merge pull request #169 from dionyziz/fix_promise_docs
Pool.hasTX does not return promise
2017-05-12 15:47:31 -07:00
Christopher Jeffrey (JJ)
315a7ceeef Merge pull request #175 from michaelfolkson/patch-1
Add path to bcoin command
2017-05-12 14:04:56 -07:00
Christopher Jeffrey (JJ)
724e60970a Merge pull request #183 from murtyjones/patch-1
[Trivial] Adds JSHint param name
2017-05-12 13:35:41 -07:00
Christopher Jeffrey (JJ)
d6157b525a Merge pull request #204 from BluSyn/cli-fix
CLI: Allow account option for generating addresses
2017-05-12 13:34:24 -07:00
Christopher Jeffrey (JJ)
3fda5bedab Merge pull request #198 from kleetus/compat/bool-validation
RPC method compatibility with bitcoin core.
2017-05-12 13:33:36 -07:00
Christopher Jeffrey (JJ)
405c18f080 Merge pull request #199 from homeopatchy/mempool-import-index-address-option
mempool: import indexAddress option.
2017-05-12 13:31:09 -07:00
Christopher Jeffrey (JJ)
bff9ea2c16 Merge pull request #214 from samlanning/is-float
Various improvements to float parsing
2017-05-12 13:26:26 -07:00
Christopher Jeffrey
a1d0948f2e
net: add --only option. fixes #210. 2017-05-12 12:02:55 -07:00
Christopher Jeffrey
87b5375079
db: fix error message. fixes #168. 2017-05-12 11:57:44 -07:00
Christopher Jeffrey
3ca70a152a
block: remove coinbase from json output. 2017-05-12 11:45:30 -07:00
Christopher Jeffrey
f2f94a800e
rpc: fix arg length check for getblock. 2017-05-12 11:44:33 -07:00
Christopher Jeffrey
b66f023e22
bin: add --version and --help args. fixes #209. 2017-05-12 11:44:33 -07:00
Christopher Jeffrey
993a27525e
config: expand home directory in config path. 2017-05-12 11:44:33 -07:00
Christopher Jeffrey
cecf2c7789
http: fix get block call. fixes #208. 2017-05-12 11:44:32 -07:00
Christopher Jeffrey
c81d57c25c
client: fix wallet admin calls. see #185. 2017-05-12 11:44:32 -07:00
Christopher Jeffrey (JJ)
27b896a4ed Merge pull request #211 from pinheadmz/cbtxt
return coinbase scriptSig string in getblock requests
2017-05-12 10:48:21 -07:00
Sam Lanning
7379482c32 btc: remove unneeded radix parameter for parseFloat() 2017-05-11 15:56:10 -07:00
Sam Lanning
3e06a244dd utils: Add clarification to util.isFloat() jsdoc 2017-05-11 14:38:36 -07:00
Christopher Jeffrey (JJ)
21dc8b4af0 Merge pull request #200 from thehobbit85/master
Updated packages with known security issues
2017-05-07 22:36:59 -07:00
Matthew Zipkin
6a332bfeaf init return cb rpc 2017-05-05 20:51:57 +00:00
Christopher Jeffrey
377017ba3d
walletdb: handle errors for plugin. 2017-05-03 19:29:45 -07:00
Christopher Jeffrey
52bf0d420a
workers: unref all streams. 2017-05-01 11:41:05 -07:00
Christopher Jeffrey
d3cfad0c64
spvnode: fix config inconsistency. fixes #195. 2017-04-30 07:28:16 -07:00
Christopher Jeffrey
12d3ee6f95
rpc: add getblockbyheight call. 2017-04-30 07:18:16 -07:00
Christopher Jeffrey
ed4400acb9
address: start using from/toString. 2017-04-30 07:13:36 -07:00
Christopher Jeffrey
14ee1f8f03
address: expose bech32. 2017-04-30 06:42:21 -07:00
Christopher Jeffrey
4f09065a3e
rpc: ensure shutdown. see #188. 2017-04-30 06:30:23 -07:00
Christopher Jeffrey
a5520abaae
http: fix tx/address and broadcast routes. 2017-04-30 06:07:18 -07:00
Christopher Jeffrey
c1d7e93477
networks: fix last checkpoint. 2017-04-30 06:06:39 -07:00
Steven Bower
6ad9b2cdeb
CLI: Allow account option for generating addresses 2017-04-25 17:01:19 -07:00
thehobbit85
661c8c59ff Updated socket.io and socket.io-client since the previous versions contained modules with security vulnerabilities.
Those are the vulnerabilities according to a scan using NSP (https://github.com/nodesecurity/nsp)

(+) 4 vulnerabilities found
┌───────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│               │ DoS due to excessively large websocket message                                                                                      │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Name          │ ws                                                                                                                                  │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Installed     │ 1.1.0                                                                                                                               │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Vulnerable    │ <=1.1.0                                                                                                                             │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Patched       │ >=1.1.1                                                                                                                             │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Path          │ bcoin@1.0.0-beta.12 > socket.io@1.4.8 > engine.io@1.6.11 > ws@1.1.0                                                                 │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ More Info     │ https://nodesecurity.io/advisories/120                                                                                              │
└───────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌───────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│               │ Regular Expression Denial of Service                                                                                                │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Name          │ negotiator                                                                                                                          │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Installed     │ 0.4.9                                                                                                                               │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Vulnerable    │ <= 0.6.0                                                                                                                            │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Patched       │ >= 0.6.1                                                                                                                            │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Path          │ bcoin@1.0.0-beta.12 > socket.io@1.4.8 > engine.io@1.6.11 > accepts@1.1.4 > negotiator@0.4.9                                         │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ More Info     │ https://nodesecurity.io/advisories/106                                                                                              │
└───────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌───────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│               │ DoS due to excessively large websocket message                                                                                      │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Name          │ ws                                                                                                                                  │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Installed     │ 1.0.1                                                                                                                               │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Vulnerable    │ <=1.1.0                                                                                                                             │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Patched       │ >=1.1.1                                                                                                                             │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Path          │ bcoin@1.0.0-beta.12 > socket.io@1.4.8 > socket.io-client@1.4.8 > engine.io-client@1.6.11 > ws@1.0.1                                 │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ More Info     │ https://nodesecurity.io/advisories/120                                                                                              │
└───────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
┌───────────────┬─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│               │ DoS due to excessively large websocket message                                                                                      │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Name          │ ws                                                                                                                                  │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Installed     │ 1.0.1                                                                                                                               │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Vulnerable    │ <=1.1.0                                                                                                                             │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Patched       │ >=1.1.1                                                                                                                             │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ Path          │ bcoin@1.0.0-beta.12 > socket.io-client@1.4.8 > engine.io-client@1.6.11 > ws@1.0.1                                                   │
├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ More Info     │ https://nodesecurity.io/advisories/120                                                                                              │
└───────────────┴─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
2017-04-22 21:35:11 +03:00
pablovidal85
fba9b46d25 mempool: import indexAddress option 2017-04-22 00:37:47 +02:00
Chris Kleeschulte
dd49ee0761
RPC method compatibility with bitcoin core.
- RPC method param semantics, unfortunately, aren't consistent in bitcoin core, therefore bcoin can't be used as a drop in replacement if bcoin "fixes the glitch".
- To avoid breaking bcoin's current api, validation of bool includes integers 0 and 1 as false and true, respectively.
- The effect of this is to allow getRawTransaction to work with older client code.
2017-04-21 13:14:33 -04:00
Christopher Jeffrey
6acef06cbc
address: implement bech32 addresses. 2017-04-12 23:13:29 -07:00
Christopher Jeffrey
6182df0442
config: fix mempool size and entry cache. 2017-04-12 08:23:19 -07:00
Marty Jones
3db7482e65 [Trivial] Adds JSHint param name 2017-04-10 20:05:56 -05:00
Christopher Jeffrey
a630d23a97
config: fix mb param. 2017-03-30 02:44:01 -07:00
Christopher Jeffrey
6fde0fd7d8
v1.0.0-beta.12 2017-03-26 15:18:23 -07:00
Christopher Jeffrey
0429d56534
http: fix response for wallet join (no wallet auth). 2017-03-26 15:15:29 -07:00
Christopher Jeffrey
378051c4a8
networks: fix witnesspubkeyhash for simnet. 2017-03-26 15:15:12 -07:00
Michael Folkson
769b0c56e9 Add path to bcoin command
After npm installing, running the command bcoin didn't work. It should be bin/bcoin instead
Michaels-MacBook-Pro:bcoin michaelfolkson$ pwd
/Users/michaelfolkson/bcoin
Michaels-MacBook-Pro:bcoin michaelfolkson$ bcoin
-bash: bcoin: command not found
2017-03-25 10:22:19 -07:00
Christopher Jeffrey
fd1ff3359c
v1.0.0-beta.11 2017-03-24 22:09:19 -07:00
Christopher Jeffrey
e609613519
networks: fix simnet. 2017-03-24 22:07:37 -07:00
Christopher Jeffrey
bdd1c9ee1a
examples: add tx example. 2017-03-24 18:06:59 -07:00
Christopher Jeffrey
07ba83277b
examples: client example. 2017-03-24 18:03:36 -07:00
Christopher Jeffrey
9008a90cb0
examples: more examples. 2017-03-24 16:26:34 -07:00
Christopher Jeffrey
89667c3e3e
examples: add examples. 2017-03-24 15:53:44 -07:00
Dionysis Zindros
6d274a1988 Pool.hasTX does not return promise 2017-03-18 19:20:28 +02:00
Christopher Jeffrey
db715036aa
http: fix chain resetting for client. 2017-03-17 07:13:24 -07:00
Christopher Jeffrey
e821eb10bf
rpc: minor refactor for gbt deps. 2017-03-17 04:32:41 -07:00
Christopher Jeffrey
f778a8c1b5
bip152: do not use Block.totalTX. 2017-03-16 15:46:16 -07:00
Christopher Jeffrey
8453c250dc
cpuminer: fix getHashes. 2017-03-16 14:30:49 -07:00
Christopher Jeffrey
16dbde4978
http: do not return stack trace in errors. 2017-03-16 14:20:25 -07:00
Christopher Jeffrey
1f10bf8253
rpc: move getDifficulty. 2017-03-16 14:14:57 -07:00
Christopher Jeffrey
35d9727bc3
rpc: minor. 2017-03-16 14:06:34 -07:00
Christopher Jeffrey
0a065be686
rpc: refactor some calls. 2017-03-16 13:32:11 -07:00
Christopher Jeffrey
8110c73b17
v1.0.0-beta.10 2017-03-16 00:40:45 -07:00
Christopher Jeffrey
9388256e48
hostlist: fix flushing. 2017-03-16 00:39:30 -07:00
Christopher Jeffrey
c0e4c169ba
http: more tests. 2017-03-15 20:38:04 -07:00
Christopher Jeffrey
0d844be588
rpc: tests and fixes. 2017-03-15 20:21:24 -07:00
Christopher Jeffrey
335a0b1cd1
node: do not modify globals. 2017-03-15 18:43:52 -07:00
Christopher Jeffrey
0e5c542b49
rpc: minor. 2017-03-15 18:20:29 -07:00
Christopher Jeffrey
93c190d646
node/cli: more config options. 2017-03-15 16:25:57 -07:00
Christopher Jeffrey
2e4a759487
gbt: fix deps check. do not mutate version. 2017-03-15 09:14:32 -07:00
Christopher Jeffrey
89cbdac61e
rpc: more gbt/getwork improvements. 2017-03-15 08:54:29 -07:00
Christopher Jeffrey
ff80620e5e
rpc: some more gbt fixes. 2017-03-15 07:45:23 -07:00
Christopher Jeffrey
1a3dcbd277
test: add some more rpc tests. 2017-03-15 07:21:14 -07:00
Christopher Jeffrey
b2649a6cd1
encoding: fix asserts. 2017-03-15 07:21:04 -07:00
Christopher Jeffrey
66c4fd8a77
rpc: better funding errors. 2017-03-15 06:55:00 -07:00
Christopher Jeffrey
1458366441
reader: better errors. 2017-03-15 06:49:46 -07:00
Christopher Jeffrey
3ae417795f
rpc: better error codes. 2017-03-15 06:13:27 -07:00
Christopher Jeffrey
5ee8a9b306
rpc: improve gbt proposal and capabilities handling. 2017-03-15 04:49:54 -07:00
Christopher Jeffrey
dc6b7b1f10
rpc: rename _submitBlock. 2017-03-15 04:04:22 -07:00
Christopher Jeffrey
9581225b8c
rpc: hold chain lock during submitblock. 2017-03-15 03:59:46 -07:00
Christopher Jeffrey
de50a62b00
rpc: misc fixes. 2017-03-15 03:44:45 -07:00
Christopher Jeffrey
ede25e8c9e
cpuminer: fix stop. 2017-03-14 17:40:34 -07:00
Christopher Jeffrey
010267e78e
config: minor. 2017-03-14 17:40:25 -07:00
Christopher Jeffrey
32ea933b77
logger: minor. 2017-03-14 08:23:56 -07:00
Christopher Jeffrey
203791c1f7
node: add location method. 2017-03-14 08:18:37 -07:00
Christopher Jeffrey
a4e37cf9df
browser: fixes. 2017-03-14 08:07:42 -07:00
Christopher Jeffrey (JJ)
7fc6efadff Merge pull request #145 from coinables/patch-1
formatting and url target
2017-03-14 06:51:27 -07:00
Christopher Jeffrey
51ed3262e8
amount: fix function name collision. fixes #154. 2017-03-14 06:45:12 -07:00
Christopher Jeffrey
f2c53e2e08
rpc: reimplement rpc id fix. closes #159. 2017-03-14 06:41:06 -07:00
Christopher Jeffrey
2a17362fa0
Merge remote-tracking branch 'danrobinson/authorization-header' 2017-03-14 06:33:17 -07:00
Christopher Jeffrey
42da82e007
wallet: fix tests and add compat routes. 2017-03-14 06:28:55 -07:00
Christopher Jeffrey
1d6bd6dbe4
node: require walletdb by default for now. 2017-03-14 06:22:43 -07:00
Christopher Jeffrey
74b21b78c5
config/validator: fix lists. 2017-03-14 06:16:57 -07:00
Christopher Jeffrey
544836de3d
networks: update checkpoints and chainwork. 2017-03-14 06:10:37 -07:00
Christopher Jeffrey
9ab06b8e81
logger: remove old constants. 2017-03-14 06:10:37 -07:00
Christopher Jeffrey
7d6ebd0201
node: make hostlist persistence optional. 2017-03-14 06:10:37 -07:00
Christopher Jeffrey
a986a4c6b8
minor: lint. 2017-03-14 06:10:37 -07:00
Christopher Jeffrey
e6d41d3335
logger: less colors. 2017-03-14 06:10:37 -07:00
Christopher Jeffrey
4674109706
node: refactor config options. 2017-03-14 06:10:37 -07:00
Christopher Jeffrey
b7c847059a
cli: fix cli. 2017-03-14 06:10:37 -07:00
Christopher Jeffrey
290f6ab563
rpc: implement invalidateblock correctly. 2017-03-14 06:10:37 -07:00
Christopher Jeffrey
c174bed58d
rpc: getmemoryinfo. 2017-03-14 06:10:37 -07:00
Christopher Jeffrey
f0630a830a
cli: fix sending. 2017-03-14 06:10:37 -07:00
Christopher Jeffrey
9e479483f5
minor: lint. 2017-03-14 06:10:37 -07:00
Christopher Jeffrey
68bba8621e
rpc/mempool: implement prioritisetransaction. 2017-03-14 06:10:37 -07:00
Christopher Jeffrey
6f27b3fa3d
rpc: minor. 2017-03-14 06:10:37 -07:00
Christopher Jeffrey
b9cb9c7e7d
template: lint. 2017-03-14 06:10:37 -07:00
Christopher Jeffrey
9a7b4eb6a0
validator: minor. 2017-03-14 06:10:36 -07:00
Christopher Jeffrey
6eb6800fc8
rpc: misc rpc fixes. 2017-03-14 06:10:36 -07:00
Christopher Jeffrey
f4106a615e
rpc: fix getinfo. see #165. 2017-03-14 06:10:36 -07:00
Christopher Jeffrey
ef07c52fc6
miner: use next deployment state for flags. 2017-03-14 06:10:36 -07:00
Christopher Jeffrey
5b3ca8ce6f
chain: refactor getDeployments. 2017-03-14 06:10:36 -07:00
Christopher Jeffrey
023591978a
rpc: fix wit commitment for getblocktemplate. 2017-03-14 06:10:36 -07:00
Christopher Jeffrey
a266391f1b
logger: truncate log files. 2017-03-14 06:10:36 -07:00
Christopher Jeffrey
b372715c88
miner: update curtime. see #160. 2017-03-14 06:10:36 -07:00
Christopher Jeffrey
4b212aff8e
bin: add wallet node. 2017-03-14 06:10:36 -07:00
Christopher Jeffrey
806d8c824a
fees: add logger context. 2017-03-14 06:10:36 -07:00
Christopher Jeffrey
99d2cceebe
rpc: fix nonce updating. 2017-03-14 06:10:36 -07:00
Christopher Jeffrey
5ce806a723
rpc: fix cpuminer. 2017-03-14 06:10:36 -07:00
Christopher Jeffrey
f7853aa639
logger: better context handling. 2017-03-14 06:10:36 -07:00
Christopher Jeffrey
896ffdd3f5
masterkey: fix fromKeyRaw. 2017-03-14 06:10:35 -07:00
Christopher Jeffrey
c71039d87c
minor: lint. 2017-03-14 06:10:35 -07:00
Christopher Jeffrey
eb601eece6
node: start using logger contexts. 2017-03-14 06:10:35 -07:00
Christopher Jeffrey
1401860fd4
pool: less error emission. 2017-03-14 06:10:35 -07:00
Christopher Jeffrey
81b565fc85
logger: add logger "contexts". 2017-03-14 06:10:35 -07:00
Christopher Jeffrey
b104e664a7
cpuminer: improve start/stop handling. 2017-03-14 06:10:35 -07:00
Christopher Jeffrey
aa7e550f91
hd: do not store mnemonic on hd private key. 2017-03-14 06:10:35 -07:00
Christopher Jeffrey
d7e2942117
netaddress: fix fromHost. 2017-03-14 06:10:35 -07:00
Christopher Jeffrey
ccd89e4f2f
cpuminer: fixes for job methods. 2017-03-14 06:10:35 -07:00
Christopher Jeffrey
2bd578fbe4
walletdb: minor. 2017-03-14 06:10:35 -07:00
Christopher Jeffrey
1a8a9afade
config/wallet: refactor config handling. add wallet server. 2017-03-14 06:10:35 -07:00
Christopher Jeffrey
bfd7cc9266
miner/template: refactor options handling. 2017-03-14 06:10:35 -07:00
Christopher Jeffrey
b0c2b89e79
mining: refactor proof handling. 2017-03-14 06:10:35 -07:00
Christopher Jeffrey
b453898f6e
rpc: misc fixes. 2017-03-14 06:10:35 -07:00
Christopher Jeffrey
48066f1634
http: misc fixes. 2017-03-14 06:10:34 -07:00
Christopher Jeffrey
1b098b61ba
template: minor. 2017-03-14 06:10:34 -07:00
Christopher Jeffrey
945fa381c5
refactor: mining. 2017-03-14 06:10:34 -07:00
Christopher Jeffrey
50d47dd5a6
rpc: method refactor. getwork refactor. 2017-03-14 06:10:34 -07:00
Christopher Jeffrey
78a4f379f5
rpc: add u32 validation. rename node rpc methods. 2017-03-14 06:10:34 -07:00
Christopher Jeffrey
59e9ef277a
http: make rpc more hookable. 2017-03-14 06:10:34 -07:00
Christopher Jeffrey
a47316c264
http: refactor node websocket api. 2017-03-14 06:10:34 -07:00
Christopher Jeffrey
4c7a935484
http: better channel management. 2017-03-14 06:10:34 -07:00
Christopher Jeffrey
5cbbdbfb2f
refactor: config, plugins, and walletdb. 2017-03-14 06:10:34 -07:00
Christopher Jeffrey
70a0147080
test: fix chain test. 2017-03-14 06:09:30 -07:00
Christopher Jeffrey
eedc563903
utils: add fs. 2017-03-14 06:09:29 -07:00
Christopher Jeffrey
695305cf68
mtx: add by-value sorting. 2017-03-14 06:09:29 -07:00
Christopher Jeffrey
a81733a720
node/config: refactor config and options. 2017-03-14 06:09:29 -07:00
Dan Robinson
814a77f11c http: add Authorization to allowed headers 2017-03-13 23:51:41 -07:00
Christopher Jeffrey
667b0e746d
http: fix json rpc id handling. see #159. 2017-03-12 23:44:04 -07:00
Christopher Jeffrey
604362effd
pool: increase blocktxn limit. 2017-03-07 22:43:46 -08:00
Christopher Jeffrey
75f4e9616f
pool: fix discoverSeeds. 2017-03-07 22:41:13 -08:00
Christopher Jeffrey
19525826e3
pool: better stalling for compact blocks. 2017-03-07 20:54:44 -08:00
Christopher Jeffrey
4aecaf9158
pool/peer: do not allow duplicate txs in merkle blocks. 2017-03-07 20:13:32 -08:00
Christopher Jeffrey
bfca120f4f
pool: lint. minor. 2017-03-07 20:04:26 -08:00
Christopher Jeffrey
d0628e990d
miner: add "preverify" option. 2017-03-07 20:00:33 -08:00
Christopher Jeffrey
871225bbe4
pool/peer: split request map into two maps. 2017-03-07 19:49:50 -08:00
Christopher Jeffrey
2bbeb40ac5
net: resend sync on peer disconnection. 2017-03-07 18:59:46 -08:00
Christopher Jeffrey
6a229d597e
logger: fix logger error handling. 2017-03-07 18:56:04 -08:00
Christopher Jeffrey
11a2bc1356
net: less banning for bip152. 2017-03-07 18:01:05 -08:00
Christopher Jeffrey
cdbad54a8c
net: improvements. see comments.
- Improved local address handling.
- Enabled upnp discovery.
- Added retry for dns seeds.
- Improved hostlist in general.
2017-03-07 17:10:47 -08:00
Christopher Jeffrey
614a952015
net: hardcoded seeds (primarily for browser). 2017-03-07 13:57:09 -08:00
Christopher Jeffrey
e823222e45
timedata/network: minor. 2017-03-06 18:41:23 -08:00
Christopher Jeffrey
eeeff1f795
chain: skip all preliminary verification when using checkpoints. 2017-03-06 18:24:38 -08:00
Christopher Jeffrey
6d477b7588
v1.0.0-beta.9 2017-03-05 18:39:33 -08:00
Christopher Jeffrey
e9650da89c
tx: prevent getRate from throwing. 2017-03-05 17:57:26 -08:00
Christopher Jeffrey
9e480db00f
test: fix chain test. 2017-03-05 17:57:10 -08:00
Christopher Jeffrey
a7ab25a078
policy: add some safety measures 2017-03-05 17:29:20 -08:00
Christopher Jeffrey
545eb77cdb
mempool: update serialization version. 2017-03-05 17:14:03 -08:00
Christopher Jeffrey
b53162e12d
mempool: fix getDescendants and getAncestors. 2017-03-05 16:44:46 -08:00
Christopher Jeffrey
bf4c890b88
mempool: minor. 2017-03-05 16:12:52 -08:00
Christopher Jeffrey
c38a4fc031
net: listen after connecting to outbound. 2017-03-05 15:40:09 -08:00
Christopher Jeffrey
664cddac42
asyncobject: fire hooks before events. 2017-03-05 15:23:13 -08:00
Christopher Jeffrey
3c4bee11f2
chain: add serial asynchronous "hooks". 2017-03-05 15:06:26 -08:00
Christopher Jeffrey
4d5eaaa64a
asyncemitter: add sync emission. 2017-03-05 15:06:07 -08:00
Christopher Jeffrey
a0d2cc598c
chaindb: do not use asyncobject. 2017-03-05 14:32:50 -08:00
Christopher Jeffrey
f2ab1611e4
db: rewrite lowlevelup without asyncobject. 2017-03-05 14:32:36 -08:00
Christopher Jeffrey
e52eebd652
fullnode: fix persistent mempool block addition/removal. 2017-03-05 13:01:30 -08:00
Christopher Jeffrey
c2b8dc37c7
mempool: handle trimming differently. 2017-03-05 11:43:28 -08:00
Christopher Jeffrey
47c1955e2c
mempool: rename hasTX to hasEntry. 2017-03-05 10:02:34 -08:00
Christopher Jeffrey
210ce4c767
mempool: evict by lowest fee rate. 2017-03-05 02:03:14 -08:00
Christopher Jeffrey
ef92070a28
rbt: always return node for insert. 2017-03-05 01:23:46 -08:00
Christopher Jeffrey
fce0126c13
util: refactor hrtime usage. 2017-03-05 01:23:16 -08:00
Christopher Jeffrey
a2fd9b35c6
rpc: fix besthash byte order. 2017-03-04 16:00:37 -08:00
Christopher Jeffrey
1a5263ef23
chain: minor. logging. 2017-03-04 16:00:07 -08:00
Christopher Jeffrey
a96868ff8e
pool: track peer heights. 2017-03-04 15:40:59 -08:00
Christopher Jeffrey
beefcfba67
chain: return null on orphan blocks. 2017-03-04 15:37:27 -08:00
Christopher Jeffrey
b265877b36
chain: refactor event emission and logging. 2017-03-04 15:34:16 -08:00
Christopher Jeffrey
fbf73ddabf
memorydb: rename to memdb. 2017-03-04 11:37:21 -08:00
Christopher Jeffrey
df06c91557
memorydb: more validation. 2017-03-04 11:31:46 -08:00
Christopher Jeffrey
d4f5f7cd66
rbt: refactor and move. 2017-03-03 18:11:41 -08:00
Christopher Jeffrey
694bab4ad0
net: less strict bip152 behavior. 2017-03-02 18:17:26 -08:00
Christopher Jeffrey
7b516ddd1e
net: more stall behavior. 2017-03-02 17:47:02 -08:00
Christopher Jeffrey
75877d2f22
upnp: rename resolve to discover. 2017-03-02 15:54:06 -08:00
Christopher Jeffrey
04735a1a37
upnp/ip: move some upnp functions to ip. 2017-03-02 15:50:25 -08:00
Christopher Jeffrey
b8bf8209f0
ip/netaddress: add reachability score. 2017-03-02 15:25:44 -08:00
Christopher Jeffrey
beaf9ee37e
upnp: minor. 2017-03-02 12:20:55 -08:00
Christopher Jeffrey
d09ed2442c
upnp: lint. 2017-03-02 12:18:25 -08:00
Christopher Jeffrey
c0a6952bb2
upnp: minor. 2017-03-02 12:14:04 -08:00
Christopher Jeffrey
36377d5a7f
upnp: better params for addPortMapping. 2017-03-02 12:04:09 -08:00
Christopher Jeffrey
0791bad973
upnp: do not throw when getting network interfaces. 2017-03-02 11:58:26 -08:00
Christopher Jeffrey
525e6f21b7
upnp: better timeouts. 2017-03-02 11:54:04 -08:00
Christopher Jeffrey
da5851ed51
net: add upnp support for port mappings and external ip. 2017-03-02 11:40:30 -08:00
Christopher Jeffrey
28b55339d5
http: improve request options. 2017-03-01 20:30:45 -08:00
Christopher Jeffrey
46a646aebd
mempool: refactor descendants handling. 2017-03-01 17:45:51 -08:00
Christopher Jeffrey
8977e99906
mempool: extra sanity checking for mining. 2017-03-01 15:19:55 -08:00
Christopher Jeffrey
027470e8cb
v1.0.0-beta.8 2017-03-01 15:04:25 -08:00
Christopher Jeffrey
77371fc501
mempool: fix fee estimator inject() method. 2017-03-01 15:03:05 -08:00
Christopher Jeffrey
1085ce6f27
bin: get --daemon working on OSX. 2017-03-01 13:55:51 -08:00
Christopher Jeffrey
bade290765
v1.0.0-beta.7 2017-03-01 12:26:55 -08:00
Christopher Jeffrey
53f607e19f
hostlist: minor. 2017-03-01 11:39:14 -08:00
Christopher Jeffrey
da69c5d888
hostlist: persist to file. 2017-03-01 11:29:11 -08:00
Christopher Jeffrey
ac6d7696a8
x509: lint. 2017-03-01 11:03:04 -08:00
Christopher Jeffrey
34cb226000
mempool: enable persistent fees. 2017-03-01 11:01:41 -08:00
Christopher Jeffrey
a11344db0e
mempool: refactor fee estimation. 2017-03-01 09:53:10 -08:00
Christopher Jeffrey
161fe6e2a1
net: increase timeout for getdata. see #144. 2017-03-01 09:25:26 -08:00
Christopher Jeffrey
23ca2cc65f
mempool: minor. 2017-03-01 09:23:21 -08:00
Christopher Jeffrey
e5fd8305bf
test: fix failing bip70 test. 2017-03-01 09:22:14 -08:00
Christopher Jeffrey
02f43304b4
pkg: add pkg.js. 2017-03-01 09:16:41 -08:00
Christopher Jeffrey
dae6917c00
bip70: refactor error handling. 2017-03-01 09:15:40 -08:00
Christopher Jeffrey
89ff0796c7
refactor: do not require json files. 2017-03-01 08:48:53 -08:00
Christopher Jeffrey
38cfdbf8f9
mempool: drop old getCoinView. 2017-03-01 07:26:20 -08:00
Christopher Jeffrey
3988d2766d
mempool: add double spend events. 2017-02-28 23:19:38 -08:00
Christopher Jeffrey
7a1e539700
http: refactor route handlers. 2017-02-28 22:45:47 -08:00
Christopher Jeffrey
bffc225179
chain/mempool/node: expose getSpentView. 2017-02-28 22:43:44 -08:00
Christopher Jeffrey
8cb2c4a1a0
mempool: refactor addr indexing. 2017-02-28 21:49:06 -08:00
Christopher Jeffrey
d92d6487b5
mempool: move memUsage method. 2017-02-28 20:55:50 -08:00
Christopher Jeffrey
08e56791a0
scripts: fix dump. 2017-02-28 20:53:33 -08:00
Christopher Jeffrey
653163929e
mempool: correct memusage numbers. 2017-02-28 20:48:51 -08:00
Christopher Jeffrey
92d896c729
mempool: refactor. 2017-02-28 17:21:16 -08:00
Christopher Jeffrey
3abc47c292
fullnode: minor. 2017-02-28 17:15:13 -08:00
Christopher Jeffrey
73210b3ed4
mempool: preliminary work for persistent fees. 2017-02-28 17:09:51 -08:00
Christopher Jeffrey
e7f850b4ba
fees: refactor estimator. 2017-02-28 16:57:45 -08:00
Christopher Jeffrey
42a2e61d7f
mempool: fix getDepends. 2017-02-28 15:22:35 -08:00
Christopher Jeffrey
c365ecb3ea
rpc: improve getrawtransaction. 2017-02-28 15:15:52 -08:00
Christopher Jeffrey
9f09de4867
rpc/http/wallet: more aggressive validation for addrs/keys. 2017-02-28 14:52:54 -08:00
Christopher Jeffrey
aa869e0b6a
fullnode: open http after walletdb. 2017-02-28 14:10:45 -08:00
Christopher Jeffrey
21bc517f8b
node: only add wallet addr if no others are available. 2017-02-28 14:05:46 -08:00
Christopher Jeffrey
e80c98d4e8
mempool: load descFee/descSize correctly. 2017-02-28 13:35:13 -08:00
Christopher Jeffrey
6dcbb93802
mempool: minor. 2017-02-28 13:21:53 -08:00
Christopher Jeffrey
7bfe5cfd08
mempool: return missing txs again. 2017-02-28 13:15:49 -08:00
Christopher Jeffrey
ce45b501da
mempool: lint. 2017-02-28 13:13:45 -08:00
Christopher Jeffrey
29fe6468eb
db: do not use isBrowser for bufferKeys check. see #137. 2017-02-28 13:04:55 -08:00
Christopher Jeffrey
7bd89b35c3
mempool: persist to disk. 2017-02-28 12:59:19 -08:00
Christopher Jeffrey
08936c8970
mempool: fix countDescendants (again). 2017-02-28 10:43:05 -08:00
Christopher Jeffrey
3ac91b9a77
mempoolentry: improve serialization. 2017-02-28 10:41:59 -08:00
Christopher Jeffrey
7ccea6fbb8
mempool: fix countDescendants. 2017-02-28 10:41:21 -08:00
Christopher Jeffrey
60ff33bdb2
block: minor. 2017-02-28 10:13:48 -08:00
Christopher Jeffrey
e9d87dcd98
refactor: lint. 2017-02-28 10:09:17 -08:00
Christopher Jeffrey
a4201e6bd5
peer: better stall detection. 2017-02-28 10:08:17 -08:00
Christopher Jeffrey
56ccfaa980
merkleblock/minerblock: fix hasTX calls. 2017-02-28 09:32:17 -08:00
Christopher Jeffrey
45952a4140
mempool: preliminary work for persistent mempool. 2017-02-28 09:20:23 -08:00
Christopher Jeffrey
914b66b94f
block: do not cache height parsing. 2017-02-28 09:20:23 -08:00
Christopher Jeffrey
a535d7d414
tx: fix witness item check. 2017-02-28 09:20:22 -08:00
Christopher Jeffrey
ac70656e71
chain/tx: fixes. 2017-02-28 09:20:22 -08:00
Christopher Jeffrey
33bda01d21
tx/mempool: simplify some witness policy. 2017-02-28 09:20:22 -08:00
Christopher Jeffrey
7688d80e74
block/chain: refactor block verification and caching. 2017-02-28 09:20:22 -08:00
Christopher Jeffrey
179caa2bd8
cli: add rate option. 2017-02-28 09:20:22 -08:00
Christopher Jeffrey
47c43ea39a
rpcclient: refactor error handling. 2017-02-28 09:20:22 -08:00
Christopher Jeffrey
89160bdfa8
workers: fix ecsign. 2017-02-28 09:20:22 -08:00
Christopher Jeffrey
cb5fa84042
rpc: minor fixes. 2017-02-28 09:20:22 -08:00
Christopher Jeffrey
c5e4aa0245
rpc: refactor help handling. 2017-02-28 09:20:22 -08:00
Christopher Jeffrey
39c1817043
chain: add verifyBlock method. expose on rpc. 2017-02-28 09:20:22 -08:00
Christopher Jeffrey
426ab85f15
block: remove commitment hash cache. 2017-02-28 09:20:22 -08:00
Christopher Jeffrey
f71f2d954b
chain: optimize reward calculation. 2017-02-28 09:20:22 -08:00
Christopher Jeffrey
2a69b7ab7a
pool: account for header download time before invoking stall behavior. 2017-02-28 09:13:03 -08:00
Christopher Jeffrey
5511526d98
hd: add spanish wordlist. fixes #138. 2017-02-28 05:59:11 -08:00
Christopher Jeffrey
63011a50fc
v1.0.0-beta.6 2017-02-28 05:39:22 -08:00
Christopher Jeffrey
2ee803810e
http: remove unnecessary headers. 2017-02-28 05:35:25 -08:00
Christopher Jeffrey
49bb9ed0fa
http: always parse json for compatability. fixes #146. 2017-02-28 05:30:10 -08:00
Kyle Honeycutt
e608a58926 formatting and url target
Minor formatting.
URL to the bcoin repo should be in a new tab since the user could be syncing.
2017-02-27 21:07:58 -08:00
Christopher Jeffrey
96d093fb64
v1.0.0-beta.5 2017-02-27 17:23:40 -08:00
Christopher Jeffrey
e31ddaa61a
mining: remove mod size from priority. better free calculation. 2017-02-27 16:58:44 -08:00
Christopher Jeffrey
e577228944
miner: improve rate comparison. 2017-02-27 16:33:45 -08:00
Christopher Jeffrey
321b3f5acc
package: upgrade bcoin-native and secp256k1. 2017-02-27 14:36:59 -08:00
Christopher Jeffrey
c02f19a288
miner: better block timestamp creation. 2017-02-27 09:12:56 -08:00
Christopher Jeffrey
4d6b1e652d
v1.0.0-beta.4 2017-02-27 00:34:16 -08:00
Christopher Jeffrey
369ef75840
miner: move logs. 2017-02-27 00:29:11 -08:00
Christopher Jeffrey
0120e67203
rpc: more accurate client rules handling (gbt). 2017-02-27 00:16:44 -08:00
Christopher Jeffrey
0a8228b3f4
miner: log block creation. 2017-02-26 23:06:46 -08:00
Christopher Jeffrey
2d9f96d86b
mempool: use virtual size weighted against sigops. 2017-02-26 22:50:25 -08:00
Christopher Jeffrey
769bbd1370
rpc: clean up some rpc calls. 2017-02-26 22:50:07 -08:00
Christopher Jeffrey
a68ade51bc
miner: minor. 2017-02-26 22:12:00 -08:00
Christopher Jeffrey
1dd0e366ac
mempool: fix descendant fees calculation. 2017-02-26 22:05:43 -08:00
Christopher Jeffrey
6d4a2c61cb
miner: fix priorityWeight check. 2017-02-26 21:54:49 -08:00
Christopher Jeffrey
b73b2fba85
heap: minor refactor. 2017-02-26 21:53:05 -08:00
Christopher Jeffrey
e49e877f17
rpc: do not use weight pre-segwit (see 9fc7f0b). 2017-02-26 21:20:24 -08:00
Christopher Jeffrey
70d4de39ce
miner: use a proper priority queue. 2017-02-26 12:53:41 -08:00
Christopher Jeffrey
2b6b985388
v1.0.0-beta.3 2017-02-26 06:22:14 -08:00
Christopher Jeffrey
bb5a7b00d6
http: less spam. 2017-02-26 04:27:00 -08:00
Christopher Jeffrey
ad51bf53f3
rpc: better bitcoind compat. 2017-02-26 04:21:24 -08:00
Christopher Jeffrey
3ac0d3de78
http: fix for ckpool (getblocktemplate). 2017-02-26 04:03:27 -08:00
Christopher Jeffrey
c80c242738
rpc: reverse target endianness. 2017-02-26 03:25:55 -08:00
Christopher Jeffrey
cb7af959ce
miner: compare cumulative descendant fee rate. 2017-02-26 03:09:33 -08:00
Christopher Jeffrey
dcf7e7a9f4
miner: improve policy defaults. switch rate sorting immediately. 2017-02-25 23:12:13 -08:00
Christopher Jeffrey
3ec781ee60
miner: expose max-block-weight config option. 2017-02-25 22:25:34 -08:00
Christopher Jeffrey
386ef622c0
rpc: only add wit-nonce if segwit is active (submitblock). 2017-02-25 18:22:22 -08:00
Christopher Jeffrey
4c4cf9e6a4
peer: timeout inv spamming. 2017-02-24 16:25:29 -08:00
Christopher Jeffrey
829e62b079
v1.0.0-beta.2 2017-02-23 21:17:59 -08:00
Christopher Jeffrey
fb997d43bb
pool: increase max header chain failures. 2017-02-23 20:56:21 -08:00
Christopher Jeffrey
f6cb0f1a19
v1.0.0-beta.1 2017-02-22 21:32:40 -08:00
Christopher Jeffrey
ba6c4f19e9
pkg: add changelog for releases. 2017-02-22 21:16:57 -08:00
Christopher Jeffrey
7104e4c02f
miner: use bigger reserve defaults. 2017-02-22 20:56:47 -08:00
Christopher Jeffrey
f2964e06fb
minerblock: ensure constant coinbase size. 2017-02-22 20:35:34 -08:00
Christopher Jeffrey
09c2357552
networks: increase default fee rates. 2017-02-22 11:38:37 -08:00
Christopher Jeffrey
304f0e7e75
smart coin selection. 2017-02-22 11:35:49 -08:00
Christopher Jeffrey (JJ)
cef85d7294 Merge pull request #135 from BluSyn/master
HTTP: Fix DELETE requests
2017-02-21 00:36:33 -08:00
Steven Bower
393dd5dae7 HTTP: Fix DELETE requests 2017-02-20 17:36:28 -08:00
Christopher Jeffrey
275eb917aa
chain: shave a few ms of block processing time. 2017-02-13 22:27:23 -08:00
Christopher Jeffrey
1e07d1ba83
chain: improve target and mtp calculation. 2017-02-13 21:59:41 -08:00
Christopher Jeffrey
dcf705d8bc
chain: s/bad-witness-merkle-size/bad-witness-nonce-size/ 2017-02-11 12:54:24 -08:00
Christopher Jeffrey
43c491bebe
wsproxy: fix pow check. 2017-02-10 22:05:50 -08:00
Christopher Jeffrey
b75400d583
v1.0.0-beta 2017-02-10 10:44:13 -08:00
Christopher Jeffrey
b3645a8c4f
pkg: update ignore files. 2017-02-10 10:36:27 -08:00
Christopher Jeffrey
5d2429a7b1
docs: get rid of global symbols. 2017-02-10 10:09:27 -08:00
Christopher Jeffrey
154ee36493
readme: rewrite to account for new docs. 2017-02-10 09:39:44 -08:00
Christopher Jeffrey
e8b0a9ef83
pool: fix uncatchable error. 2017-02-08 15:57:13 -08:00
Christopher Jeffrey
7cc62c0a1e
rpc: fix getpeerinfo - relaytxes. 2017-02-08 15:56:31 -08:00
Christopher Jeffrey
c12a0630aa
pool: do not request duplicate txs. 2017-02-08 14:40:55 -08:00
Christopher Jeffrey
e3c0b123a0
docs: build and expose scripterror properly. 2017-02-07 16:09:25 -08:00
Christopher Jeffrey
182b25f9ab
fullnode: document events. 2017-02-07 14:18:39 -08:00
Christopher Jeffrey
b0b7745039
fullnode: broadcast in selfish mode. 2017-02-07 14:15:33 -08:00
Christopher Jeffrey
1ec49be808
config: expose mempool max size. 2017-02-07 14:02:54 -08:00
Christopher Jeffrey
d3f94dbc6a
mempool: force broadcasting on addTX fail. 2017-02-07 13:56:30 -08:00
Christopher Jeffrey
256c449e68
ec: force secp25k1 bindings only. 2017-02-07 13:55:58 -08:00
Christopher Jeffrey
d56e50e166
script: docs for getters. 2017-02-05 18:17:49 -08:00
Christopher Jeffrey
23f7d3a782
script: minor. 2017-02-04 15:09:06 -08:00
Christopher Jeffrey
ef95b69e5e
minor: refactor. move asyncobject. 2017-02-04 14:52:13 -08:00
Christopher Jeffrey
60125003a4
ip: minor. 2017-02-04 01:16:17 -08:00
Christopher Jeffrey
1b5d361415
docs: add types. 2017-02-04 00:42:17 -08:00
Christopher Jeffrey
4e7df6ef87
docs: get jsdoc compiling again. 2017-02-03 22:47:26 -08:00
Christopher Jeffrey
b4a21cad2d
proxysocket: do not stop reads. 2017-02-03 10:25:04 -08:00
Christopher Jeffrey
91f36b3d1c
net: expose more of the tcp interface. 2017-02-03 09:59:02 -08:00
Christopher Jeffrey
f20aae676a
pool: do not reset chain when checkpoints=false. 2017-02-02 17:55:38 -08:00
Christopher Jeffrey
69b442a318
wallet: fix resend. 2017-02-02 16:54:15 -08:00
Christopher Jeffrey
9650d8adae
scrypt: move async version. 2017-02-02 11:45:11 -08:00
Christopher Jeffrey
bec4264fcf
crypto: remove async functions. 2017-02-02 11:34:35 -08:00
Christopher Jeffrey
a443b88f92
chain: cleanup some functions. 2017-02-02 11:28:25 -08:00
Christopher Jeffrey
0f1a62b0de
test: block sigops tests. 2017-02-01 23:00:54 -08:00
Christopher Jeffrey
5b1966a6c3
bip70: comments. 2017-02-01 19:56:22 -08:00
Christopher Jeffrey
91af611866
sha256: minor. 2017-02-01 18:54:10 -08:00
Christopher Jeffrey
c225f67bfc
crypto: remove subtle support. remove DSA support. 2017-02-01 17:46:54 -08:00
Christopher Jeffrey
66dfce4397
chain: avoid getDeployments in spv mode. see #128. 2017-02-01 17:15:57 -08:00
Christopher Jeffrey
87f9d58d47
crypto: fix hash160 for browser. 2017-02-01 17:04:46 -08:00
Christopher Jeffrey
096d348791
crypto: optimized sha256 for browser. 2017-02-01 16:59:40 -08:00
Christopher Jeffrey
fc2827a5bd
test: add coins test. 2017-02-01 11:56:45 -08:00
Christopher Jeffrey
db85d6db18
network: remove batchSize. 2017-02-01 11:56:06 -08:00
Christopher Jeffrey
d0e226f926
test: sigops tests. 2017-02-01 06:07:01 -08:00
Christopher Jeffrey
7d86b4bb5e
test: clean up chain test. 2017-01-31 17:08:12 -08:00
Christopher Jeffrey
74aede0447
test: lint. 2017-01-31 17:03:22 -08:00
Christopher Jeffrey
65f7b94c07
hostlist: lint. 2017-01-31 16:28:26 -08:00
Christopher Jeffrey
cc16b48cf4
test: tx sigops tests. more chain tests. 2017-01-31 16:27:39 -08:00
Christopher Jeffrey
389adee8f0
mining: change some miner apis. 2017-01-31 16:27:05 -08:00
Christopher Jeffrey
231d08b1c4
test: add node-context. 2017-01-30 19:44:50 -08:00
Christopher Jeffrey
bc951e25a9
test: use memwallet for mempool test. 2017-01-30 18:56:56 -08:00
Christopher Jeffrey
df5228c849
test: node/chain tests. add memwallet. 2017-01-30 18:37:56 -08:00
Christopher Jeffrey
95fab44015
hostlist: allow multiple refs even if full. 2017-01-30 15:47:55 -08:00
Christopher Jeffrey
9cd70fb589
hostlist: improve hash perf. 2017-01-30 15:44:29 -08:00
Christopher Jeffrey
4740a2fff3
wallet: rename noSorting to sort. see #122. 2017-01-29 17:28:12 -08:00
Christopher Jeffrey
80d47b8db4
wallet: more failsafes for sending. 2017-01-29 17:21:16 -08:00
Christopher Jeffrey
3d0254054c
peer: remove useless call. 2017-01-29 16:49:09 -08:00
Christopher Jeffrey
cc6ccfe9d9
peer: only request cmpctblock if we received sendcmpct. 2017-01-29 16:26:36 -08:00
Christopher Jeffrey
fae56d1387
pool: less log spam. 2017-01-29 16:08:59 -08:00
Christopher Jeffrey
4085321145
net: better compact block debug logs. 2017-01-29 13:19:30 -08:00
Christopher Jeffrey
5e1d8c743c
chain: add genesis check. 2017-01-28 19:29:16 -08:00
Christopher Jeffrey
0f8fd1dc77
minor: lint. 2017-01-28 19:09:12 -08:00
Christopher Jeffrey
17742434a5
logger: handle mkdir error. 2017-01-28 19:06:56 -08:00
Christopher Jeffrey
963e812bf9
chain: do not handle genesis block. 2017-01-28 19:06:15 -08:00
Christopher Jeffrey
0ec58ca93d
wallet: minor style change. 2017-01-27 18:11:23 -08:00
Christopher Jeffrey
86fdf33f8a
block: fix isBlock. 2017-01-27 18:10:51 -08:00
Christopher Jeffrey
695509b1b3
peer: fix potential memory leak. 2017-01-27 18:10:51 -08:00
Christopher Jeffrey
b7f0a1fb79
readme: mention tor support. 2017-01-27 18:10:51 -08:00
Christopher Jeffrey (JJ)
94ec846fdd Merge pull request #122 from mnaamani/bip69-optional
add option to disable bip69 in Wallet.send
2017-01-27 17:49:35 -08:00
Christopher Jeffrey
394df48408
pool: some cleanup. 2017-01-27 00:11:34 -08:00
Christopher Jeffrey
a61679c4a9
miner: 4 byte nonces. 2017-01-27 00:08:49 -08:00
Christopher Jeffrey
8e6819714b
merkleblock: improve extractTree perf. 2017-01-27 00:08:49 -08:00
Christopher Jeffrey (JJ)
594b39de66 Merge pull request #125 from mnaamani/fix-pool-graceful-disconnect
pool: graceful disconnect
2017-01-27 00:08:19 -08:00
Mokhtar Naamani
e651338ff3 pool: graceful disconnect - minor fix 2017-01-27 10:01:35 +02:00
Mokhtar Naamani
06d25a9007 pool: graceful disconnect - simpler approach 2017-01-27 09:56:58 +02:00
Mokhtar Naamani
de36d64d4a pool: graceful disconnect 2017-01-26 18:21:13 +02:00
Christopher Jeffrey
bae2aa33dd
parser: minor. 2017-01-26 03:00:14 -08:00
Christopher Jeffrey
67e6c8d768
http: add hooks. 2017-01-26 03:00:14 -08:00
Christopher Jeffrey
e52130ef29
config: fix path handling. 2017-01-26 03:00:14 -08:00
Christopher Jeffrey
977ef01d5a
txdb: failsafe for unconfirm. 2017-01-26 03:00:14 -08:00
Christopher Jeffrey
0a1c0d1890
config: refactor config parsing. 2017-01-26 03:00:13 -08:00
Christopher Jeffrey
f576ab6e6c
pool: always relay onion addresses. 2017-01-26 03:00:13 -08:00
Christopher Jeffrey
e05fb77d33
socks: more checks for tor resolve. 2017-01-26 03:00:13 -08:00
Christopher Jeffrey (JJ)
2552b3fca3 Merge pull request #123 from mnaamani/fix-pool-broadcast-item
pool: fix BroadcastItem multiple reject methods
2017-01-25 13:35:31 -08:00
Mokhtar Naamani
e1147cdf3d pool: fix BroadcastItem multiple reject methods 2017-01-25 21:20:16 +02:00
Christopher Jeffrey
64114460ad
socks: refactor addr parsing. 2017-01-25 02:31:40 -08:00
Christopher Jeffrey
00dccf0d5d
socks: minor. 2017-01-25 02:01:45 -08:00
Christopher Jeffrey
c6aad6448c
socks: error handling. 2017-01-25 01:20:58 -08:00
Christopher Jeffrey
b8cd9893fb
net: fix socket and dns callbacks. 2017-01-24 18:34:01 -08:00
Christopher Jeffrey
32fd1d6dba
dns: fix tor resolution. 2017-01-24 18:30:47 -08:00
Christopher Jeffrey
5073c1508f
net: tor support for outgoing conns. 2017-01-24 18:25:44 -08:00
Christopher Jeffrey
5288e8a619
socks: refactor errors. 2017-01-24 18:21:41 -08:00
Christopher Jeffrey
3a0b7d07d3
socks: fix no auth and proxying. 2017-01-24 06:03:27 -08:00
Christopher Jeffrey
a87484f2e8
socks: misc fixes. 2017-01-24 05:17:52 -08:00
Christopher Jeffrey
0de1302ca9
socks: fix state handling. 2017-01-24 03:58:18 -08:00
Christopher Jeffrey
6c9dd723cd
net: add socks proxy. 2017-01-24 03:52:08 -08:00
Mokhtar Naamani
38e5a0f615 add option to disable bip69 in Wallet.send 2017-01-24 10:10:25 +02:00
Christopher Jeffrey
b8324e0b09
ip: rename some functions. 2017-01-23 23:08:21 -08:00
Christopher Jeffrey
07c3177227
ip: better tor support. 2017-01-23 22:44:17 -08:00
Christopher Jeffrey
2c0f8ce226
peer: block type fix for compact blocks. 2017-01-23 21:23:01 -08:00
Christopher Jeffrey
caf8043dcb
peer: fix handleDrain. 2017-01-23 21:21:05 -08:00
Christopher Jeffrey
592191c44c
peer: less aggresive stall behavior. 2017-01-23 20:43:17 -08:00
Christopher Jeffrey
cfeafb6273
net: wait for peer drain on block serving. 2017-01-23 20:30:02 -08:00
Christopher Jeffrey
658120de6d
netaddr: fix isIPv6. 2017-01-23 19:58:06 -08:00
Christopher Jeffrey
e6dd78abe1
minor: lint. 2017-01-23 19:43:19 -08:00
Christopher Jeffrey
016d0da096
ip/netaddress: better ip parsing. 2017-01-23 19:36:19 -08:00
Christopher Jeffrey
2d49e38580
chain: coin cache. 2017-01-23 15:18:25 -08:00
Christopher Jeffrey
2a6ee729a0
pool: disable bip37 by default. 2017-01-23 15:06:20 -08:00
Christopher Jeffrey
c6b439f21c
chain/pool: remove witness option. 2017-01-23 14:51:40 -08:00
Christopher Jeffrey
1e9ebcc0d1
config: cleanup. 2017-01-23 13:44:11 -08:00
Christopher Jeffrey
c44fc3bcef
pool: disable checkpoints properly. rename prop for consistency. 2017-01-23 13:40:29 -08:00
Christopher Jeffrey
e7413aabb7
chain/pool: disable checkpoints on checkpoint failure. see #121. 2017-01-23 13:25:01 -08:00
Christopher Jeffrey
77032f758d
chain: different checkpoints handling. 2017-01-23 12:41:07 -08:00
Christopher Jeffrey
3374bffd14
invitem: rename witness flag for consistency. 2017-01-23 05:34:05 -08:00
Christopher Jeffrey
30ab5c2a88
http/pool: more options fixes. 2017-01-23 03:58:47 -08:00
Christopher Jeffrey
dc9f31f36f
pool: fix port for options. 2017-01-23 03:50:54 -08:00
Christopher Jeffrey
a52db227e3
network: fix/improve some chain params. 2017-01-23 03:42:50 -08:00
Christopher Jeffrey
cbb45db801
config: rename useCheckpoints. allow implicit noAuth on localhost. 2017-01-23 03:19:19 -08:00
Christopher Jeffrey
2fdbdfc087
network: remove witness field. 2017-01-23 03:03:38 -08:00
Christopher Jeffrey
86b7292c4a
node: enable workers by default. throw warnings if native bindings were not built. 2017-01-22 20:39:42 -08:00
Christopher Jeffrey
e32f521a43
packets: limit chain locators. 2017-01-22 20:05:07 -08:00
Christopher Jeffrey
00f24dc11e
peer: minor. change log level. 2017-01-22 19:57:37 -08:00
Christopher Jeffrey
1a2f29a360
walletdb: improve global resend. 2017-01-22 15:25:33 -08:00
Christopher Jeffrey
25899827fd
net: remove noDiscovery. exempt bip150 packets from lock. 2017-01-22 14:48:03 -08:00
Christopher Jeffrey
33fbdff127
mtx: call TX.getJSON in MTX.toJSON. see #120. 2017-01-22 14:41:11 -08:00
Christopher Jeffrey
6cca0aac1c
pool: minor fixes. 2017-01-21 17:27:15 -08:00
Christopher Jeffrey
d516035473
pool: minor. 2017-01-21 17:06:10 -08:00
Christopher Jeffrey
6e13fe57c0
pool: refactor header sync. 2017-01-21 16:59:20 -08:00
Christopher Jeffrey
219671c620
pool: do not emit tx if we have a mempool. 2017-01-21 15:38:39 -08:00
Christopher Jeffrey
51a25bf15f
net/nodeclient: always resend bloom filter. see #119. 2017-01-21 15:20:03 -08:00
Christopher Jeffrey
39b941516d
chainentry: minor. 2017-01-21 14:40:51 -08:00
Christopher Jeffrey
f3f585defc
pool: cleanup. 2017-01-21 13:59:13 -08:00
Christopher Jeffrey
b212eed282
net: handle public ip and port better. 2017-01-21 13:56:41 -08:00
Christopher Jeffrey
dc839062bf
pool: minor. 2017-01-21 13:20:44 -08:00
Christopher Jeffrey
545c0004e9
pool: minor. 2017-01-21 13:07:49 -08:00
Christopher Jeffrey
be4145e163
pool/peer: fixes. cleanup. 2017-01-21 13:03:53 -08:00
Christopher Jeffrey
58f8035add
pool: noncelist. 2017-01-21 12:57:01 -08:00
Christopher Jeffrey
f67eeee936
pool: minor. 2017-01-21 05:22:46 -08:00
Christopher Jeffrey
518a113e97
pool: fix error. 2017-01-21 05:19:53 -08:00
Christopher Jeffrey
44201193e8
pool: noncelist. 2017-01-21 05:18:18 -08:00
Christopher Jeffrey
3abfdb3770
pool: cleanup. 2017-01-21 04:15:16 -08:00
Christopher Jeffrey
9d580289ab
rpc: fix peer.hostname. 2017-01-21 04:12:39 -08:00
Christopher Jeffrey
59e73b24ca
parser: minor. 2017-01-21 03:56:30 -08:00
Christopher Jeffrey
4008caff51
peer: minor. 2017-01-21 03:49:44 -08:00
Christopher Jeffrey
26f6185097
spvnode: fix events. 2017-01-21 03:48:57 -08:00
Christopher Jeffrey
4692849593
peer: abstract all deps. 2017-01-21 03:43:26 -08:00
Christopher Jeffrey
6016d96202
pool: move sync method out of peer. 2017-01-20 22:24:45 -08:00
Christopher Jeffrey
de0a60340b
chain: add getProofTime. 2017-01-20 22:05:04 -08:00
Christopher Jeffrey
b60e0e20a4
pool: stricter standards for requests. 2017-01-20 20:51:36 -08:00
Christopher Jeffrey
7a5f4a1928
pool: fix spv. 2017-01-20 19:20:42 -08:00
Christopher Jeffrey
08b41a2dc4
peer: throw on destroyed write. 2017-01-20 17:40:06 -08:00
Christopher Jeffrey
f0f9f798c5
pool: fix inv. do not hold lock for bip151 msgs. 2017-01-20 17:23:14 -08:00
Christopher Jeffrey
cdcdb7bd52
pool: add forceInv for getdata. 2017-01-20 17:09:00 -08:00
Christopher Jeffrey
d035eb10eb
pool: getblocks fix again. 2017-01-20 17:01:51 -08:00
Christopher Jeffrey
4a45290f36
pool: fix getblocks. 2017-01-20 16:58:14 -08:00
Christopher Jeffrey
0c055ba236
pool: minor. 2017-01-20 16:49:55 -08:00
Christopher Jeffrey
170d9a1416
miner: share lock with chain. 2017-01-20 15:20:40 -08:00
Christopher Jeffrey
f8c82197a4
mempool: share lock with chain. 2017-01-20 15:14:07 -08:00
Christopher Jeffrey
3fb2150dc4
pool: allow use of headersFirst without checkpoints. 2017-01-20 15:04:13 -08:00
Christopher Jeffrey
fe52210c5e
pool: fix block logs. 2017-01-20 13:44:20 -08:00
Christopher Jeffrey
4b937de8a6
lock: remove nonsense from mutex. 2017-01-20 12:01:54 -08:00
Christopher Jeffrey
18c4a83ed3
pool: refactor and add compact block mode 1 support. 2017-01-20 09:39:58 -08:00
Christopher Jeffrey
7543049180
pool: refactor packet handling. 2017-01-19 17:31:38 -08:00
Christopher Jeffrey
2d952306e6
net: refactor packet handling. 2017-01-19 15:32:18 -08:00
Christopher Jeffrey
8cd951c994
pool: fix verify error handling. 2017-01-19 06:29:45 -08:00
Christopher Jeffrey
0a756aba34
pool: refactor logging. 2017-01-19 05:05:56 -08:00
Christopher Jeffrey
72e4ddc2b0
net: cleanup after removal. 2017-01-19 04:45:17 -08:00
Christopher Jeffrey
b6593adf75
net: remove alert system. 2017-01-19 04:41:58 -08:00
Christopher Jeffrey
e407c08668
net: drop getutxos impl. 2017-01-19 04:39:25 -08:00
Christopher Jeffrey
66ec0ae36e
net: better headers first. 2017-01-19 04:35:12 -08:00
Christopher Jeffrey
6bc016f313
wallet: fix resend. 2017-01-19 02:06:42 -08:00
Christopher Jeffrey
9c352c5d2b
net: better locks. 2017-01-19 01:18:57 -08:00
Christopher Jeffrey
05353e0e1a
peer: do not flush merkle blocks early. 2017-01-18 21:59:46 -08:00
Christopher Jeffrey
2ee6cea969
net: better dos protection for merkleblocks. 2017-01-18 21:54:35 -08:00
Christopher Jeffrey
4cba97a0a8
wallet/net: ensure low FPR of bloom filters. see #118. 2017-01-18 20:53:01 -08:00
Christopher Jeffrey
f02f5ee5d2
migrate: fix put call. 2017-01-18 17:06:05 -08:00
Christopher Jeffrey
bbbe537574
script: minor. 2017-01-18 17:06:05 -08:00
Christopher Jeffrey (JJ)
b80064320b Merge pull request #117 from bitjson/master
spvnode: fix incorrect function call.
2017-01-18 16:56:12 -08:00
Jason Dreyzehner
93e50dab3c
spvnode: fix incorrect function call. 2017-01-18 19:13:54 -05:00
Christopher Jeffrey
7f0acd5103
browser: expose wallet to rpc. 2017-01-17 18:03:34 -08:00
Christopher Jeffrey
569c18241f
txdb: fix range queries. 2017-01-17 17:10:00 -08:00
Christopher Jeffrey
cdad00944c
pool: minor. 2017-01-17 08:15:41 -08:00
Christopher Jeffrey
e738a80988
walletdb: minor. 2017-01-16 23:20:13 -08:00
Christopher Jeffrey
4254b4359e
config: smaller fast defaults. 2017-01-16 19:37:05 -08:00
Christopher Jeffrey
1e3cc80e2d
networks: update testnet slowHeight. 2017-01-16 19:31:59 -08:00
Christopher Jeffrey
8f09755533
chaindb: remove useless object. 2017-01-16 17:29:10 -08:00
Christopher Jeffrey
ca3dea3470
writer: better failsafes. optimize. 2017-01-16 17:25:42 -08:00
Christopher Jeffrey
fcc3f52f72
chaindb: cleanup. 2017-01-16 16:14:08 -08:00
Christopher Jeffrey
ac7f194c4d
wsproxy: stricter validation. 2017-01-16 15:03:45 -08:00
Christopher Jeffrey
bcde9d59a7
ip: handle ipv4-mapped ipv6 addr missing sections properly. 2017-01-16 14:42:36 -08:00
Christopher Jeffrey
3960275b0c
package: add npm test-browser. 2017-01-16 14:22:41 -08:00
Christopher Jeffrey
e15ee2308d
bip152: fix size calculation. 2017-01-16 14:09:46 -08:00
Christopher Jeffrey
48399bb0cb
logger: fix stream. 2017-01-16 14:07:56 -08:00
Christopher Jeffrey
e712b27ee9
browser: fix index.js. 2017-01-16 14:03:13 -08:00
Christopher Jeffrey
a1dcb8c381
script: do not clone for removeSeparators. 2017-01-16 13:57:14 -08:00
Christopher Jeffrey
d840144f3e
hostlist/authdb: dns resolution refactor. 2017-01-16 12:44:02 -08:00
Christopher Jeffrey
120ceef984
peer: timeout bip150 and bip151 properly. 2017-01-16 11:43:45 -08:00
Christopher Jeffrey
f2d092f23c
net: add priority nodes. 2017-01-16 04:30:10 -08:00
Christopher Jeffrey
db49f44c8a
peer: refactor version packet handling. 2017-01-16 03:33:54 -08:00
Christopher Jeffrey
212a69697e
tcp: make server promise based. 2017-01-16 01:55:10 -08:00
Christopher Jeffrey
63b39cec56
pool: dns resolution for authdb. 2017-01-16 01:31:14 -08:00
Christopher Jeffrey
ded8097a03
dns: add lookup function. 2017-01-16 01:29:38 -08:00
Christopher Jeffrey
07103da04f
chainentry: minor. 2017-01-16 01:28:01 -08:00
Christopher Jeffrey
491462f551
bip150: add dns resolution. comments. 2017-01-15 23:46:19 -08:00
Christopher Jeffrey
1e9b7363c2
bip151: cleanup handshake properly. 2017-01-15 23:43:19 -08:00
Christopher Jeffrey
9affb11b22
bip152: comments. 2017-01-15 23:42:39 -08:00
Christopher Jeffrey
60897be916
scripts: add a fuzzer. 2017-01-15 23:28:35 -08:00
Christopher Jeffrey
8b035fd9a8
opcode: do not continue reading after a bad push. 2017-01-15 22:16:57 -08:00
Christopher Jeffrey
d89678eaac
tx: assertions. 2017-01-15 18:31:37 -08:00
Christopher Jeffrey
afb15787ad
peer: better error messages. 2017-01-15 18:03:31 -08:00
Christopher Jeffrey
fe0ea9ac76
pool: minor. 2017-01-15 17:57:17 -08:00
Christopher Jeffrey
5ee83e9114
tx: some misc cleanup. 2017-01-15 17:52:42 -08:00
Christopher Jeffrey
94460ba592
mtx: fix mtx.fromJSON. 2017-01-15 17:10:24 -08:00
Christopher Jeffrey
15579a6b21
outpoint: minor. 2017-01-15 16:26:25 -08:00
Christopher Jeffrey
858081626f
logger: fix error handling. 2017-01-15 15:18:02 -08:00
Christopher Jeffrey
a53b2c0eef
primitives: cloning and assertions. 2017-01-15 15:17:33 -08:00
Christopher Jeffrey
58da4be8fa
primitives: more aggressive asserting. 2017-01-15 13:18:35 -08:00
Christopher Jeffrey
6d1c918793
hostlist: refactor seed handling. 2017-01-15 13:03:57 -08:00
Christopher Jeffrey
fcae101c0f
bip151: extra assertions. refactor. 2017-01-14 23:19:46 -08:00
Christopher Jeffrey
c0031e062a
peer: minor. 2017-01-14 19:46:18 -08:00
Christopher Jeffrey
199699d73a
node: better option handling. 2017-01-14 19:35:59 -08:00
Christopher Jeffrey
a486bd3a18
refactor: options. 2017-01-14 17:59:54 -08:00
Christopher Jeffrey
9dbfaf3127
pool: rename ignoreDiscovery. 2017-01-14 09:11:07 -08:00
Christopher Jeffrey
f0e7aa9d82
net: handle server differently. 2017-01-14 07:54:07 -08:00
Christopher Jeffrey
e8cc724488
node/net: refactor node bootstrapping. 2017-01-14 07:21:16 -08:00
Christopher Jeffrey
80d01b52c3
net: avoid 0-len getdatas for blocks. 2017-01-14 06:53:51 -08:00
Christopher Jeffrey
07414f5fd3
chain: remove chain.byTime. 2017-01-14 06:44:00 -08:00
Christopher Jeffrey
fd2f158169
net: avoid requesting duplicate blocks. avoid reconnecting to banned peers. 2017-01-14 06:43:49 -08:00
Christopher Jeffrey
c3c3e41e68
script: typo. 2017-01-14 06:42:48 -08:00
Christopher Jeffrey
e51062d249
http: minor params. 2017-01-13 18:50:52 -08:00
Christopher Jeffrey
699e71d84a
net: send peer addr in version msg. 2017-01-13 16:45:05 -08:00
Christopher Jeffrey
0f4348af6d
miner: wrap nonces correctly. 2017-01-13 16:44:46 -08:00
Christopher Jeffrey
b77b814be4
bip152: fix empty block filling. 2017-01-13 15:27:13 -08:00
Christopher Jeffrey
daaa1c5fa5
address: fix types by val. 2017-01-13 15:11:42 -08:00
Christopher Jeffrey
46e53abe9c
gbt: fix target endianness. 2017-01-13 15:11:35 -08:00
Christopher Jeffrey
166fe0ad6e
chain: remove bestHeight tracking. 2017-01-13 12:50:50 -08:00
Christopher Jeffrey
89538c1fb4
migrate: fix chaindb1to2. 2017-01-12 16:38:48 -08:00
Christopher Jeffrey
79eea76cc4
output: remove output mutability and addr caching. 2017-01-12 16:13:32 -08:00
Christopher Jeffrey
a8a752a212
bench: fix walletdb benchmarks. 2017-01-12 16:05:06 -08:00
Christopher Jeffrey
34dd6c3b79
http: url fixes. 2017-01-12 13:04:10 -08:00
Christopher Jeffrey
002718206a
rpc: some refactoring. 2017-01-12 12:41:33 -08:00
Christopher Jeffrey
7396e08f16
config: minor. 2017-01-12 12:41:23 -08:00
Christopher Jeffrey
e36f78f6bf
coin: add rhash method. 2017-01-12 12:41:04 -08:00
Christopher Jeffrey
f3a393668e
map: remove __proto__ check. 2017-01-12 12:40:50 -08:00
Christopher Jeffrey
9e0b10f314
http: path parsing. 2017-01-12 12:40:31 -08:00
Christopher Jeffrey
72f6a1d239
mtx: allow base58 addrs in outputs. 2017-01-12 03:28:03 -08:00
Christopher Jeffrey
fed7d0de54
http: remove use of callbacks. 2017-01-12 02:57:24 -08:00
Christopher Jeffrey
c28589d0e6
http-base: remove useless asserts and loops. 2017-01-11 23:40:07 -08:00
Christopher Jeffrey
0b296a1a6f
masterkey: refactor. 2017-01-11 23:39:33 -08:00
Christopher Jeffrey
398900dcdc
package: cleanup package. 2017-01-11 23:39:23 -08:00
Christopher Jeffrey
38a30aceed
masterkey: remove useless arg for lock. 2017-01-11 21:47:09 -08:00
Christopher Jeffrey
085866d1ac
lock: fix closure calls. 2017-01-11 21:30:08 -08:00
Christopher Jeffrey
9de61172a4
refactor: use Object.create(null) for all user input keys. 2017-01-11 21:27:55 -08:00
Christopher Jeffrey
7c021cf842
utils: rename locker to lock for consistency. 2017-01-11 21:20:26 -08:00
Christopher Jeffrey
76ff5f814f
chainentry: no network pointer. 2017-01-11 19:43:57 -08:00
Christopher Jeffrey
ef4ab275da
http: minor. 2017-01-11 19:23:03 -08:00
Christopher Jeffrey
e82950a6e8
uri: allow empty keys. 2017-01-11 19:08:08 -08:00
Christopher Jeffrey
6e7a19ef35
uri: remove old options. 2017-01-11 19:02:12 -08:00
Christopher Jeffrey
f192dab0a6
minor: lint. 2017-01-11 18:55:27 -08:00
Christopher Jeffrey
1cda7cb702
http: make http base server safer. 2017-01-11 18:42:08 -08:00
Christopher Jeffrey
428e2a1301
uri: remove bip20 parsing. 2017-01-11 18:19:28 -08:00
Christopher Jeffrey
40ff06f11f
bloom: ensure min values. 2017-01-11 15:38:24 -08:00
Christopher Jeffrey
8c1002e1da
path: lint. 2017-01-11 14:56:59 -08:00
Christopher Jeffrey
4da1e0b4e0
bloom: do not allow passed in buffer. 2017-01-11 14:56:46 -08:00
Christopher Jeffrey
9efece17d1
bloom: more fixes. 2017-01-11 14:28:09 -08:00
Christopher Jeffrey
65ab296d2e
bloom: cleanup instantiation. 2017-01-11 12:10:04 -08:00
Christopher Jeffrey
dbaae30700
net: only add timeouts for outbound peers. 2017-01-10 18:03:19 -08:00
Christopher Jeffrey
a6c1e8c339
chain: minor. 2017-01-10 18:01:29 -08:00
Christopher Jeffrey
eabbfbf98b
net: fix getdata bug. 2017-01-10 16:12:42 -08:00
Christopher Jeffrey
c605638daf
pool: some request refactoring. 2017-01-10 16:10:55 -08:00
Christopher Jeffrey
d338f62078
protocol: constants changes. 2017-01-10 04:57:41 -08:00
Christopher Jeffrey
e718caa1ff
tx: extra assertion. 2017-01-10 00:07:18 -08:00
Christopher Jeffrey
fb53992bf6
address: fix witnessscripthash. 2017-01-09 23:25:35 -08:00
Christopher Jeffrey
6e298c445a
coins: minor. 2017-01-09 23:24:38 -08:00
Christopher Jeffrey
4c557744a2
refactor: address, amount, uri, errors. 2017-01-09 23:07:02 -08:00
Christopher Jeffrey
84fce9aad4
minor: some comments. 2017-01-09 15:20:56 -08:00
Christopher Jeffrey
6cd9e4d687
workers: refactor. 2017-01-09 14:59:35 -08:00
Christopher Jeffrey
9e4ea75198
test: cleanup. 2017-01-09 14:25:45 -08:00
Christopher Jeffrey
2145cadc10
mtx/script: minor. optimize script.fromProgram. 2017-01-09 13:26:18 -08:00
Christopher Jeffrey
29e03892e7
script: some refactoring. 2017-01-09 00:03:59 -08:00
Christopher Jeffrey
f58e748263
network: add minimum chainworks. 2017-01-08 23:10:19 -08:00
Christopher Jeffrey
59db7a5498
network: minor. 2017-01-08 22:43:30 -08:00
Christopher Jeffrey
129be729de
network: remove alexykot.me dns seed. 2017-01-08 22:41:24 -08:00
Christopher Jeffrey
cd4a0cc964
network: remove segnet3 support. 2017-01-08 22:38:41 -08:00
Christopher Jeffrey
c7ce8c778b
peer: some comments. do not kill on late pong. 2017-01-08 22:29:57 -08:00
Christopher Jeffrey
469da05515
txdb: remove useless props. 2017-01-08 21:57:06 -08:00
Christopher Jeffrey
a25610857e
mtx: lint. 2017-01-08 21:55:27 -08:00
Christopher Jeffrey
ee4e918024
mtx/tests: more refactoring. 2017-01-08 21:49:54 -08:00
Christopher Jeffrey
95c205b309
mtx: less overloading. 2017-01-08 02:44:55 -08:00
Christopher Jeffrey
8987c0d870
wallet/mtx: fix fee checking and refactor some mtx functions. 2017-01-08 01:36:01 -08:00
Christopher Jeffrey
fa8ec48bc5
co/utils: remove some functions and refactor. 2017-01-08 01:35:05 -08:00
Christopher Jeffrey
0a15ebefab
readme: fix examples. add irc/slack. 2017-01-07 22:43:08 -08:00
Christopher Jeffrey
a4602a22cb
tx: refactor address getting. 2017-01-07 22:42:57 -08:00
Christopher Jeffrey
0eef277984
mtx: coin selector refactor. 2017-01-07 15:39:18 -08:00
Christopher Jeffrey
fb0b2b53d7
net: use Map object for requested items. 2017-01-07 00:19:40 -08:00
Christopher Jeffrey
bea77b0ec7
mtx: refactor coin selection. 2017-01-07 00:18:45 -08:00
Christopher Jeffrey
3b45648750
mtx: fix bip69 impl. 2017-01-06 23:59:58 -08:00
Christopher Jeffrey
9e5989eba5
minor: lint. 2017-01-06 21:21:37 -08:00
Christopher Jeffrey
d396cdd0fd
constants: minor. 2017-01-06 21:14:11 -08:00
Christopher Jeffrey
3236c367b1
tx: refactor locktimes. 2017-01-06 11:09:52 -08:00
Christopher Jeffrey
122b4a9fb3
tx: refactor. 2017-01-06 10:52:22 -08:00
Christopher Jeffrey
74c177d623
refactor: more fixes. 2017-01-06 10:40:16 -08:00
Christopher Jeffrey
0c194f1d3f
policy: refactor. 2017-01-06 10:35:51 -08:00
Christopher Jeffrey
5d5bcee9fa
refactor: cleanup. 2017-01-06 10:24:39 -08:00
Christopher Jeffrey
75430cae8b
refactor: more moving. 2017-01-06 10:18:21 -08:00
Christopher Jeffrey
69d0320faa
refactor: indexes. 2017-01-06 09:58:47 -08:00
Christopher Jeffrey
5caf6210b9
refactor: move constants around. 2017-01-06 09:57:55 -08:00
Christopher Jeffrey
d1a4e53896
bloom/net: move bloom constants. net services, move inv types. 2017-01-06 01:57:49 -08:00
Christopher Jeffrey
3da4542ecb
pool: remove failsafe. 2017-01-05 19:25:34 -08:00
Christopher Jeffrey
b3ccd8a105
pool: fix handle headers. 2017-01-05 14:37:37 -08:00
Christopher Jeffrey
758a62b386
networks: remove sipa's seed. 2017-01-05 14:35:29 -08:00
Christopher Jeffrey
8ca683f4f3
peer: add inv queue. 2017-01-05 14:35:29 -08:00
Christopher Jeffrey
84f7b0196d
test: fix version packet test. 2017-01-05 14:35:29 -08:00
Christopher Jeffrey
80a1b95529
utils: map changes. 2017-01-05 14:35:29 -08:00
Christopher Jeffrey
5fb64e7bac
pool: refactor reject handling. 2017-01-05 14:35:29 -08:00
Christopher Jeffrey
94d4e80373
co: stop using co.wrap. 2017-01-05 14:35:29 -08:00
Christopher Jeffrey
cca763ca95
peer: avoid compactblock dos. 2017-01-05 14:35:28 -08:00
Christopher Jeffrey
5dc0202d56
utils: add map. 2017-01-05 14:35:28 -08:00
Christopher Jeffrey
cd8e464079
net: redesign stall behavior and block management. 2017-01-05 14:35:28 -08:00
Christopher Jeffrey
eb12b0e608
net: misc. 2017-01-05 14:35:28 -08:00
Christopher Jeffrey (JJ)
19c44a9779 Merge pull request #111 from mnaamani/hotfix-netaddress
netaddress: fix fromHost to include BLOOM service
2017-01-03 14:58:46 -08:00
Christopher Jeffrey (JJ)
f04206e671 Merge pull request #112 from mnaamani/hotfix-bloom-fromrate
bloom: fix minimum value of n
2017-01-03 14:37:54 -08:00
Mokhtar Naamani
f5a00c6e6b bloom: fix minimum value of n 2017-01-03 17:37:15 +02:00
Mokhtar Naamani
bbafbbb98c netaddress: fix fromHost to include BLOOM service 2017-01-02 17:18:17 +02:00
Christopher Jeffrey
f8fa536129
pool: fix startSync. 2016-12-31 03:21:36 -08:00
Christopher Jeffrey
933d80bb37
util: fix mkdirp error on windows. 2016-12-30 00:13:19 -08:00
Christopher Jeffrey
b5ff10e74f
tx: minor. 2016-12-30 00:05:50 -08:00
Christopher Jeffrey
da7640cd27
peer: minor. 2016-12-29 15:35:03 -08:00
Christopher Jeffrey
943c5d2d12
net: treat services as a u32. 2016-12-27 15:28:19 -08:00
Christopher Jeffrey
dd6bd8db4a
net: move hostlist. 2016-12-27 14:38:32 -08:00
Christopher Jeffrey
74dbff2377
net: add addrman serialization. 2016-12-27 14:29:46 -08:00
Christopher Jeffrey
d26204479a
ip: fix ipv4 map check. 2016-12-27 12:32:39 -08:00
Christopher Jeffrey
1d4fbc1833
mempool: minor. 2016-12-26 13:55:21 -08:00
Christopher Jeffrey
3ada25564e
chain: refactor orphan list. 2016-12-24 22:32:45 -08:00
Christopher Jeffrey
f3bd64689d
peer: minor. 2016-12-24 13:10:14 -08:00
Christopher Jeffrey
e36adec092
request: silence errors after cleanup. 2016-12-23 11:27:18 -08:00
Christopher Jeffrey
6ea846ee9a
pool: minor. 2016-12-22 22:27:09 -08:00
Christopher Jeffrey
5a0632f449
pool: schedule txs like blocks. 2016-12-22 13:26:04 -08:00
Christopher Jeffrey
8b8a65868b
peer: fix getutxos handler. 2016-12-22 05:16:04 -08:00
Christopher Jeffrey
648ad0227b
walletdb: comments. 2016-12-22 04:01:59 -08:00
Christopher Jeffrey
4f8e401dbc
peer: cleanup events after connect timeout. 2016-12-22 04:01:49 -08:00
Christopher Jeffrey
bb11cfc021
spvnode: do not attempt to insert wdb txs twice. 2016-12-22 03:55:04 -08:00
Christopher Jeffrey
0eaa26a374
pool: minor. 2016-12-21 16:17:23 -08:00
Christopher Jeffrey
c10f689435
net: fix hosts.toArray (again). 2016-12-21 16:04:48 -08:00
Christopher Jeffrey
8ce823e31c
pool: minor. 2016-12-21 15:53:59 -08:00
Christopher Jeffrey
35fba9f3ae
pool: fix hostlist.toArray. 2016-12-21 15:49:46 -08:00
Christopher Jeffrey
1a4984d533
net: add hasServices method. 2016-12-21 15:31:55 -08:00
Christopher Jeffrey
14f2851929
pool: add ban and unban calls once again. 2016-12-21 15:13:01 -08:00
Christopher Jeffrey
cc4dd23c83
pool: fix potential infinite loop with addrman. 2016-12-21 15:05:41 -08:00
Christopher Jeffrey
bb1bf9f138
http: fix info call. 2016-12-21 14:49:26 -08:00
Christopher Jeffrey
583e479a80
locker: fix destroy handling. 2016-12-21 14:49:18 -08:00
Christopher Jeffrey
24e6ed7a26
net: rewrite hostlist. bitcoind-style management. 2016-12-21 13:18:03 -08:00
Christopher Jeffrey
25101f1784
net: refactor host and peer list. 2016-12-20 15:45:12 -08:00
Christopher Jeffrey
127a52aaf1
refactor: rename network address. 2016-12-20 12:47:19 -08:00
Christopher Jeffrey
3baaeadd14
tx: comments and addr fixes. 2016-12-20 00:40:49 -08:00
Christopher Jeffrey
fa167d9a8c
config: querystring parsing. 2016-12-19 17:27:58 -08:00
Christopher Jeffrey
0d5811719c
config: add network alias. 2016-12-19 17:00:29 -08:00
Christopher Jeffrey
bd4bfa142f
pool: refactor dns discovery. 2016-12-19 16:58:02 -08:00
Christopher Jeffrey
cc2d49ea10
request: refactor mime types. 2016-12-19 16:50:32 -08:00
Christopher Jeffrey
5375f8bf19
mempool: refactor orphan handling. 2016-12-19 16:47:29 -08:00
Christopher Jeffrey
b9d6e7e40d
request: more content types. 2016-12-19 15:06:44 -08:00
Christopher Jeffrey
37f8d45c25
server: add get wallets call. 2016-12-19 08:04:30 -08:00
Christopher Jeffrey
b38d859382
pool: refactor dns discovery. 2016-12-19 07:32:42 -08:00
Christopher Jeffrey
aa07255d74
request: make pool an explicit option. 2016-12-19 07:29:43 -08:00
Christopher Jeffrey
22c5014c49
request: fix socket hangup. 2016-12-19 07:21:40 -08:00
Christopher Jeffrey
291c7f72fe
pool: rediscover seeds when no hosts are available. 2016-12-19 07:11:09 -08:00
Christopher Jeffrey
10e9ab9322
ip: more parsing safety. 2016-12-19 06:31:48 -08:00
Christopher Jeffrey
37128240b3
ip: improve parsing. 2016-12-19 06:13:42 -08:00
Christopher Jeffrey
3e3e4c84ba
network/pool: improve dns discovery. 2016-12-19 05:20:47 -08:00
Christopher Jeffrey
9490d29390
mempool: do not hold chain lock while getting viewpoint. 2016-12-19 05:11:54 -08:00
Christopher Jeffrey
9fd7153100
netaddress: minor. 2016-12-19 04:19:16 -08:00
Christopher Jeffrey
546fccfca8
ip: speed up ipv6 parsing. 2016-12-19 04:08:35 -08:00
Christopher Jeffrey
6617bd7d49
peer: lint. 2016-12-19 04:01:02 -08:00
Christopher Jeffrey
6d2659a31c
locker: revert to old drain behavior. 2016-12-19 03:58:34 -08:00
Christopher Jeffrey
8ac673d36e
ip: less strict parsing. 2016-12-19 03:23:47 -08:00
Christopher Jeffrey
b51554d765
utils: rewrite ip module. 2016-12-19 03:10:54 -08:00
Christopher Jeffrey
1836d8b314
ip: fix parseHost for ipv6. 2016-12-19 00:43:42 -08:00
Christopher Jeffrey
9d8f95ee0f
walletdb: less load for browser. 2016-12-18 23:06:44 -08:00
Christopher Jeffrey
1df11caf71
peer: lock fixes. dos fixes. 2016-12-18 22:14:50 -08:00
Christopher Jeffrey
3732260350
util: refactor locker. 2016-12-18 21:19:35 -08:00
Christopher Jeffrey
37a3f83334
keyring: add refresh method. 2016-12-18 20:41:30 -08:00
Christopher Jeffrey
97ecd5c59f
mempool: refactor indexing. 2016-12-18 19:35:38 -08:00
Christopher Jeffrey
01f21b0399
mempool: refactor verification. 2016-12-18 17:08:06 -08:00
Christopher Jeffrey
42f0b2aa19
mempool: refactor addr index. 2016-12-18 16:26:07 -08:00
Christopher Jeffrey
37770aa6df
mempool: move some methods. 2016-12-18 15:50:00 -08:00
Christopher Jeffrey
53e30fcc08
http: request - response limit. 2016-12-18 14:27:42 -08:00
Christopher Jeffrey
856957eee9
peer: fix witness checking for inbound. 2016-12-18 03:35:16 -08:00
Christopher Jeffrey
595ada8c86
mtx/wallet: more sanity checks for sending. 2016-12-18 03:20:47 -08:00
Christopher Jeffrey
ff28b7c4fb
mempool/miner: cleanup. 2016-12-18 02:58:29 -08:00
Christopher Jeffrey
c358a1b59e
mtx: coin selection - handle reorgd coinbases. 2016-12-18 02:54:01 -08:00
Christopher Jeffrey
82d1345311
net: refactor inv type handling. 2016-12-18 01:44:04 -08:00
Christopher Jeffrey
2691f9fcb6
mempool: fix comment. 2016-12-17 15:48:47 -08:00
Christopher Jeffrey
1f2c3080bc
mempool: more minor style changes. 2016-12-17 15:43:48 -08:00
Christopher Jeffrey
effc177a77
mempool: minor. style. 2016-12-17 15:34:33 -08:00
Christopher Jeffrey
b36484c7aa
mempool: fix potential race conditions with coins. 2016-12-17 15:28:14 -08:00
Christopher Jeffrey
5fb16543f1
chain: expose coins methods. 2016-12-17 14:41:47 -08:00
Christopher Jeffrey
514e735a96
net: refactor reject msg. broadcast orphans. 2016-12-17 14:08:43 -08:00
Christopher Jeffrey
2d831ca5bd
node: minor. 2016-12-17 13:08:02 -08:00
Christopher Jeffrey
9036ea263d
peer: less spammy logs. 2016-12-17 02:50:03 -08:00
Christopher Jeffrey
6a87a9588b
peer: refactor ack handling. 2016-12-17 02:10:28 -08:00
Christopher Jeffrey
7606667ea5
list: comments. 2016-12-17 02:05:02 -08:00
Christopher Jeffrey
dcfc19408f
node: minor fixes. 2016-12-17 00:18:28 -08:00
Christopher Jeffrey
1365d0ff1d
net: refactor peer.pending. 2016-12-16 22:48:16 -08:00
Christopher Jeffrey
edf47d67c8
primitives: refresh call. 2016-12-16 22:02:05 -08:00
Christopher Jeffrey
a23a5437a4
net: fix peer error handling. 2016-12-16 20:48:47 -08:00
Christopher Jeffrey
2beb9c06a5
test: fix http. 2016-12-16 18:11:49 -08:00
Christopher Jeffrey
5683d708dd
browser: add dns resolution. 2016-12-16 18:05:04 -08:00
Christopher Jeffrey
2c2ad461af
net: add dns. 2016-12-16 17:18:55 -08:00
Christopher Jeffrey
af8194112e
net: refactor pool. 2016-12-16 17:18:20 -08:00
Christopher Jeffrey
8ccefb8e71
peer: refactor. 2016-12-16 15:08:59 -08:00
Christopher Jeffrey
4269d16fee
refactor: lint. 2016-12-16 14:49:35 -08:00
Christopher Jeffrey
7971e56765
peer: use list for request queue. 2016-12-16 14:40:30 -08:00
Christopher Jeffrey
463ebd9bd3
pool: misc refactor. 2016-12-16 13:53:05 -08:00
Christopher Jeffrey
761b6d6636
net: refactor host management. 2016-12-16 13:50:45 -08:00
Christopher Jeffrey
dc58c99ba2
net: refactor sending and announcing. 2016-12-16 04:10:02 -08:00
Christopher Jeffrey
69a9b5873f
net: use linked lists. 2016-12-16 03:18:08 -08:00
Christopher Jeffrey
67ffecc989
http: refactor info. 2016-12-15 19:57:04 -08:00
Christopher Jeffrey
d661496541
rpc: minor. 2016-12-15 19:20:12 -08:00
Christopher Jeffrey
29579fc8d0
rpc: refactor getblocktemplate. 2016-12-15 19:06:22 -08:00
Christopher Jeffrey
6b69e2bfad
miner: move tx.isFinal. 2016-12-15 16:41:33 -08:00
Christopher Jeffrey
2e26909e85
rpc: add witness nonce for submitted blocks. 2016-12-15 16:12:35 -08:00
Christopher Jeffrey
6d1eb9fd36
rpc: submitblock logs. 2016-12-15 15:38:27 -08:00
Christopher Jeffrey
559cc3592d
mempool: handle mined removal better. 2016-12-15 15:12:55 -08:00
Christopher Jeffrey
8b05ef2def
http: fix html type for request. 2016-12-15 09:15:37 -08:00
Christopher Jeffrey
ee3745616e
miner: refactor extranonce. 2016-12-14 17:15:27 -08:00
Christopher Jeffrey
40b3e56402
mempool: logs for block adding/removing. 2016-12-14 14:04:26 -08:00
Christopher Jeffrey
854cdf1367
wallet: fix txrecord. 2016-12-14 12:17:53 -08:00
Christopher Jeffrey
b2ef630341
http: less spam. 2016-12-14 12:11:05 -08:00
Christopher Jeffrey
4a8c4dee57
node: fix event race conditions. 2016-12-14 12:03:47 -08:00
Christopher Jeffrey
4353decc5a
mining: remove cheating. rename witness deployment to segwit. 2016-12-14 11:27:39 -08:00
Christopher Jeffrey
f8b4750d90
Revert "miner: pass ts."
This reverts commit aa46fb2df2.
2016-12-14 10:59:17 -08:00
Christopher Jeffrey
aa46fb2df2
miner: pass ts. 2016-12-14 10:46:01 -08:00
Christopher Jeffrey
a9a0f638eb
miner: failsafe for segwit. 2016-12-14 10:39:56 -08:00
Christopher Jeffrey
6dcfdc02fd
miner: better cheating. 2016-12-14 10:33:44 -08:00
Christopher Jeffrey
1c08beba0a
miner: cheat on testnet. 2016-12-14 10:09:45 -08:00
Christopher Jeffrey
65ddc563d6
miner: mining and rpc changes. 2016-12-14 10:03:39 -08:00
Christopher Jeffrey
b025f5c241
http: allow batched rpc calls. 2016-12-14 07:05:24 -08:00
Christopher Jeffrey
8efbe1f9ee
coins/errors: minor. 2016-12-14 07:05:14 -08:00
Christopher Jeffrey
44818f8b06
errors: add assert. 2016-12-14 05:56:58 -08:00
Christopher Jeffrey
c1d6896797
rpc: minor fixes. 2016-12-14 04:20:05 -08:00
Christopher Jeffrey
eef018004f
http/rpc: mining. logs and error handling. 2016-12-13 21:06:37 -08:00
Christopher Jeffrey
ca9fc63309
net: minor. 2016-12-13 20:21:04 -08:00
Christopher Jeffrey
2f543ea465
btc: refactor verify error. 2016-12-13 17:53:29 -08:00
Christopher Jeffrey
ef1eb23ea3
txdb: minor. 2016-12-13 17:51:45 -08:00
Christopher Jeffrey
33a8e1e511
block/tx: sigops cost/size/weight. 2016-12-13 16:52:31 -08:00
Christopher Jeffrey
f9a1e18437
wallet: remove resolution. 2016-12-13 14:26:14 -08:00
Christopher Jeffrey
d01088b54d
bench: fix chacha bench. 2016-12-13 03:40:13 -08:00
Christopher Jeffrey
14c9a37cd9
packets: more serialization nonsense. 2016-12-13 02:58:49 -08:00
Christopher Jeffrey
fcc7f41438
env: fix coinview. 2016-12-12 21:27:18 -08:00
Christopher Jeffrey
51ca09603a
masterkey: minor. 2016-12-12 12:59:08 -08:00
Christopher Jeffrey
eaaa35cb8e
script: minor. 2016-12-12 12:31:27 -08:00
Christopher Jeffrey
41a2a46403
tx: refactor sighash v0. 2016-12-12 10:53:28 -08:00
Christopher Jeffrey
fcf6254d29
address: refactor. 2016-12-12 06:50:13 -08:00
Christopher Jeffrey
8108ff3eb5
util: minor changes to static writer. 2016-12-12 05:38:43 -08:00
Christopher Jeffrey
df4b07304b
rpc: fix getblocktemplate. 2016-12-12 05:11:19 -08:00
Christopher Jeffrey
eef7ffbe6e
bench: add buffer writer bench. 2016-12-11 19:41:23 -08:00
Christopher Jeffrey
dfefc7182f
serialization: more sizes. 2016-12-11 19:16:02 -08:00
Christopher Jeffrey
3b9e4d6c6e
refactor: use static writers everywhere. 2016-12-11 17:26:42 -08:00
Christopher Jeffrey
f7c9a24802
tx/coins: start using static writers more. 2016-12-11 13:44:20 -08:00
Christopher Jeffrey
1296bb2302
serialization: add size calculation and static writer. 2016-12-11 12:19:18 -08:00
Christopher Jeffrey
808d8678a6
tx: add sigops vsize calculation. 2016-12-11 10:35:17 -08:00
Christopher Jeffrey
72d5eec710
block/bip152/merkleblock: refactor some block things. 2016-12-11 10:10:00 -08:00
Christopher Jeffrey
efa0d3eac5
script: fix potential uncaught error. 2016-12-11 10:09:04 -08:00
Christopher Jeffrey
dcef9beed5
root: update readme. 2016-12-11 09:05:27 -08:00
Christopher Jeffrey
d4cb8d82a2
minor: comments. 2016-12-11 08:32:46 -08:00
Christopher Jeffrey
ed4fb0f92c
rpc: minor. 2016-12-11 08:23:03 -08:00
Christopher Jeffrey
fc6798d3f0
http: rewrite request module. 2016-12-11 08:18:11 -08:00
Christopher Jeffrey
48fc7549ce
tx/wallet: misc fixes. 2016-12-11 06:14:32 -08:00
Christopher Jeffrey
59645ac3ec
refactor: remove extra properties from tx and block. 2016-12-11 05:35:31 -08:00
Christopher Jeffrey
931a2a9398
coins: minor. 2016-12-10 23:15:03 -08:00
Christopher Jeffrey
c681b75b7b
coins: minor. 2016-12-10 22:06:57 -08:00
Christopher Jeffrey
f3801fa8a7
refactor: move coins. 2016-12-10 22:00:27 -08:00
Christopher Jeffrey
5e23b284a3
coinview: fix parsing. 2016-12-10 21:46:50 -08:00
Christopher Jeffrey
e754621dd4
script: toCode/fromCode. 2016-12-10 21:31:40 -08:00
Christopher Jeffrey
b77aa9240e
coins: refactor and comments. 2016-12-10 20:43:49 -08:00
Christopher Jeffrey
b437b33760
test/bench: lint. 2016-12-10 17:13:45 -08:00
Christopher Jeffrey
d2e61d1fa2
test: cleanup tests. 2016-12-10 14:43:58 -08:00
Christopher Jeffrey
5e3b05ff11
bench: clean up benchmarks. 2016-12-10 13:32:28 -08:00
Christopher Jeffrey
1d6eb802e7
chain: minor. 2016-12-10 08:19:35 -08:00
Christopher Jeffrey
bf2e7d1486
test: fix tx tests. 2016-12-10 08:11:24 -08:00
Christopher Jeffrey
4484a11ede
tx/block: refactor. 2016-12-10 07:18:05 -08:00
Christopher Jeffrey
c9523d91a5
chain: refactor disconnection. 2016-12-10 06:30:04 -08:00
Christopher Jeffrey
092c1a90df
coins: undo coins fixes. 2016-12-09 17:29:33 -08:00
Christopher Jeffrey
12b3274d33
refactor: pass coin viewpoints for every function requiring inputs. 2016-12-09 07:15:35 -08:00
Christopher Jeffrey
ead3f64b7f
Merge branch 'pass-coins-4' into coins-compression-2 2016-12-09 00:01:14 -08:00
Christopher Jeffrey
de1f658ede
chaindb: fix getFullBlock. 2016-12-08 23:53:25 -08:00
Christopher Jeffrey
5bed0455d2
scriptnum: refactor. 2016-12-08 21:56:57 -08:00
Christopher Jeffrey
bf07023369
script: add cscriptnum implementation. 2016-12-08 19:26:53 -08:00
Christopher Jeffrey
d4c2331a11
mempool/chain: move some methods around. 2016-12-08 15:51:25 -08:00
Christopher Jeffrey
2715e71ae8
script: minor. 2016-12-08 03:01:36 -08:00
Christopher Jeffrey
9d4f946dda
mtx: minor. 2016-12-08 02:19:17 -08:00
Christopher Jeffrey
ee7d39ce81
policy: lower min relay fee to 1000. 2016-12-08 02:11:33 -08:00
Christopher Jeffrey
c86311029c
mempool: optimize coin view. 2016-12-08 01:57:26 -08:00
Christopher Jeffrey
b2065cc84d
mempool: minor. 2016-12-08 01:48:39 -08:00
Christopher Jeffrey
82a1a24138
test: fix mempool tests. 2016-12-08 01:40:04 -08:00
Christopher Jeffrey
1e18ca772a
encoding: fix varint bns. 2016-12-08 01:17:53 -08:00
Christopher Jeffrey
dd0ebe5320
rpc: fix getblocktemplate. 2016-12-07 22:39:30 -08:00
Christopher Jeffrey
c300df7340
mempool: refactor. 2016-12-07 19:11:59 -08:00
Christopher Jeffrey
c9fbaae0da
chaindb: fix getCoinView. 2016-12-07 18:05:52 -08:00
Christopher Jeffrey
4e9bec4cd3
refactor: lint. 2016-12-07 17:52:53 -08:00
Christopher Jeffrey
1269aab7a5
mempool: use coin viewpoint. 2016-12-07 17:47:31 -08:00
Christopher Jeffrey
8b99b5103b
chain: refactor coinview. 2016-12-07 03:25:40 -08:00
Christopher Jeffrey
9e4db47792
wallet: improve size estimation. 2016-12-06 23:29:13 -08:00
Christopher Jeffrey
f7e50e3435
tx: pass coins into scripting system. 2016-12-06 17:37:35 -08:00
Christopher Jeffrey
d4b8afa747
chain: pass height around. 2016-12-06 17:13:04 -08:00
Christopher Jeffrey
136a48b4b4
pool: refactor requests. 2016-12-06 17:12:54 -08:00
Christopher Jeffrey
9215e4fe48
address: better network validation. 2016-12-06 14:24:05 -08:00
Christopher Jeffrey
2365355d79
net: getblocks handling. 2016-12-06 11:10:47 -08:00
Christopher Jeffrey
d2e9843757
http: fix addr array. 2016-12-06 00:04:04 -08:00
Christopher Jeffrey
4e4dbfba49
server/wallet/mempool: get tests passing. 2016-12-05 21:02:08 -08:00
Christopher Jeffrey
5091f69038
wallet/http: send address validation. 2016-12-05 17:24:18 -08:00
Christopher Jeffrey
07a34bbfe5
chaindb: compression=true. 2016-12-05 11:36:55 -08:00
Christopher Jeffrey
01535c55d7
mempool: remove confidence. 2016-12-05 11:35:33 -08:00
Christopher Jeffrey
21f4f45205
mempool: refactor coin and orphan handling. 2016-12-04 20:14:18 -08:00
Christopher Jeffrey
b4221b7589
chaindb: switch back to buffer coin cache. 2016-12-04 19:12:13 -08:00
Christopher Jeffrey
1d5bcc5918
block/worker: misc fixes. 2016-12-04 18:59:49 -08:00
Christopher Jeffrey
f45ce12bec
chaindb: minor. 2016-12-04 18:09:33 -08:00
Christopher Jeffrey
72b68532e3
ldb: add db cache-size option. 2016-12-04 13:59:08 -08:00
Christopher Jeffrey
28cc714bad
node: fix fast option. 2016-12-04 03:25:09 -08:00
Christopher Jeffrey
c358b6b822
chain: minor. 2016-12-04 03:16:13 -08:00
Christopher Jeffrey
11506ce246
coinview: minor. 2016-12-04 03:14:49 -08:00
Christopher Jeffrey
38eca965a7
mempool: orphan serialization. 2016-12-04 03:14:25 -08:00
Christopher Jeffrey
30526aaea4
chaindb: coin cache. 2016-12-04 02:59:20 -08:00
Christopher Jeffrey
a95aba92fb
serialization: less polymorphism. 2016-12-04 00:54:50 -08:00
Christopher Jeffrey
ba88ffab01
encoding: fix typo for BN. 2016-12-02 21:29:47 -08:00
Christopher Jeffrey
f2a9eb6538
workers: refactor logging. 2016-12-02 18:34:29 -08:00
Christopher Jeffrey
bdc7ec0198
worker: more refactoring. 2016-12-02 18:14:47 -08:00
Christopher Jeffrey
1f47d5ead5
workers: client and server parser refactor. 2016-12-02 12:08:46 -08:00
Christopher Jeffrey
a4d30f00a8
workers: improve protocol. 2016-12-02 11:52:03 -08:00
Christopher Jeffrey
89f478bba1
encoding: no casting. 2016-12-02 06:36:12 -08:00
Christopher Jeffrey
c190dd2aad
util: refactor encoding. 2016-12-02 04:34:38 -08:00
Christopher Jeffrey
dbed720d20
coins: minor. 2016-12-02 01:50:43 -08:00
Christopher Jeffrey
b37b99a86e
chain: refactor input spending. 2016-12-01 23:37:57 -08:00
Christopher Jeffrey
967449b0d5
chaindb: minor. 2016-12-01 13:35:04 -08:00
Christopher Jeffrey
244af663bb
coins: comments. 2016-12-01 04:48:00 -08:00
Christopher Jeffrey
9f11875736
coins: no compressed non-zero bytes. 2016-12-01 04:11:14 -08:00
Christopher Jeffrey
3d876858f9
chain: refactor undo coins. 2016-12-01 02:56:08 -08:00
Christopher Jeffrey
873475b835
mtx: refactor signing. 2016-12-01 00:29:34 -08:00
Christopher Jeffrey
8e49d87e53
wallet: refactor client. 2016-12-01 00:13:59 -08:00
Christopher Jeffrey
6939ba2cd3
chain: skip coinbases when scanning. 2016-12-01 00:03:23 -08:00
Christopher Jeffrey
81e71e7922
wallet: drop wallet getters. 2016-11-30 23:12:01 -08:00
Christopher Jeffrey
bffdd78009
hd: drop getters. 2016-11-30 22:00:22 -08:00
Christopher Jeffrey
430a69e3d3
chaindb: drop useless. 2016-11-30 21:34:21 -08:00
Christopher Jeffrey
ded3bc34f3
refactor: start moving away from getters. 2016-11-30 21:31:52 -08:00
Christopher Jeffrey
0e234c7c3a
net: fix destroy check. 2016-11-30 21:00:40 -08:00
Christopher Jeffrey
f4f4f2b433
chaindb: compression=false. 2016-11-30 20:36:11 -08:00
Christopher Jeffrey
371f6b1fa0
chain: refactor spending. 2016-11-30 20:08:07 -08:00
Christopher Jeffrey
453eccbabd
Revert "chain: handle chain state arithmetic differently."
This reverts commit c87fce53ab.
2016-11-30 19:13:29 -08:00
Christopher Jeffrey
c87fce53ab
chain: handle chain state arithmetic differently. 2016-11-30 18:57:58 -08:00
Christopher Jeffrey
c02514a8b3
test: add chain state test. 2016-11-30 18:53:52 -08:00
Christopher Jeffrey
aad1691f7e
chain: refactor tx indexing. 2016-11-30 18:17:10 -08:00
Christopher Jeffrey
7157d06464
chaindb: refactor init and deployments. 2016-11-30 17:35:57 -08:00
Christopher Jeffrey
9f44ddc22f
chain: add undocoins object. 2016-11-30 16:08:38 -08:00
Christopher Jeffrey
311b9841fb
chain: more refactoring. 2016-11-30 16:02:56 -08:00
Christopher Jeffrey
cfd7ec8a64
chain: more refactoring. 2016-11-30 13:09:33 -08:00
Christopher Jeffrey
ff5eddbebb
chain: move some methods. 2016-11-30 01:05:28 -08:00
Christopher Jeffrey
74ec6a29fb
migrate: fix chain migration. 2016-11-29 22:18:33 -08:00
Christopher Jeffrey
3e94b9fd0a
migrate: enable chain migration. 2016-11-29 21:46:42 -08:00
Christopher Jeffrey
75f01c1692
migrate: check tip index for chaindbv2. 2016-11-29 21:43:20 -08:00
Christopher Jeffrey
8b8e1e3f13
migrate: update chaindb1to2. 2016-11-29 21:31:39 -08:00
Christopher Jeffrey
2b12863de1
migrate: add chaindb v2 migration. 2016-11-29 21:27:20 -08:00
Christopher Jeffrey
e7bcbbb976
chain: drop newCoins option. 2016-11-29 21:01:48 -08:00
Christopher Jeffrey
cc252b949d
coins: refactor. lint. 2016-11-29 20:36:24 -08:00
Christopher Jeffrey
dcb376f26d
chain: add newCoins option. 2016-11-29 20:36:23 -08:00
Christopher Jeffrey
cdee4ce251
coins: refactor. 2016-11-29 20:36:23 -08:00
Christopher Jeffrey
63c42bf390
chain: new coins compression. 2016-11-29 20:36:23 -08:00
Christopher Jeffrey
923364a70a
chain: initial add refactor. 2016-11-29 20:36:23 -08:00
Christopher Jeffrey
0f529d5f8b
chain/block: reorder some consensus checks. 2016-11-29 20:36:23 -08:00
Christopher Jeffrey
71c7c3e300
peer: lint. 2016-11-29 20:35:30 -08:00
Christopher Jeffrey
01e7fd3902
pool: rename outbound/inbound. remove co.wait() in scheduleRequests. 2016-11-28 20:40:09 -08:00
Christopher Jeffrey
bc4a9b3f14
net: reduce request timeout to 2 min. 2016-11-28 17:56:15 -08:00
Christopher Jeffrey
fa8b4c6428
net: remove isBusy check from sendRequests. 2016-11-28 17:31:21 -08:00
Christopher Jeffrey
507fd89948
timedata: move time to network object. 2016-11-28 16:58:48 -08:00
Christopher Jeffrey
cc7a7890db
chain: less polymorphism for getDeploymentState. 2016-11-28 16:08:35 -08:00
Christopher Jeffrey
d1e37582d1
block/crypto: refactor merkle trees. 2016-11-28 15:59:30 -08:00
Christopher Jeffrey
6520cf32e0
node: less error spam in logs. 2016-11-27 23:54:18 -08:00
Christopher Jeffrey
c7b7678f8a
peer: fix tryAnnounce. 2016-11-27 23:54:08 -08:00
Christopher Jeffrey
1997864ec2
coins: refactor compression. 2016-11-27 22:23:12 -08:00
Christopher Jeffrey
7fd2c409ae
peer: error on finishDrain. 2016-11-27 16:09:23 -08:00
Christopher Jeffrey
89f86ae6c5
bip70: fix payment serialization. 2016-11-27 04:33:59 -08:00
Christopher Jeffrey
dd2d9f48bd
coins: refactor. 2016-11-26 20:17:01 -08:00
Christopher Jeffrey
67695b7e53
fees: minor. 2016-11-26 20:16:54 -08:00
Christopher Jeffrey
cb59675b06
refactor: rename buffer reader/writer vars. 2016-11-26 10:56:50 -08:00
Christopher Jeffrey
c523193714
coins: refactor. 2016-11-26 10:03:32 -08:00
Christopher Jeffrey
20cdb1adbc
miner: clear coins. 2016-11-26 09:27:17 -08:00
Christopher Jeffrey
85adb1acec
test: chain. 2016-11-26 06:56:44 -08:00
Christopher Jeffrey
cd0315923b
mempool: add reset logs. 2016-11-26 06:18:31 -08:00
Christopher Jeffrey
c033f5d465
coins: optimize. 2016-11-26 06:09:27 -08:00
Christopher Jeffrey
9bc92abb41
chain: refactor coins. 2016-11-26 04:50:32 -08:00
Christopher Jeffrey
2d94935ddd
bench: fix coin bench. 2016-11-26 04:31:25 -08:00
Christopher Jeffrey
c5a5d4498a
chain/wallet: handle caches better. 2016-11-26 01:12:38 -08:00
Christopher Jeffrey
3e37961927
mempool: add reset method. 2016-11-26 00:22:46 -08:00
Christopher Jeffrey
2dbeb07668
scripts: add heapdump script. 2016-11-25 21:23:31 -08:00
Christopher Jeffrey
5dbb896aea
mempool: update mem usage. 2016-11-25 21:23:17 -08:00
Christopher Jeffrey
db10df4ccb
root: remove .dockerignore. 2016-11-25 19:53:26 -08:00
Christopher Jeffrey
eda58c6c3b
root: remove some files. 2016-11-25 19:53:08 -08:00
Christopher Jeffrey
eef9bcd872
walletdb: minor. 2016-11-25 19:37:04 -08:00
Christopher Jeffrey
c0fd199f2d
chain: refactor and optimize. 2016-11-25 19:34:25 -08:00
Christopher Jeffrey
024ff3e211
http: http and rpc fixes. 2016-11-25 14:19:11 -08:00
Christopher Jeffrey
0dbdf30e89
pool: minor. 2016-11-25 14:13:36 -08:00
Christopher Jeffrey
6c25efca89
net: better write handling. 2016-11-24 14:44:10 -08:00
Christopher Jeffrey
01bb0adc17
pool: fix typo. 2016-11-24 01:20:21 -08:00
Christopher Jeffrey
9c48cc9333
pool: fix destroyed race condition. 2016-11-23 18:54:12 -08:00
Christopher Jeffrey
1f22013ce0
chain: versionbits refactor. 2016-11-23 17:03:58 -08:00
Christopher Jeffrey
390f7d8ddb
minerblock: commit block once mined. 2016-11-23 00:56:56 -08:00
Christopher Jeffrey
9e48947d2f
txdb: fix txdb.confirm. 2016-11-23 00:36:57 -08:00
Christopher Jeffrey
229be344fc
chaindb: persistent versionbits state caches. 2016-11-22 23:59:02 -08:00
Christopher Jeffrey
0530c8f80f
chain: log state updates after db write. 2016-11-22 14:18:44 -08:00
Christopher Jeffrey
e025902405
wallet: expose client. 2016-11-22 10:51:00 -08:00
Christopher Jeffrey
9a921ab8f0
crypto: optimize hashing for browser. 2016-11-22 10:46:06 -08:00
Christopher Jeffrey
008880f40f
deps: bcoin-native v0.0.11. 2016-11-22 10:30:23 -08:00
Christopher Jeffrey
0e40eb6491
tx/block: remove hashAsync. 2016-11-22 10:28:54 -08:00
Christopher Jeffrey
7f5e0cb493
writer: improve perf. 2016-11-21 20:54:30 -08:00
Christopher Jeffrey
0bf9828f03
wallet: add clients. 2016-11-21 18:05:29 -08:00
Christopher Jeffrey
f376289684
crypto: implement subtle api for browser. 2016-11-21 17:50:05 -08:00
Christopher Jeffrey
4245cd6bf1
crypto: use subtle for browser pbkdf2. 2016-11-20 13:12:35 -08:00
Christopher Jeffrey
6c61ad976d
walletdb: add experimental client. 2016-11-19 22:55:00 -08:00
Christopher Jeffrey
d75b5d80cc
walletdb: nodeclient work. 2016-11-19 21:40:31 -08:00
Christopher Jeffrey
1827b945dd
walletdb: new client api. 2016-11-19 18:26:27 -08:00
Christopher Jeffrey
8f743b6e7d
peer: handle drains better. 2016-11-19 14:33:40 -08:00
Christopher Jeffrey
9353a86e14
modules: blockchain technology (tm). 2016-11-19 11:24:01 -08:00
Christopher Jeffrey
bf34a8133d
btc: rename. 2016-11-19 11:14:38 -08:00
Christopher Jeffrey
b754973511
utils/btc: rename. 2016-11-19 10:45:31 -08:00
Christopher Jeffrey
ae093d2242
amount/utils: drop utils.btc and utils.satoshi. 2016-11-19 09:59:47 -08:00
Christopher Jeffrey
9e9b657eab
utils: add amount object. 2016-11-19 08:44:24 -08:00
Christopher Jeffrey
098465c171
miner: rename. 2016-11-19 07:10:49 -08:00
Christopher Jeffrey
7f3c265085
net: rename timedata. 2016-11-19 06:53:59 -08:00
Christopher Jeffrey
3014229d9a
workers: rename. 2016-11-19 06:48:55 -08:00
Christopher Jeffrey
a1ec1bfff1
modules: refactor indexes. 2016-11-19 06:36:57 -08:00
Christopher Jeffrey
0631148705
modules: more refactoring. 2016-11-19 05:29:29 -08:00
Christopher Jeffrey
729aea3b41
utils: mark circular. 2016-11-19 02:47:44 -08:00
Christopher Jeffrey
3f6e4f3847
workers: major refactor. 2016-11-19 02:28:30 -08:00
Christopher Jeffrey
6f9ad90e07
modules: drop all circular deps. 2016-11-19 02:26:05 -08:00
Christopher Jeffrey
4c9d9d5160
miner: rename fill. add comments. 2016-11-18 23:52:14 -08:00
Christopher Jeffrey
c6eabdb121
utils: minor. 2016-11-18 23:41:58 -08:00
Christopher Jeffrey
091ddf2029
http: minor. 2016-11-18 23:39:52 -08:00
Christopher Jeffrey
5ad3b9612d
ec: minor. 2016-11-18 23:37:19 -08:00
Christopher Jeffrey
baffd161b8
modules: more browser compat. 2016-11-18 23:33:05 -08:00
Christopher Jeffrey
354cf00158
modules: fix browser compilation. 2016-11-18 23:17:29 -08:00
Christopher Jeffrey
67a00bfe50
modules: remove all conditional requires. see #105. 2016-11-18 23:05:04 -08:00
Christopher Jeffrey
9f522c5ca4
layout: less conditional requires. see #105. 2016-11-18 18:31:29 -08:00
428 changed files with 99012 additions and 123257 deletions

View File

@ -1,9 +0,0 @@
{
"presets": ["es2015"],
"plugins": [
["transform-runtime", {
"polyfill": true,
"regenerator": true
}]
]
}

59
.circleci/config.yml Normal file
View File

@ -0,0 +1,59 @@
defaults: &defaults
working_directory: ~/repo
docker:
- image: circleci/node:10.2
version: 2.0
jobs:
install:
<<: *defaults
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package-lock.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: npm install
- run: npm install bslint nyc codecov
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package-lock.json" }}
- persist_to_workspace:
root: .
paths: .
test:
<<: *defaults
steps:
- attach_workspace:
at: .
- run:
name: Tests with coverage
command: npm run test-ci
- run:
name: Submit coverage
command: ./node_modules/.bin/codecov
lint:
<<: *defaults
steps:
- attach_workspace:
at: .
- run:
name: Lint
command: npm run lint-ci
workflows:
version: 2
test_and_lint:
jobs:
- install
- lint:
requires:
- install
- test:
requires:
- install

View File

@ -1,2 +0,0 @@
node_modules/
docker_data/

13
.eslintfiles Normal file
View File

@ -0,0 +1,13 @@
bench/
bin/cli
bin/node
bin/spvnode
bin/wallet
browser/server.js
browser/wsproxy.js
browser/src/app.js
lib/
migrate/
scripts/
test/
docs/examples

152
.eslintrc.json Normal file
View File

@ -0,0 +1,152 @@
{
"env": {
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readable",
"BigInt": "readable",
"BigInt64Array": "readable",
"BigUint64Array": "readable",
"queueMicrotask": "readable",
"SharedArrayBuffer": "readable",
"TextEncoder": "readable",
"TextDecoder": "readable"
},
"overrides": [
{
"files": ["*.mjs"],
"parserOptions": {
"sourceType": "module"
}
},
{
"files": ["*.cjs"],
"parserOptions": {
"sourceType": "script"
}
},
{
"files": [
"test/{,**/}*.{mjs,cjs,js}"
],
"env": {
"mocha": true
},
"globals": {
"register": "readable"
},
"rules": {
"max-len": "off",
"prefer-arrow-callback": "off"
}
}
],
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 10,
"ecmaFeatures": {
"globalReturn": true
},
"requireConfigFile": false,
"sourceType": "script"
},
"root": true,
"rules": {
"array-bracket-spacing": ["error", "never"],
"arrow-parens": ["error", "as-needed", {
"requireForBlockBody": true
}],
"arrow-spacing": "error",
"block-spacing": ["error", "always"],
"brace-style": ["error", "1tbs"],
"camelcase": ["error", {
"properties": "never"
}],
"comma-dangle": ["error", "never"],
"consistent-return": "error",
"eol-last": ["error", "always"],
"eqeqeq": ["error", "always", {
"null": "ignore"
}],
"func-name-matching": "error",
"indent": ["off", 2, {
"ArrayExpression": "off",
"SwitchCase": 1,
"CallExpression": {
"arguments": "off"
},
"FunctionDeclaration": {
"parameters": "off"
},
"FunctionExpression": {
"parameters": "off"
},
"MemberExpression": "off",
"ObjectExpression": "off",
"ImportDeclaration": "off"
}],
"handle-callback-err": "off",
"linebreak-style": ["error", "unix"],
"max-len": ["error", {
"code": 80,
"ignorePattern": "function \\w+\\(",
"ignoreUrls": true
}],
"max-statements-per-line": ["error", {
"max": 1
}],
"new-cap": ["error", {
"newIsCap": true,
"capIsNew": false
}],
"new-parens": "error",
"no-buffer-constructor": "error",
"no-console": "off",
"no-extra-semi": "off",
"no-fallthrough": "off",
"no-func-assign": "off",
"no-implicit-coercion": "error",
"no-multi-assign": "error",
"no-multiple-empty-lines": ["error", {
"max": 1
}],
"no-nested-ternary": "error",
"no-param-reassign": "off",
"no-return-assign": "error",
"no-return-await": "off",
"no-shadow-restricted-names": "error",
"no-tabs": "error",
"no-trailing-spaces": "error",
"no-unused-vars": ["error", {
"vars": "all",
"args": "none",
"ignoreRestSiblings": false
}],
"no-use-before-define": ["error", {
"functions": false,
"classes": false
}],
"no-useless-escape": "off",
"no-var": "error",
"nonblock-statement-body-position": ["error", "below"],
"padded-blocks": ["error", "never"],
"prefer-arrow-callback": "error",
"prefer-const": ["error", {
"destructuring": "all",
"ignoreReadBeforeAssign": true
}],
"prefer-template": "off",
"quotes": ["error", "single"],
"semi": ["error", "always"],
"spaced-comment": ["error", "always", {
"exceptions": ["!"]
}],
"space-before-blocks": "error",
"strict": "error",
"unicode-bom": ["error", "never"],
"valid-jsdoc": "error",
"wrap-iife": ["error", "inside"]
}
}

12
.gitignore vendored
View File

@ -1,5 +1,11 @@
npm-debug.log
key.key
node_modules/
test.js
.nyc_output
docs/reference/
docker_data/
browser/bcoin*
npm-debug.log
coverage/
yarn.lock
webpack.*.js
.DS_Store
tmp*

View File

@ -1,43 +0,0 @@
{
"bitwise": false,
"esversion": 6,
"curly": false,
"eqeqeq": true,
"freeze": true,
"latedef": "nofunc",
"maxparams": 7,
"noarg": true,
"shadow": "inner",
"undef": true,
"unused": "vars",
"boss": true,
"expr": true,
"eqnull": true,
"evil": true,
"loopfunc": true,
"proto": true,
"supernew": true,
"-W018": true,
"-W064": true,
"-W086": true,
"-W032": true,
"-W021": true,
"browser": true,
"browserify": true,
"node": true,
"nonstandard": true,
"typed": true,
"worker": false,
"camelcase": false,
"indent": 2,
"maxlen": 110,
"newcap": false,
"quotmark": "single",
"laxbreak": true,
"laxcomma": true
}

View File

@ -1,6 +1,18 @@
.babel*
.bmocharc*
.bpkgignore
.editorconfig
.eslint*
.git*
test/
.mocharc*
.yarnignore
yarn.lock
node_modules/
.jshintrc
.jscsrc
jsdoc.json
package-lock.json
npm-debug.log
webpack.*.js
browser/bcoin*
bench/
build/
docs/
test/

603
CHANGELOG.md Normal file
View File

@ -0,0 +1,603 @@
# Bcoin release notes & changelog
## v2.0.0-dev
### How to upgrade
The way that block data is stored has changed for greater performance,
efficiency, reliability and portability.
- Block and undo block data has been moved from LevelDB into flat files.
- The transaction and address indexes have been moved into separate
LevelDB databases.
- The transaction has been de-duplicated, and will reduce disk usage by
half for those running with `txindex` enabled.
- The `txindex` and `addrindex` can now be enabled after the initial
block download.
- The `addrindex` has been sorted to support querying for large sets
of results, and will no longer cause CPU and memory exhaustion issues.
- The `addrindex` will correctly distinguish between `p2pkh` and
`p2wpkh` addresses.
To upgrade to the new disk layout it's necessary to move block data
from LevelDB (e.g. `~/.bcoin/chain`) to a new file based block
storage (e.g. `~./.bcoin/blocks`), and remove `txindex` and `addrindex`
data from the chain database, for those that have that feature enabled.
To do this you can run:
```
node ./migrate/chaindb4to6.js /path/to/bcoin/chain
```
The migration will take 1-3 hours, depending on hardware. The block data
will now be stored at `/path/to/bcoin/blocks`, after the data has been moved
the chain database will be compacted to free disk space.
Alternatively, you can also sync the chain again, however the above
migration will be faster as additional network bandwidth won't be used
for downloading the blocks again.
For those with `txindex` and `addrindex` enabled, the indexes will be
regenerated by rescanning the chain on next startup, this process can
take multiple hours (e.g. 8 hours) depending on hardware and the
index. Please take the potential downtime in re-indexing into account
before upgrading.
### Wallet API changes
#### HTTP
- `PUT /wallet/:id` Creating a watch-only wallet now requires an `accountKey`
argument. This is to prevent bcoin from generating keys and addresses the
user can not spend from.
- `POST /wallet/:id/create`
- Now has a `sign` argument for optional signing of transactions.
- Now has a `template` option, that will skip templating inputs when
`sign = false`, but you can enable it if necessary. It does not have an
effect when `sign = true`.
- Exposes `blocks`, which can will be used if there is no `rate` option.
- Exposes `sort` (Default `true`), that can be used to disable BIP69 sorting.
#### RPC
- Bug fix addresses for the `getnewaddress` command with various networks.
- Deprecate the `ismine` and `iswatchonly` fields from the `validateaddress`
command and add `isscript`, `iswitness`, `ischange`, `witness_version`
and `witness_program` to partially match the v0.18.0 Bitcoin Core release
(26a2000b0177fd2668b7d82e5aa52829cf2bfdf6)
- Add wallet RPC `getaddressinfo` to return `ismine` and `iswatchonly`
with the correct values instead of their previous values which were
hardcoded to false. Also returns `address`, `scriptPubKey`, `isscript`,
`iswitness`, `witness_version` and `witness_program`.
(a28ffa272a3c4d90d0273d9aa223a23becc08e0e)
### Node API changes
#### HTTP
Several CPU and memory exhaustion issues have been resolved with some
additional arguments for querying multiple sets of results for addresses
that have many transactions.
- `GET /tx/address/:address` has several new arguments: `after`, `reverse`
and `limit`. The `after` argument is a txid, for querying additional results
after a previous result. The `reverse` argument will change the order that
results are returned, the default order is oldest to latest. The `limit`
argument can be used to give results back in smaller sets if necessary.
- `POST /tx/address` This has been deprecated, instead query for each address
individually with `GET /tx/address/:address` with the expectation that
there could be _many_ results that would additionally need to be queried
in a subsequent query using the `after` argument to request the next set.
- `POST /coin/address` and `GET /coin/address/:address` are deprecated as
coins can be generated using results from `/tx/address/:address` and
querying by only a range of the latest transactions to stay synchronized.
Coins could otherwise be removed from results at any point, and thus the
entire set of results would need to be queried every time to discover
which coins have been spent and are currently available.
- `GET /` has new fields `.indexes.{addr,tx}` for the status of indexers.
### Network changes
- Regtest params have been updated to correspond with other bitcoin
implementations for cross testing. Key prefixes have been updated and
segwit is always active (39684df6051b599da9ed1383cb7e3f8605806a74). The
regtest seeds have also been cleared so that the node will not attempt
to connect to itself.
- Testnet seeds have been updated (8b6eba165b090edfc1ff5dbc9c422758d60b6342)
### Logging changes
- Wallet and node HTTP and RPC is now more clearly identified. The wallet
HTTP server will log with the context `wallet-http` and the RPC as
`wallet-rpc`. The node HTTP will log with the context `node-http` and the
RPC as `node-rpc`. There was also a reduction in the duplicate logs in
the case of an error for the node RPC, and the addition of method logging
for the wallet RPC.
- There is now also additional logging during wallet rescans.
### Configuration changes
- Pool options now has a `--discover` option exposed, and the `--only` node
option will disable discovery of new nodes.
- The option for `coin-cache` has been removed, this setting was causing
issues during the sync with out-of-memory errors and was making performance
worse instead of better.
- The database location for indexes can be configured via the
`--index-prefix` option. Default locations are `prefix` + `/index`
(e.g. `~/.bcoin/testnet/index/tx` and `~/.bcoin/testnet/index/addr`).
### Script changes
- Script has been updated for policy flags. For example
`VERIFY_CONST_SCRIPTCODE` to disable `OP_CODESEPARATOR` in non-segwit
scripts and make a positive `findAndDelete` result invalid.
- Segwit scripts that terminate with a stack size not equal to one
now has as error of `CLEANSTACK` instead of `EVAL_FALSE`.
- `VERIFY_UPGRADABLE_NOPS` now does not apply to `OP_CHECKLOCKTIMEVERIFY`
and `OP_CHECKSEQUENCEVERIFY`.
### Testing changes
- Switched to use a security focused rewrite of `mocha` called
`bmocha`, for further details see: https://github.com/bcoin-org/bmocha
- Data has been updated to be in sync with other implementations
around policy-only script validation.
- Tests now cleanly close with all timers being cleared.
- Config file `wallet.conf` won't be read during test runs that was
causing issues with some testing environments.
### Chain changes
- The transaction index methods are now implemented at `node.txindex`:
- `getMeta(hash)`
- `getTX(hash)`
- `hasTX(hash)`
- `getSpentView(tx)`
- The address index method `getHashesByAddress` is now implemented
at `node.addrindex`:
- `getHashesByAddress(addr)` It now accepts `Address` instances
rather than `Address|String` and the results are now sorted in
order of appearance in the blockchain.
- `getHashesByAddress(addr, options)` A new options argument has
been added with the fields:
- `after` - A transaction hash for results to begin after.
- `limit` - The total number of results to return at maximum.
- `reverse` - Will give results in order of latest to oldest.
- The following methods require `node.addrindex.getHashesByAddress`
in conjunction with `node.txindex.getTX` and `node.txindex.getMeta`
respectively, and now includes a new options argument as described
above for `getHashesByAddress`:
- `node.getMetaByAddress(addr, options)`
- `node.getTXByAddress(addr, options)`
- The following method has been deprecated:
- `getCoinsByAddress(addr)`
### Other changes
- A new module for storing block data in files.
- Use of `buffer-map` for storing hashes
(see https://github.com/bcoin-org/bcoin/issues/533).
- Use of `bsert` for assertions.
- `SIGINT` handling will close the full node, spvnode and wallet.
- Using the bcoin library in a REPL now has auto-completion by pressing tab.
- Various documentation updates.
- Mempool fix to add non-standard (non-segwit) to reject cache.
- A lockfile is now included and all dependencies integrity verified
with sha512 hash and not the vulnerable sha1 hash.
- Updates to dependencies including `bcrypto` to version > 3.
- Various small fixes to run bcoin in a browser.
## v1.0.0
### Migration
The latest bcoin release contains almost a total rewrite of the wallet. A
migration is required.
Bcoin has also been modularized quite a bit. Users installing globally from npm
should be sure to run:
``` bash
$ npm update -g bcoin
```
For users who cloned the respository themselves, it might be wise to simply
remove the `node_modules` directory and do a fresh `npm install`.
``` bash
$ cd bcoin/
$ git pull origin master
$ rm -rf node_modules/
$ npm install
$ npm test
```
---
Once upgrading is complete, a migration script must be executed. The migration
script resides in `./migrate/latest` as an executable file.
A bcoin __prefix directory__ must be passed as the first argument.
Example:
``` bash
$ ./migrate/latest ~/.bcoin
```
What this does:
- Renames `chain.ldb` to `chain`.
- Renames `spvchain.ldb` to `spvchain`.
- Renames `walletdb.ldb` to `wallet`.
- Runs a migration (`chaindb3to4.js`) on `chain`.
- Runs a migration (`chaindb3to4.js`) on `spvchain`.
- Runs a migration (`walletdb6to7.js`) on `wallet`.
The chain migration should be minor, and only taxing if you have
`--index-address` enabled.
If you have a testnet, regtest, or simnet directory, the migration must also be
run on these, e.g.
``` bash
$ ./migrate/latest ~/.bcoin/testnet
```
Also note that the `--prefix` argument now __always__ creates a fully-fledged
prefix directory. For example `--prefix ~/.bcoin_whatever --network testnet`
will create a directory structure of `~/.bcoin_whatever/testnet/` instead of
`~/.bcoin_whatever`. Please update your directory structure accordingly.
### Configuration changes
Wallet and Node are now separated and use different persistent configuration files.
Some configuration options have moved to `wallet.conf`, which is stored in the prefix
directory next to the existing `bcoin.conf`.
All configuration options in `wallet.conf` will have the `wallet-`
prefix added implicitly. The prefix is still needed when using CLI/ENV configuration
methods. The wallet now has it's own HTTP server, so options such as
`wallet-http-host` must also be specified along with `http-host`
if you require this setting (required for Docker networking).
Wallet-specific settings such as `api-key` and `wallet-auth`
have moved to `wallet.conf`. If using CLI/ENV options, these are prefixed with `wallet-`.
Various configuration method examples are shown below.
Note some config options (eg. `network`) are automatically passed to wallet plugin
if specified through CLI/ENV, but should be specified in `wallet.conf` for `bwallet-cli`.
Example using wallet.conf:
```
network: testnet
wallet-auth: true
api-key: hunter2
http-host: 0.0.0.0
```
Example using CLI options:
`./bin/node --network=testnet --http-host=0.0.0.0 --wallet-http-host=0.0.0.0 --wallet-api-key=hunter2 --wallet-wallet-auth=true`
Example using ENV:
`BCOIN_NETWORK=simnet BCOIN_HTTP_HOST=0.0.0.0 BCOIN_WALLET_HTTP_HOST=0.0.0.0 BCOIN_WALLET_API_KEY=hunter2 BCOIN_WALLET_WALLET_AUTH=true ./bin/node`
### Bcoin client changes
The `bcoin cli` interface has been deprecated and is now replaced with a
separate tool: `bcoin-cli`. `bcoin wallet` has also been deprecated and is
replaced with `bwallet-cli`. Both `bcoin-cli` and `bwallet-cli` can be
installed with the `bclient` package in npm.
### Wallet API changes
The main wallet API changes have to do with changes in the structure of the
HTTP server itself. The bcoin wallet HTTP server will now always listen on it's
own port. Standard ports are:
```
main: 8334
testnet: 18334
regtest: 48334
simnet: 18558
```
The default account object is no longer present on the wallet. To retrieve it,
request `/wallet/:id/account/default` instead. More minor changes to the JSON
output include the removal of `id` and `wid` properties on a number of objects.
Please update your code accordingly.
For socket.io events, all `wallet ` prefixes have been removed. For example,
`wallet join` should be replaced with simply `join`. All wallet-related events
(`tx`, `confirmed`, etc) now receive the wallet ID as the first argument. The
`tx` event will receive `[id, details]` instead of `[details]`.
The `_admin` endpoints have been moved up a level. Instead of requesting
`/wallet/_admin/backup` (for example), request `/backup` instead. If
`--wallet-auth` is enabled, a new flag `--admin-token` is accepted. Admin token
is a 64 character hex string and allows access to all admin routes. For
example, `GET /backup?token=xxx...`. It also allows access to any wallet on the
HTTP or websocket layer (websockets who use the admin token can join a wallet
of `*`, which notifies them of events on _all_ wallets).
### Notable changes
- __wallet/http__ - A `conflict` event will be correctly emitted for _all_
double spends.
- __wallet/http__ - Account balances are now indexed and will appear on account
objects via the API.
- __bcoin__ - Bcoin has been rewritten using class syntax. Objects will not be
inheritable with legacy prototypal inheritance.
- __pkg__ - Bcoin is once again buildable with browserify.
- __pkg__ - Numerous modules have been moved out to separate dependencies. For
example, the `lib/crypto` module has been moved to the `bcrypto` package (and
also heavily optimized even further).
- __bcoin__ - The main `bcoin` module has been rewritten in terms of what it
exposes and how. Conventions have changed (`Address` instead of `address`).
Due to the use of class syntax, something like `bcoin.Address(str)` is no
longer possible. Please take a look at `lib/bcoin.js` to get a better idea of
what has changed.
- __net__ - Support for BIP151 and BIP150 has been dropped.
## v1.0.0-beta.15
### Notable changes
## v1.0.0-beta.14
### Notable changes
- __pkg__ - Ignored `bcoin*` files in npmignore have been removed. This fixes
the npm install.
## v1.0.0-beta.13
### Notable changes
- __config__ - Options using megabyte units are now calculated properly again
(6182df044228f9215938e7d314435f3f2640acca,
a630d23a97b68f189a85105856fedc4e9e515754,
7728a0047053d4c368e60426e5fc7cc812d54caf).
- __address__ - Bech32 addresses are now supported
(6acef06cbc87a3051ba238a2fb640562e718135e). This changes the semantics of
the `Address` object: to support bech32, `Address.fromBase58` calls should be
replaced with `Address.fromString`. Likewise, `addr.toBase58` calls should
be replaced with `addr.toString`
- __rpc__ - `getblockbyheight` is now exposed via JSON-RPC. It takes the same
parameters as the `getblock` call, requiring a height instead of block hash
(12d3ee6f9582afa9a3ba8984c63dcbc27b8db57e).
- __bin__ - `bcoin --version` and `bcoin --help` now exit with appropriate
messages (f2f94a800e37c5dbdda6920fa6b85fbd485c212a).
- __net__ - The p2p pool now exposes an `--only` option
(a1d0948f2e528c5d77d6502659fafd064b1e693b).
- __mempool__ - The mempool `indexAddress` option should now work correctly
(fba9b46d253c19bbf8e662d9d75ab03dc9e20a78).
- __rpc__ - JSON-RPC calls now properly cast booleans a la bitcoin core
(dd49ee076196d2353783e3044185165dbac4aeb9).
- __rpc__ - Various RPC calls have been improved and updated
(c78707ed6a71ce46c41c4e43ecb505e78a84b380,
c1e684dc12d0a86573a905d54d4f81fce921987a,
5bde338a53117b1bd0fd92df0abc23d95180ab32).
- __rpc__ - Retroactive pruning is now available via the `pruneblockchain` call
(f0bc6d5925419ba4a8289fa7828efc48ecc152d4).
- __http__ - Getting block by height via the Rest API now works again
(df4c8cc68c965bd818a5004354d2652751d4a702).
- __net__ - Peers who serve invalid orphans are now punished properly
(0ceca23cb5a3d724c79c6bf587ede5d473df8486).
- __utils__ - An implementation of GCS filters is now supported
(b994c278f25408886c3095d0c24123baaf07f78f).
- __http__ - The `witness` option is now properly exposed on the Rest API for
segwit wallets (f04ad612b216becd35765c6e231f7820c7eee358).
- __deps__ - Node.js >=v7.6.0 is now a required dependency
(a0bd9680fed07c5eb37c227d160b0868f8adaf31).
- __build__ - The browser build has switched from browserify to webpack
(19f236f74072d473123d20282d2119f6d9130458).
- __bcoin__ - The codebase has been rewritten to use all ES6 and ES7 features
supported by node.js
(aa05bb5df79d9a3af53060a4c0c066226f6e9e4c,
78d62c73b82e1953999d1cf80c90ed2035d4996e,
e00472891df5934d8fc3aa63662f852816aa86b0,
c53f4cf89e46d9de8ab7f65430310567558fe03f,
8c7279518f5341a2482a79ac98f0574468541edc).
- __workers__ - The worker pool has been refactored to solve the dissonance
between the browser and node.js (27c60ce76e57af1695d78f912227d93194812c88).
- __net__ - DNS requests should now timeout sooner
(647b6909c6d527eb82f6d789c88a23b2f8a60126).
- __http__ - Satoshi values are now required for all JSON serialization, as
opposed to BTC strings which were used in the past
(2f51fd1c5066f194a5a52383f4dd45497b882706).
- __bin__ - The `--no-wallet` flag is now exposed for nodes who want to run
without a wallet.
- __chain__ - BIP91 support is now exposed via the `--bip91` option. The
`segwit` and `segsignal` rules will be automatically added when calling
`getblocktemplate`. To enable bip91 on an existing database `--force-flags`
must be passed. This will force bip91 to be enforced, but will not invalidate
any previous blocks (`bcoin cli reset [height]` may need to be used).
- __chain__ - BIP148 support is now exposed via the `--bip148` option. This
likewise must be enabled with `--force-flags` on existing chains. This has
the same potential "reset" implications as the `--bip91` option.
### Migrating
This release contains a few non-backward-compatible changes.
Bcoin now requires node.js >=7.6.0 due to the use of ES6/7 features, and for
the sake of more stability.
Bcoin's rest API now assumes satoshi values for in all JSON serialization.
__This is a breaking change__ for code that is not aware of it. All code which
hits the rest API must be updated to use only satoshi values as opposed to BTC
strings.
In other words, this:
``` json
{
"unconfirmed": "1.12",
"confirmed": "1.12"
}
```
Becomes this:
``` json
{
"unconfirmed": 112000000,
"confirmed": 112000000
}
```
## v1.0.0-beta.12
### Notable changes
- __networks__ - Fixed simnet wpkh prefix.
- __http__ - `wallet join` without wallet auth has been fixed for responses.
This was causing a hanging issue with the client.
## v1.0.0-beta.11
### Notable changes
- __networks__ - Simnet params have been fixed.
- __cli__ - Chain reset call has been fixed.
## v1.0.0-beta.10
### Notable changes
- __wallet/http__ - Create wallet route modified
(`POST /wallet/:id?` changed to `PUT /wallet/:id`).
- __wallet/http__ - Create account route modified
(`POST /wallet/:id/account/:account?` changed to
`PUT /wallet/:id/account/:account`).
- __wallet/http__ - `auth` socket.io event name for wallet auth changed to
`wallet auth`.
- __config__ - `payout-address` option was changed to `coinbase-address`.
- __node__ - Plugin system is now exposed.
See https://github.com/bcoin-org/bcoin/pull/156.
- __config__ - The internal API for the config object has been rewritten
and is now more reusable, particularly by node plugins.
- __http/rpc__ - Both the HTTPBase and RPCBase objects now allow "mounting" by
other rpc and http servers.
- __wallet__ - The wallet code has been completely removed from the node, and
now resides entirely within one module. The wallet is exposed only as a
plugin or a separate server.
- __rpc__ - `prioritisetransaction` is now exposed properly (`deltaFee`s are
now tracked on mempool entries).
- __rpc__ - Proper `id` and error codes are now implemented.
- __rpc__ - Several `getblocktemplate` improvements have been implemented for
more accuracy. e.g. `curtime` will now be updated each call.
- __mining__ - The internal miner API has been rewritten, and now mimics
stratum in a sense.
- __chain__ - Faster verification with checkpoints.
- __net__ - Fixed a potential block stalling issue.
- __net__ - Hardcoded seeds for main added. Makes
for better shipping with browsers.
- __wsproxy/proxysocket__ - DNS resolution is no longer exposed.
- __logger__ - Log files now trim to 20mb on boot.
- __hostlist__ - A persistent `hosts` file is now written by default.
## v1.0.0-beta.9
### Notable changes
- __mempool__ - Trimming now removes dependency chains by cumulative fee rate.
- __mempool__ - Cumulative descendant fees are now updated properly when
removing a transaction.
- __net__ - Preliminary upnp support for adding port mappings.
- __chain/mempool/miner__ - Various atomicity fixes and extra sanity checking.
- __pool/peer__ - Peer height is now tracked and exposed on the RPC as
`bestheight`.
## v1.0.0-beta.8
### Notable changes
- __mempool__ - Fixed critical fee estimator bug causing throwing in the
mempool.
## v1.0.0-beta.7
### Notable changes
- __http__ - Always display spent coins in tx routes (e.g. `/tx/[txid]`).
- __mempool__ - An on-disk mempool is now exposed via `--persistent-mempool`
(also makes fee data persistent).
- __chain__ - `chain.add` now takes a `flags` parameter to avoid POW and
non-contextual checks if necessary.
- __net__ - HostList is now potentially persistent with a `hostLocation` option.
- __net__ - Smarter stall behavior and timeouts.
## v1.0.0-beta.6
### Notable changes
- __http__ - Better bitcoind compatability for JSON-RPC.
## v1.0.0-beta.5
### Notable changes
- __miner__ - Better fee rate comparisons.
- __deps__ - Upgrade deps, fix build on arm and windows.
## v1.0.0-beta.4
### Notable changes
- __miner__ - Optimized TX sorting.
- __rpc__ - Improved getblocktemplate to provide more
accurate results to bitcoind.
## v1.0.0-beta.3
### Notable changes
- __miner__ - Improved fee rate sorting.
- __rpc__ - Fix incompatibilities in rpc api (getblocktemplate & submitblock).
## v1.0.0-beta.2
### Notable changes
- __pool__ - Increase max header chain failures to 500 (prevents the initial
sync from reverting to getblocks so frequently).
## v1.0.0-beta.1
### Notable changes
- __wsproxy__: Fixed proof of work handling in websocket proxy (43c491b).
- __chain__: Optimized MTP and network target calculations (1e07d1b).
- __wallet__: Implemented "smart" coin selection (304f0e7e).
- __protocol__: Increased default network fees for main (09c2357).
- __http__: Fix for handling `DELETE` http method (393dd5d).
- __miner__: Improved handling of default reserved size and sigops (f2964e0
and 7104e4c).
## v1.0.0-beta
### Notable changes
- Initial tagged release.

View File

@ -1,18 +0,0 @@
FROM alpine:edge
MAINTAINER Steven Bower <steven@purse.io>
RUN apk update && \
apk upgrade
RUN apk add nodejs bash unrar git python build-base make
RUN mkdir /code /data
ADD . /code
WORKDIR /code
RUN npm install --production
RUN npm uninstall node-gyp
RUN apk del unrar git python build-base make && \
rm /var/cache/apk/*
CMD ["node", "/code/bin/node"]

View File

@ -2,7 +2,7 @@ This software is licensed under the MIT License.
Copyright (c) 2014-2015, Fedor Indutny (https://github.com/indutny)
Copyright (c) 2014-2016, Christopher Jeffrey (https://github.com/chjj)
Copyright (c) 2014-2017, Christopher Jeffrey (https://github.com/chjj)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,11 +0,0 @@
all:
@npm run browserify
@npm run uglify
clean:
@npm run clean
test:
@npm test
.PHONY: all clean test

710
README.md
View File

@ -1,668 +1,67 @@
# BCoin
# Fcoin (Bcoin ported to Lcoin ported to Flo)
**BCoin** is a bitcoin library which can also act as an SPV node or a full
node. It is consensus aware and is up to date with the latest BIPs: it supports
segregated witness, versionbits, CSV, and compact block relay. It also has
preliminary support for bip151 (peer-to-peer encryption), bip150 (peer auth),
and bip114 (MAST). It runs in node.js, but it can also be browserified.
## Differences between this repo and [bcoin-org/bcoin](https://github.com/bcoin-org/bcoin)
Try it in the browser: http://bcoin.io/browser.html
* Based on latest bcoin repo, pick flo related commits from bcoin-org/fcoin, applied some modifications and fixed more tests.
* **May rebase and `push --force` frequently, to catch up with bcoin and make repo easy to maintain.**
## Features
## TODO
- Browserifiable
- Full blockchain validation
- Blockchain database
- Mempool/Miner
- Wallet system & wallet database (HD keys w/ bip44 derivation)
- Bitcoind-compatible JSON rpc api
- REST api
- Support for: Versionbits, CSV, Segwit, BIP70, BIP151, BIP152, BIP150,
and MAST.
- SPV mode
* [ ] Fix tests:
* [ ] block-test
* [ ] tx-test
## Fcoin
__NOTE__: The latest release of fcoin contains a non-backward compatible change
to the rest API. Please read the [changelog]'s "migrating" section for more
details.
---
**Fcoin** is an alternative implementation of the flo protocol, written in
node.js.
Bcoin, the parent project, is well tested and aware of all known consensus rules. It is currently
used in production as the consensus backend and wallet system for
[purse.io][purse].
## Uses
- Full Node
- SPV Node
- Wallet Backend (bip44 derivation)
- Mining Backend (getblocktemplate support)
- Layer 2 Backend (lightning)
- General Purpose Bitcoin Library
Try it in the browser: [https://bcoin.io/browser/](https://bcoin.io/browser/)
## Install
```
$ git clone git://github.com/bcoin-org/bcoin.git
$ cd bcoin
$ git clone git://github.com/oipwg/fcoin.git
$ cd fcoin
$ npm install
$ bcoin --fast
$ ./bin/fcoin
```
Note that the latest BCoin has not been published to NPM yet, as it is still
under fairly heavy development (which may involve changing serialization
formats for the database).
See the [Getting started][guide] guide for more in-depth installation
instructions, including verifying releases.
## Documentation
Read the docs here: http://bcoin.io/docs/
- General docs: [docs/](docs/README.md)
- Wallet and node API docs: https://bcoin.io/api-docs/
- Library API docs: https://bcoin.io/docs/
## Example Usage
## Support
- [CLI Usage](#cli-usage)
- [Creating a blockchain and mempool](#creating-a-blockchain-and-mempool)
- [Connecting to the P2P network](#connecting-to-the-p2p-network)
- [Doing an SPV sync](#doing-an-spv-sync)
- [High-level usage with the Node object](#high-level-usage-with-the-node-object)
- [Running the default full node](#running-the-default-full-node)
- [Running a full node in the browser](#running-a-full-node-in-the-browser)
### CLI Usage
``` bash
$ export BCOIN_API_KEY=your-api-key
# View the genesis block
$ bcoin cli block 0
# View the mempool
$ bcoin cli mempool
# View primary wallet
$ bcoin cli wallet get
# View transaction history
$ bcoin cli wallet history
# Send a transaction
$ bcoin cli wallet send [address] 0.01
# View balance
$ bcoin cli wallet balance
# Derive new address
$ bcoin cli wallet address
# Create a new account
$ bcoin cli wallet account create foo
# Send from account
$ bcoin cli wallet send [address] 0.01 --account=foo
```
#### RPC (bitcoind-like)
``` bash
$ bcoin rpc getblockchaininfo
$ bcoin rpc getwalletinfo
$ bcoin rpc getpeerinfo
$ bcoin rpc getbalance
$ bcoin rpc listtransactions
$ bcoin rpc sendtoaddress [address] 0.01
```
### Creating a blockchain and mempool
``` js
var bcoin = require('bcoin');
bcoin.set({
// Default network (so we can avoid passing
// the `network` option into every object below.
network: 'regtest',
// Enable the global worker pool
// for mining and transaction verification.
useWorkers: true
});
// Start up a blockchain, mempool, and miner using in-memory
// databases (stored in a red-black tree instead of on-disk).
var chain = new bcoin.chain({ db: 'memory' });
var mempool = new bcoin.mempool({ chain: chain });
var miner = new bcoin.miner({ chain: chain, mempool: mempool });
// Open the miner (initialize the databases, etc).
// Miner will implicitly call `open` on chain and mempool.
miner.open().then(function() {
// Create a block "attempt".
return miner.createBlock();
}).then(function(attempt) {
// Mine the block on the worker pool (use mine() for the master process)
return attempt.mineAsync();
}).then(function(block) {
// Add the block to the chain
console.log('Adding %s to the blockchain.', block.rhash);
console.log(block);
return chain.add(block);
}).then(function() {
console.log('Added block!');
});
```
### Connecting to the P2P network
``` js
var bcoin = require('bcoin').set('main');
// Create a blockchain and store it in leveldb.
// `db` also accepts `rocksdb` and `lmdb`.
var prefix = process.env.HOME + '/my-bcoin-environment';
var chain = new bcoin.chain({ db: 'leveldb', location: prefix + '/chain' });
var mempool = new bcoin.mempool({ chain: chain });
// Create a network pool of peers with a limit of 8 peers.
var pool = new bcoin.pool({ chain: chain, mempool: mempool, maxPeers: 8 });
// Open the pool (implicitly opens mempool and chain).
pool.open().then(function() {
// Connect, start retrieving and relaying txs
pool.connect();
// Start the blockchain sync.
pool.startSync();
// Watch the action
chain.on('block', function(block) {
console.log('Connected block to blockchain:');
console.log(block);
});
mempool.on('tx', function(tx) {
console.log('Added tx to mempool:');
console.log(tx);
});
pool.on('tx', function(tx) {
console.log('Saw transaction:');
console.log(tx.rhash);
});
});
// Start up a segnet4 sync in-memory
// while we're at it (because we can).
var tchain = new bcoin.chain({
network: 'segnet4',
db: 'memory'
});
var tmempool = new bcoin.mempool({
network: 'segnet4',
chain: tchain
});
var tpool = new bcoin.pool({
network: 'segnet4',
chain: tchain,
mempool: tmempool,
size: 8
});
tpool.open().then(function() {
// Connect, start retrieving and relaying txs
tpool.connect();
// Start the blockchain sync.
tpool.startSync();
tchain.on('block', function(block) {
console.log('Added segnet4 block:');
console.log(block);
});
tmempool.on('tx', function(tx) {
console.log('Added segnet4 tx to mempool:');
console.log(tx);
});
tpool.on('tx', function(tx) {
console.log('Saw segnet4 transaction:');
console.log(tx);
});
});
```
### Doing an SPV sync
``` js
var bcoin = require('bcoin').set('testnet');
// SPV chains only store the chain headers.
var chain = new bcoin.chain({
db: 'leveldb',
location: process.env.HOME + '/spvchain',
spv: true
});
var pool = new bcoin.pool({
chain: chain,
spv: true,
maxPeers: 8
});
var walletdb = new bcoin.walletdb({ db: 'memory' });
pool.open().then(function() {
return walletdb.open();
}).then(function() {
return walletdb.create();
}).then(function(wallet) {
console.log('Created wallet with address %s', wallet.getAddress('base58'));
// Add our address to the spv filter.
pool.watchAddress(wallet.getAddress());
// Connect, start retrieving and relaying txs
pool.connect();
// Start the blockchain sync.
pool.startSync();
pool.on('tx', function(tx) {
wallet.addTX(tx);
});
wallet.on('balance', function(balance) {
console.log('Balance updated.');
console.log(bcoin.utils.btc(balance.unconfirmed));
});
});
```
### High-level usage with the Node object
``` js
var bcoin = require('bcoin').set('main');
var node = bcoin.fullnode({
prune: false,
useCheckpoints: true,
debug: true,
// Primary wallet passphrase
passsphrase: 'node',
logLevel: 'info'
});
// We get a lot of errors sometimes,
// usually from peers hanging up on us.
// Just ignore them for now.
node.on('error', function(err) {
;
});
// Start the node
node.open().then(function() {
// Create a new wallet (or get an existing one with the same ID)
var options = {
id: 'mywallet',
passphrase: 'foo',
witness: false,
type: 'pubkeyhash'
};
return node.walletdb.create(options);
}).then(function(wallet) {
console.log('Created wallet with address: %s', wallet.getAddress('base58'));
// Start syncing the blockchain
node.startSync();
// Wait for balance and send it to a new address.
wallet.once('balance', function(balance) {
// Create a transaction, fill
// it with coins, and sign it.
var options = {
subtractFee: true,
outputs: [{
address: newReceiving,
value: balance.total
}]
};
wallet.createTX(options).then(function(tx) {
// Need to pass our passphrase back in to sign!
return wallet.sign(tx, 'foo');
}).then(function(tx) {
console.log('sending tx:');
console.log(tx);
return node.sendTX(tx);
}).then(function() {
console.log('tx sent!');
});
});
});
node.chain.on('block', function(block) {
;
});
node.mempool.on('tx', function(tx) {
;
});
node.chain.on('full', function() {
node.mempool.getHistory().then(console.log);
});
```
### Running the default full node
``` bash
$ bcoin --fast
```
`--fast` will enable checkpoints, coin cache, and getheaders.
Your config file should reside in `~/.bcoin/bcoin.conf`. See `etc/sample.conf`
for an example.
### Running a full node in the browser
``` bash
$ cd ~/bcoin
$ make # Browserify bcoin
$ node browser/server.js 8080 # Start up a simple webserver and websocket->tcp bridge
$ chromium http://localhost:8080
```
You should see something like this: http://i.imgur.com/0pWySyZ.png
This is a simple proof-of-concept. It's not a pretty interface. I hope to see
others doing something far more interesting. A browser extension may be better:
the chrome extension API exposes raw TCP access.
## TX creation
Normal transactions in bcoin are immutable. The primary TX object contains a
bunch of consensus and policy checking methods. A lot of it is for internal use
and pretty boring for users of this library.
BCoin also offers a mutable transaction object (MTX). Mutable transactions
inherit from the TX object, but can also be signed and modified.
``` js
var bcoin = require('bcoin');
var assert = require('assert');
var constants = bcoin.constants;
// Create an HD master keypair with a mnemonic.
var master = bcoin.hd.fromMnemonic();
// Derive another private hd key (we don't want to use our master key!).
var key = master.derive('m/44/0/0/0/0');
// Create a "keyring" object. A keyring object is basically a key manager that
// is also able to tell you info such as: your redeem script, your scripthash,
// your program hash, your pubkey hash, your scripthash program hash, etc.
// In this case, we'll make it simple and just add one key for a
// pubkeyhash address. `getPublicKey` returns the non-hd public key.
var keyring = new bcoin.keyring(key.privateKey);
console.log(keyring.getAddress());
// Create a fake coinbase for our funding.
var cb = new bcoin.mtx();
// Add a typical coinbase input
cb.addInput({
prevout: {
hash: constants.NULL_HASH,
index: 0
},
script: new bcoin.script(),
sequence: 0xffffffff
});
// Send 50,000 satoshis to ourself.
cb.addOutput({
address: keyring.getAddress(),
value: 50000
});
// Create our redeeming transaction.
var tx = new bcoin.mtx();
// Add output 0 from our coinbase.
tx.addInput(cb, 0);
// Send 10,000 satoshis to ourself,
// creating a fee of 40,000 satoshis.
tx.addOutput({
address: keyring.getAddress(),
value: 10000
});
// Sign input 0: pass in our keyring.
tx.sign(keyring);
// Commit our transaction and make it immutable.
// This turns it from an MTX into a TX object.
tx = tx.toTX();
// The transaction should now verify.
assert(tx.verify());
assert(tx.getFee() === 40000);
```
### Coin Selection
The above method works, but is pretty contrived. In reality, you probably
wouldn't select inputs and calculate the fee by hand. You would want a
change output added. BCoin has a nice method of dealing with this.
Let's try it more realistically:
``` js
var bcoin = require('bcoin');
var assert = require('assert');
var constants = bcoin.constants;
var master = bcoin.hd.fromMnemonic();
var key = master.derive('m/44/0/0/0/0');
var keyring = new bcoin.keyring(key.privateKey);
var cb = new bcoin.mtx();
cb.addInput({
prevout: {
hash: constants.NULL_HASH,
index: 0
},
script: new bcoin.script(),
sequence: 0xffffffff
});
// Send 50,000 satoshis to ourselves.
cb.addOutput({
address: keyring.getAddress(),
value: 50000
});
// Our available coins.
var coins = [];
// Convert the coinbase output to a Coin
// object and add it to our available coins.
// In reality you might get these coins from a wallet.
var coin = bcoin.coin.fromTX(cb, 0);
coins.push(coin);
// Create our redeeming transaction.
var tx = new bcoin.mtx();
// Send 10,000 satoshis to ourself.
tx.addOutput({
address: keyring.getAddress(),
value: 10000
});
// Now that we've created the output, we can do some coin selection (the output
// must be added first so we know how much money is needed and also so we can
// accurately estimate the size for fee calculation).
// Select coins from our array and add inputs.
// Calculate fee and add a change output.
tx.fund(coins, {
// Use a rate of 10,000 satoshis per kb.
// With the `fullnode` object, you can
// use the fee estimator for this instead
// of blindly guessing.
rate: 10000,
// Send the change back to ourselves.
changeAddress: keyring.getAddress()
});
// Sign input 0
tx.sign(keyring);
// Commit our transaction and make it immutable.
// This turns it from an MTX into a TX.
tx = tx.toTX();
// The transaction should now verify.
assert(tx.verify());
```
## Scripting
Scripts are array-like objects with some helper functions.
``` js
var bcoin = require('bcoin');
var assert = require('assert');
var BN = bcoin.bn;
var opcodes = bcoin.script.opcodes;
var output = new bcoin.script();
output.push(opcodes.OP_DROP);
output.push(opcodes.OP_ADD);
output.push(new BN(7));
output.push(opcodes.OP_NUMEQUAL);
// Compile the script to its binary representation
// (you must do this if you change something!).
output.compile();
assert(output.getSmall(2) === 7); // compiled as OP_7
var input = new bcoin.script();
input.set(0, 'hello world'); // add some metadata
input.push(new BN(2));
input.push(new BN(5));
input.push(input.shift());
assert(input.getString(2) === 'hello world');
input.compile();
// A stack is another array-like object which contains
// only Buffers (whereas scripts contain Opcode objects).
var stack = new bcoin.stack();
input.execute(stack);
output.execute(stack);
// Verify the script was successful in its execution:
assert(stack.length === 1);
assert(bcoin.script.bool(stack.pop()) === true);
```
Using a witness would be similar, but witnesses do not get executed, they
simply _become_ the stack. The witness object itself is very similar to the
Stack object (an array-like object containing Buffers).
``` js
var witness = new bcoin.witness();
witness.push(new BN(2));
witness.push(new BN(5));
witness.push('hello world');
var stack = witness.toStack();
output.execute(stack);
```
## Wallet usage
BCoin maintains a wallet database which contains every wallet. Wallets are _not
usable_ without also using a wallet database. For testing, the wallet database
can be in-memory, but it must be there.
Wallets in bcoin use bip44. They also originally supported bip45 for multisig,
but support was removed to reduce code complexity, and also because bip45
doesn't seem to add any benefit in practice.
The wallet database can contain many different wallets, with many different
accounts, with many different addresses for each account. BCoin should
theoretically be able to scale to hundreds of thousands of
wallets/accounts/addresses.
Each account can be of a different type. You could have a pubkeyhash account,
as well as a multisig account, a witness pubkeyhash account, etc.
Note that accounts should not be accessed directly from the public API. They do
not have locks which can lead to race conditions during writes.
TODO
## HTTP API & Websocket Events
TODO
## Design
BCoin is thoroughly event driven. It has a fullnode object, but BCoin was
specifically designed so the mempool, blockchain, p2p pool, and wallet database
could all be used separately. All the fullnode object does is tie these things
together. It's essentially a huge proxying of events. The general communication
between these things looks something like this:
```
pool -> block event -> chain
pool -> tx event -> mempool
chain -> block event -> mempool/miner
chain -> tx event -> walletdb
chain -> reorg event -> walletdb/mempool/miner
mempool -> tx event -> walletdb/miner
miner -> block event -> chain
walletdb -> tx event -> websocket server
websocket server -> tx event -> websocket client
http client -> tx -> http server -> mempool
```
Not only does the loose coupling make testing easier, it ensures people can
utilize bcoin for many use cases.
### Performance
Non-javscript people reading this may think using javascript isn't a wise
descision.
#### Javascript
Javascript is inherently slow due to how dynamic it is, but modern JITs have
solved this issue using very clever optimization and dynamic recompilation
techniques. v8 in some cases can [rival the speed of C++][v8] if the code is
well-written.
#### Concurrency
BCoin runs in node.js, so the javascript code is limited to one thread. We
solve this limitation by spinning up persistent worker processes for
transaction verification (webworkers when in the browser). This ensures the
blockchain and mempool do not block the master process very much. It also means
transaction verification can be parallelized.
Strangely enough, workers are faster in the browser than they are in node since
you are allowed to share memory between threads using the transferrable api
(Uint8Arrays can be "transferred" to another thread). In node, you have to pipe
data to another process.
But of course, there is a benefit to having a multi-process architecture: the
worker processes can die on their own without disturbing the master process.
BCoin uses [secp256k1-node][secp256k1-node] for ecdsa verification, which is a
node.js binding to Pieter Wuille's blazingly fast [libsecp256k1][libsecp256k1]
library.
In the browser, bcoin will use [elliptic][elliptic], the fastest javascript
ecdsa implementation. It will obviously never beat C and hand-optimized
assembly, but it's still usable.
#### Benefits
The real feature of javascript is that your code will run almost anywhere. With
bcoin, we now have a full node that will run on almost any browser, on laptops,
on servers, on smartphones, on most devices you can imagine, even by simply
visting a webpage.
Join us on [freenode][freenode] in the [#bcoin][irc] channel.
## Disclaimer
BCoin does not guarantee you against theft or lost funds due to bugs, mishaps,
Fcoin does not guarantee you against theft or lost funds due to bugs, mishaps,
or your own incompetence. You and you alone are responsible for securing your
money.
@ -674,13 +73,18 @@ all code is your original work. `</legalese>`
## License
Copyright (c) 2014-2015, Fedor Indutny (MIT License).
Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
- Copyright (c) 2014-2015, Fedor Indutny (MIT License).
- Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
See LICENSE for more info.
[v8]: https://www.youtube.com/watch?v=UJPdhx5zTaw
[libsecp256k1]: https://github.com/bitcoin-core/secp256k1
[secp256k1-node]: https://github.com/cryptocoinjs/secp256k1-node
[elliptic]: https://github.com/indutny/elliptic
[purse]: https://purse.io
[guide]: docs/getting-started.md
[freenode]: https://freenode.net/
[irc]: irc://irc.freenode.net/bcoin
[changelog]: CHANGELOG.md
[coverage-status-img]: https://codecov.io/gh/bcoin-org/bcoin/badge.svg?branch=master
[coverage-status-url]: https://codecov.io/gh/bcoin-org/bcoin?branch=master
[circleci-status-img]: https://circleci.com/gh/bcoin-org/bcoin/tree/master.svg?style=shield
[circleci-status-url]: https://circleci.com/gh/bcoin-org/bcoin/tree/master

20
TODO.md
View File

@ -1,20 +0,0 @@
# Todo
Todo before release. Excuse the mess.
- prioritization for mining.
- switch entirely to secp256k1-node. note that payment-protocol still directly
requires elliptic.
- walletdb removes coins from txs - potentially have it clone the tx (slower).
- refactor and add all network packets.
- rename keyring object.
- browser-side dsa signing/verify for payment-protocol.
- do not output bitcoin strings (utils.btc) on the api layer. use satoshis
instead.
- implement jl's latest MAST.
- rewrite readme. move examples to wiki.
- fix docs.
- implement rpc calls:
- listaddressgroupings
- importaddress (maybe)
- man pages

27
bench/bech32.js Normal file
View File

@ -0,0 +1,27 @@
'use strict';
const Address = require('../lib/primitives/address');
const random = require('bcrypto/lib/random');
const bench = require('./bench');
const addrs = [];
{
const end = bench('serialize');
for (let i = 0; i < 100000; i++) {
const addr = Address.fromProgram(0, random.randomBytes(20));
addrs.push(addr.toBech32());
}
end(100000);
}
{
const end = bench('parse');
for (let i = 0; i < 100000; i++) {
const b32 = addrs[i];
const addr = Address.fromBech32(b32);
addrs[i] = addr;
}
end(100000);
}
console.error(addrs[0][0]);

View File

@ -1,11 +1,11 @@
'use strict';
module.exports = function bench(name) {
var start = process.hrtime();
const start = process.hrtime();
return function end(ops) {
var elapsed = process.hrtime(start);
var time = elapsed[0] + elapsed[1] / 1e9;
var rate = ops / time;
const elapsed = process.hrtime(start);
const time = elapsed[0] + elapsed[1] / 1e9;
const rate = ops / time;
console.log('%s: ops=%d, time=%d, rate=%s',
name, ops, time, rate.toFixed(5));

476
bench/blockstore.js Normal file
View File

@ -0,0 +1,476 @@
/*!
* bench/blockstore.js - benchmark blockstore for bcoin
*
* This can be run to benchmark the performance of the blockstore
* module for writing, reading and pruning block data. Results are
* written to stdout as JSON or formated bench results.
*
* Usage:
* node ./blockstore.js [--maxfile=<bytes>] [--total=<bytes>]
* [--location=<path>] [--store=<name>]
* [--output=<name>] [--unsafe]
*
* Options:
* - `maxfile` The maximum file size (applies to "file" store).
* - `total` The total number of block bytes to write.
* - `location` The location to store block data.
* - `store` This can be "file" or "level".
* - `output` This can be "json", "bench" or "benchjson".
* - `unsafe` This will allocate block data directly from memory
* instead of random, it is faster.
*
* Copyright (c) 2019, Braydon Fuller (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
process.title = 'blockstore-bench';
const {isAbsolute} = require('path');
const {mkdirp} = require('bfile');
const random = require('bcrypto/lib/random');
const {BufferMap} = require('buffer-map');
const {
FileBlockStore,
LevelBlockStore
} = require('../lib/blockstore');
const config = {
'maxfile': {
value: true,
parse: a => parseInt(a),
valid: a => Number.isSafeInteger(a),
fallback: 128 * 1024 * 1024
},
'total': {
value: true,
parse: a => parseInt(a),
valid: a => Number.isSafeInteger(a),
fallback: 3 * 1024 * 1024 * 1024
},
'location': {
value: true,
valid: a => isAbsolute(a),
fallback: '/tmp/bcoin-bench-blockstore'
},
'store': {
value: true,
valid: a => (a === 'file' || a === 'level'),
fallback: 'file'
},
'output': {
value: true,
valid: a => (a === 'json' || a === 'bench' || a === 'benchjson'),
fallback: 'bench'
},
'unsafe': {
value: false,
valid: a => (a === true || a === false),
fallback: false
}
};
/**
* These block sizes were generated from bitcoin mainnet blocks by putting
* sizes into bins of 256 ^ (2 * n) as the upper bound and calculating
* the percentage of each and then distributing to roughly match the
* percentage of the following:
*
* |-------------|------------|
* | percentage | bytes |
* |-------------|------------|
* | 23.4055 | 1048576 |
* | 15.5338 | 256 |
* | 12.2182 | 262144 |
* | 8.4079 | 524288 |
* | 7.1289 | 131072 |
* | 6.9197 | 65536 |
* | 6.7073 | 2097152 |
* | 4.6753 | 32768 |
* | 3.9695 | 4096 |
* | 3.3885 | 16384 |
* | 2.6526 | 8192 |
* | 2.0048 | 512 |
* | 1.587 | 1024 |
* | 1.3976 | 2048 |
* | 0.0032 | 4194304 |
* |-------------|------------|
*/
const distribution = [
1048576, 256, 256, 524288, 262144, 256, 131072, 256, 524288, 256, 131072,
1048576, 262144, 1048576, 2097152, 256, 1048576, 65536, 256, 262144, 8192,
32768, 32768, 256, 1048576, 524288, 2097152, 1024, 1048576, 1048576, 131072,
131072, 262144, 512, 1048576, 1048576, 1024, 1048576, 1048576, 262144, 2048,
262144, 256, 1048576, 131072, 4096, 524288, 65536, 4096, 65536, 131072,
2097152, 2097152, 2097152, 256, 524288, 4096, 262144, 65536, 65536, 262144,
16384, 1048576, 32768, 262144, 1048576, 256, 131072, 1048576, 1048576,
1048576, 8192, 1048576, 256, 16384, 1048576, 256, 256, 524288, 256, 32768,
16384, 32768, 1048576, 512, 4096, 1048576, 1048576, 524288, 65536, 2097152,
512, 262144, 8192, 524288, 131072, 65536, 16384, 2048, 262144, 1048576,
1048576, 256, 524288, 262144, 4194304, 262144, 2097152
];
(async () => {
let settings = null;
try {
settings = processArgs(process.argv, config);
} catch (err) {
console.log(err.message);
process.exit(1);
}
await mkdirp(settings.location);
let store = null;
let output = null;
if (settings.store === 'file') {
store = new FileBlockStore({
location: settings.location,
maxFileLength: settings.maxfile
});
} else if (settings.store === 'level') {
store = new LevelBlockStore({
location: settings.location
});
}
if (settings.output === 'bench') {
output = new BenchOutput();
} else if (settings.output === 'benchjson') {
output = new BenchJSONOutput();
} else if (settings.output === 'json') {
output = new JSONOutput();
}
await store.open();
const hashes = [];
const lengths = new BufferMap();
output.start();
// 1. Write data to the block store
let written = 0;
async function write() {
for (const length of distribution) {
const hash = random.randomBytes(32);
let raw = null;
if (settings.unsafe) {
raw = Buffer.allocUnsafe(length);
} else {
raw = random.randomBytes(length);
}
const start = process.hrtime();
await store.write(hash, raw);
const elapsed = process.hrtime(start);
hashes.push(hash);
lengths.set(hash, length);
written += length;
output.result('write', start, elapsed, length);
if (written >= settings.total)
break;
}
}
while (written < settings.total)
await write();
// 2. Read data from the block store
for (const hash of hashes) {
const start = process.hrtime();
const raw = await store.read(hash);
const elapsed = process.hrtime(start);
output.result('read', start, elapsed, raw.length);
}
// 3. Read data not in the order it was written (random)
for (let i = 0; i < hashes.length; i++) {
const rand = random.randomInt() / 0xffffffff * (hashes.length - 1) | 0;
const hash = hashes[rand];
const start = process.hrtime();
const raw = await store.read(hash);
const elapsed = process.hrtime(start);
output.result('randomread', start, elapsed, raw.length);
}
// 4. Prune data from the block store
for (const hash of hashes) {
const start = process.hrtime();
await store.prune(hash);
const elapsed = process.hrtime(start);
const length = lengths.get(hash);
output.result('prune', start, elapsed, length);
}
output.end();
await store.close();
})().catch((err) => {
console.error(err);
process.exit(1);
});
class JSONOutput {
constructor() {
this.time = process.hrtime();
this.index = 0;
}
start() {
process.stdout.write('[');
}
result(type, start, elapsed, length) {
if (this.index > 0)
process.stdout.write(',');
const since = [start[0] - this.time[0], start[1] - this.time[1]];
const smicro = hrToMicro(since);
const emicro = hrToMicro(elapsed);
process.stdout.write(`{"type":"${type}","start":${smicro},`);
process.stdout.write(`"elapsed":${emicro},"length":${length},`);
process.stdout.write(`"index":${this.index}}`);
this.index += 1;
}
end() {
process.stdout.write(']');
}
}
class BenchOutput {
constructor() {
this.time = process.hrtime();
this.index = 0;
this.results = {};
this.interval = null;
this.stdout = process.stdout;
}
start() {
this.stdout.write('Starting benchmark...\n');
this.interval = setInterval(() => {
this.stdout.write(`Operation count=${this.index}\n`);
}, 5000);
}
result(type, start, elapsed, length) {
const micro = hrToMicro(elapsed);
if (!this.results[type])
this.results[type] = {};
if (!this.results[type][length])
this.results[type][length] = [];
this.results[type][length].push(micro);
this.index += 1;
}
end() {
clearInterval(this.interval);
this.stdout.write('Benchmark finished.\n');
function format(value) {
if (typeof value === 'number')
value = value.toFixed(2);
if (typeof value !== 'string')
value = value.toString();
while (value.length < 15)
value = `${value} `;
return value;
}
function title(value) {
if (typeof value !== 'string')
value = value.toString();
while (value.length < 85)
value = ` ${value} `;
if (value.length > 85)
value = value.slice(0, 85);
return value;
}
for (const type in this.results) {
this.stdout.write('\n');
this.stdout.write(`${title(type)}\n`);
this.stdout.write(`${'='.repeat(85)}\n`);
this.stdout.write(`${format('length')}`);
this.stdout.write(`${format('operations')}`);
this.stdout.write(`${format('min')}`);
this.stdout.write(`${format('max')}`);
this.stdout.write(`${format('average')}`);
this.stdout.write(`${format('median')}`);
this.stdout.write('\n');
this.stdout.write(`${'-'.repeat(85)}\n`);
for (const length in this.results[type]) {
const cal = calculate(this.results[type][length]);
this.stdout.write(`${format(length)}`);
this.stdout.write(`${format(cal.operations.toString())}`);
this.stdout.write(`${format(cal.min)}`);
this.stdout.write(`${format(cal.max)}`);
this.stdout.write(`${format(cal.average)}`);
this.stdout.write(`${format(cal.median)}`);
this.stdout.write('\n');
}
this.stdout.write('\n');
}
this.stdout.write('\n');
}
}
class BenchJSONOutput {
constructor() {
this.time = null;
this.results = {};
this.stdout = process.stdout;
}
start() {
this.time = process.hrtime();
}
result(type, start, elapsed, length) {
const micro = hrToMicro(elapsed);
if (!this.results[type])
this.results[type] = {};
if (!this.results[type][length])
this.results[type][length] = [];
this.results[type][length].push(micro);
}
end() {
const report = {
summary: [],
time: hrToMicro(process.hrtime(this.time)),
elapsed: 0
};
for (const type in this.results) {
for (const length in this.results[type]) {
const cal = calculate(this.results[type][length]);
report.elapsed += cal.total;
report.summary.push({
type: type,
length: length,
operations: cal.operations,
min: cal.min,
max: cal.max,
average: cal.average,
median: cal.median
});
}
}
this.stdout.write(JSON.stringify(report, null, 2));
this.stdout.write('\n');
}
}
function hrToMicro(time) {
return (time[0] * 1000000) + (time[1] / 1000);
}
function calculate(times) {
times.sort((a, b) => a - b);
let min = Infinity;
let max = 0;
let total = 0;
for (const micro of times) {
if (micro < min)
min = micro;
if (micro > max)
max = micro;
total += micro;
}
const average = total / times.length;
const median = times[times.length / 2 | 0];
const operations = times.length;
return {
total,
operations,
min,
max,
average,
median
};
}
function processArgs(argv, config) {
const args = {};
for (const key in config)
args[key] = config[key].fallback;
for (let i = 2; i < process.argv.length; i++) {
const arg = process.argv[i];
const match = arg.match(/^(\-){1,2}([a-z]+)(\=)?(.*)?$/);
if (!match) {
throw new Error(`Unexpected argument: ${arg}.`);
} else {
const key = match[2];
let value = match[4];
if (!config[key])
throw new Error(`Invalid argument: ${arg}.`);
if (config[key].value && !value) {
value = process.argv[i + 1];
i++;
} else if (!config[key].value && !value) {
value = true;
} else if (!config[key].value && value) {
throw new Error(`Unexpected value: ${key}=${value}`);
}
if (config[key].parse)
value = config[key].parse(value);
if (value)
args[key] = value;
if (!config[key].valid(args[key]))
throw new Error(`Invalid value: ${key}=${value}`);
}
}
return args;
}

33
bench/buffer.js Normal file
View File

@ -0,0 +1,33 @@
'use strict';
const BufferWriter = require('bufio').BufferWriter;
const StaticWriter = require('bufio').StaticWriter;
const common = require('../test/util/common');
const bench = require('./bench');
const tx5 = common.readTX('tx5');
{
const [tx] = tx5.getTX();
const end = bench('serialize (static-writer)');
for (let i = 0; i < 10000; i++) {
tx.refresh();
const {size} = tx.getWitnessSizes();
const bw = new StaticWriter(size);
tx.toWriter(bw);
bw.render();
}
end(10000);
}
{
const [tx] = tx5.getTX();
const end = bench('serialize (buffer-writer)');
for (let i = 0; i < 10000; i++) {
tx.refresh();
const bw = new BufferWriter();
tx.toWriter(bw);
bw.render();
}
end(10000);
}

View File

@ -1,45 +0,0 @@
'use strict';
var chachapoly = require('../lib/crypto/chachapoly');
var bench = require('./bench');
console.log('note: rate measured in kb/s');
var chacha = new chachapoly.ChaCha20();
var iv = new Buffer('0102030405060708', 'hex');
chacha.init(iv, 0);
var data = new Buffer(32);
for (var i = 0; i < 32; i++)
data[i] = i;
var end = bench('encrypt');
for (var i = 0; i < 1000000; i++)
chacha.encrypt(data);
end(i * 32 / 1024);
var poly = new chachapoly.Poly1305();
var key = new Buffer('000102030405060708090a0b0c0d0e0f', 'hex');
poly.init(key);
var data = new Buffer(32);
for (var i = 0; i < 32; i++)
data[i] = i & 0xff;
var end = bench('update');
for (var i = 0; i < 1000000; i++)
poly.update(data);
end(i * 32 / 1024);
var end = bench('finish');
for (var i = 0; i < 1000000; i++) {
poly.init(key);
poly.update(data);
poly.finish();
}
end(i * 32 / 1024);
// For reference:
var crypto = require('../lib/crypto/crypto');
var end = bench('sha256');
for (var i = 0; i < 1000000; i++)
crypto.hash256(data);
end(i * 32 / 1024);

View File

@ -1,42 +0,0 @@
'use strict';
var BN = require('bn.js');
var constants = require('../lib/protocol/constants');
var utils = require('../lib/utils/utils');
var assert = require('assert');
var scriptTypes = constants.scriptTypes;
var bench = require('./bench');
var fs = require('fs');
var Coins = require('../lib/chain/coins');
var TX = require('../lib/primitives/tx');
var wtx = fs.readFileSync(__dirname + '/../test/data/wtx.hex', 'utf8');
wtx = tx.fromRaw(wtx.trim(), 'hex');
var coins = Coins.fromTX(wtx);
var raw;
var end = bench('serialize');
for (var i = 0; i < 10000; i++)
raw = coins.toRaw();
end(i);
var end = bench('parse');
for (var i = 0; i < 10000; i++)
Coins.fromRaw(raw);
end(i);
var end = bench('parse-single');
var hash = wtx.hash('hex');
for (var i = 0; i < 10000; i++)
Coins.parseCoin(raw, hash, 5);
end(i);
var coins = Coins.fromRaw(raw);
var end = bench('get');
var j;
for (var i = 0; i < 10000; i++)
for (var j = 0; j < coins.outputs.length; j++)
coins.get(j);
end(i * coins.outputs.length);

34
bench/coins.js Normal file
View File

@ -0,0 +1,34 @@
'use strict';
const CoinView = require('../lib/coins/coinview');
const BufferReader = require('bufio').BufferReader;
const StaticWriter = require('bufio').StaticWriter;
const common = require('../test/util/common');
const bench = require('./bench');
const [tx, view] = common.readTX('tx3').getTX();
{
const end = bench('serialize');
for (let i = 0; i < 10000000; i++) {
const bw = new StaticWriter(view.getSize(tx));
view.toWriter(bw, tx).render();
}
end(10000000);
}
{
const bw = new StaticWriter(view.getSize(tx));
const raw = view.toWriter(bw, tx).render();
const end = bench('parse');
for (let i = 0; i < 10000000; i++) {
const br = new BufferReader(raw);
CoinView.fromReader(br, tx);
}
end(10000000);
}

17
bench/hexstring.js Normal file
View File

@ -0,0 +1,17 @@
'use strict';
const random = require('bcrypto/lib/random');
const util = require('../lib/utils/util');
const bench = require('./bench');
const hashes = [];
for (let i = 0; i < 100000; i++)
hashes.push(random.randomBytes(32));
{
const end = bench('hexstring');
for (let i = 0; i < hashes.length; i++)
util.fromRev(util.revHex(hashes[i]));
end(100000);
}

22
bench/merkle.js Normal file
View File

@ -0,0 +1,22 @@
'use strict';
const assert = require('assert');
const merkle = require('bcrypto/lib/merkle');
const random = require('bcrypto/lib/random');
const SHA256 = require('bcrypto/lib/sha256');
const bench = require('./bench');
const leaves = [];
for (let i = 0; i < 3000; i++)
leaves.push(random.randomBytes(32));
{
const end = bench('tree');
for (let i = 0; i < 1000; i++) {
const [n, m] = merkle.createTree(SHA256, leaves.slice());
assert(n);
assert(!m);
}
end(1000);
}

View File

@ -1,19 +1,20 @@
'use strict';
var BN = require('bn.js');
var bcoin = require('../').set('main');
var constants = bcoin.constants;
var utils = bcoin.utils;
var assert = require('assert');
var bench = require('./bench');
var Mnemonic = bcoin.hd.Mnemonic;
const assert = require('assert');
const bench = require('./bench');
const HD = require('../lib/hd');
const Mnemonic = require('../lib/hd/mnemonic');
var key = bcoin.hd.fromMnemonic();
var phrase = key.mnemonic.getPhrase();
const mnemonic = new Mnemonic();
HD.fromMnemonic(mnemonic);
assert.equal(Mnemonic.fromPhrase(phrase).getPhrase(), phrase);
const phrase = mnemonic.getPhrase();
var end = bench('fromPhrase');
for (var i = 0; i < 10000; i++)
Mnemonic.fromPhrase(phrase);
end(i);
assert.strictEqual(Mnemonic.fromPhrase(phrase).getPhrase(), phrase);
{
const end = bench('fromPhrase');
for (let i = 0; i < 10000; i++)
Mnemonic.fromPhrase(phrase);
end(10000);
}

View File

@ -1,43 +1,17 @@
'use strict';
var BN = require('bn.js');
var bcoin = require('../').set('main');
var constants = bcoin.constants;
var utils = bcoin.utils;
var assert = require('assert');
var scriptTypes = constants.scriptTypes;
var opcodes = constants.opcodes;
var bench = require('./bench');
var fs = require('fs');
var Script = bcoin.script;
const random = require('bcrypto/lib/random');
const Script = require('../lib/script/script');
const bench = require('./bench');
bcoin.cache();
const hashes = [];
Script.prototype.fromPubkeyhashOld = function fromScripthash(hash) {
assert(Buffer.isBuffer(hash) && hash.length === 20);
this.push(opcodes.OP_DUP);
this.push(opcodes.OP_HASH160);
this.push(hash);
this.push(opcodes.OP_EQUALVERIFY);
this.push(opcodes.OP_CHECKSIG);
this.compile();
return this;
};
for (let i = 0; i < 100000; i++)
hashes.push(random.randomBytes(20));
Script.fromPubkeyhashOld = function fromScripthash(hash) {
return new Script().fromPubkeyhashOld(hash);
};
var hashes = [];
for (var i = 0; i < 100000; i++)
hashes.push(bcoin.crypto.randomBytes(20));
var end = bench('old');
for (var i = 0; i < hashes.length; i++)
Script.fromPubkeyhashOld(hashes[i]);
end(i);
var end = bench('hash');
for (var i = 0; i < hashes.length; i++)
Script.fromPubkeyhash(hashes[i]);
end(i);
{
const end = bench('hash');
for (let i = 0; i < hashes.length; i++)
Script.fromPubkeyhash(hashes[i]);
end(100000);
}

View File

@ -1,131 +1,200 @@
'use strict';
var BN = require('bn.js');
var bcoin = require('../').set('main');
var constants = bcoin.constants;
var utils = bcoin.utils;
var assert = require('assert');
var scriptTypes = constants.scriptTypes;
var bench = require('./bench');
var fs = require('fs');
const random = require('bcrypto/lib/random');
const Address = require('../lib/primitives/address');
const TX = require('../lib/primitives/tx');
const Script = require('../lib/script/script');
const MTX = require('../lib/primitives/mtx');
const consensus = require('../lib/protocol/consensus');
const common = require('../test/util/common');
const bench = require('./bench');
bcoin.cache();
const tx3 = common.readTX('tx3');
const tx5 = common.readTX('tx5');
const tx10 = common.readTX('tx10');
var block = bcoin.block.fromJSON(require('../test/data/block300025.json'));
var btx = block.txs[397];
{
const raw = tx5.getRaw();
const end = bench('parse');
var tx1 = parseTX('../test/data/tx3.hex');
var tx4 = parseTX('../test/data/tx4.hex');
var wtx = fs.readFileSync(__dirname + '/../test/data/wtx.hex', 'utf8');
wtx = new Buffer(wtx.trim(), 'hex');
var tx;
for (let i = 0; i < 10000; i++)
TX.fromRaw(raw);
function parseTX(file) {
file = fs.readFileSync(__dirname + '/' + file, 'utf8').trim().split(/\n+/);
var tx = bcoin.tx.fromRaw(file.shift().trim(), 'hex');
for (var i = 0; i < file.length; i++) {
var coin = bcoin.tx.fromRaw(file[i].trim(), 'hex');
tx.fillCoins(coin);
end(10000);
}
{
const [tx, view] = tx5.getTX();
const end = bench('sigops');
for (let i = 0; i < 100000; i++)
tx.getSigopsCost(view);
end(100000);
}
{
const [tx] = tx5.getTX();
const end = bench('serialize');
for (let i = 0; i < 10000; i++) {
tx._raw = null;
tx.toRaw();
}
return tx;
end(10000);
}
var end = bench('parse');
for (var i = 0; i < 1000; i++)
tx = bcoin.tx.fromRaw(wtx);
end(i);
{
const [tx] = tx3.getTX();
const end = bench('hash');
var end = bench('serialize');
var raw;
for (let i = 0; i < 30000; i++) {
tx.hash();
tx._hash = null;
}
for (var i = 0; i < 1000; i++) {
tx._raw = null;
raw = tx.toRaw();
end(30000);
}
end(i);
var end = bench('hash');
for (var i = 0; i < 3000; i++) {
tx1.hash();
tx1._hash = null;
{
const [tx] = tx5.getTX();
const end = bench('witness hash');
for (let i = 0; i < 30000; i++) {
tx.witnessHash();
tx._whash = null;
}
end(30000);
}
end(i);
var end = bench('witness hash');
for (var i = 0; i < 3000; i++) {
tx.witnessHash();
tx._whash = null;
{
const [tx] = tx5.getTX();
const end = bench('sanity');
for (let i = 0; i < 10000; i++)
tx.isSane();
end(10000);
}
end(i);
var end = bench('fee');
for (var i = 0; i < 1000; i++)
tx.getFee();
end(i);
{
const [tx] = tx5.getTX();
const end = bench('input hashes');
var end = bench('sanity');
for (var i = 0; i < 1000; i++)
tx.isSane();
end(i);
for (let i = 0; i < 10000; i++)
tx.getInputHashes();
var end = bench('input hashes');
for (var i = 0; i < 1000; i++)
tx.getInputHashes('hex');
end(i);
end(10000);
}
var end = bench('output hashes');
for (var i = 0; i < 1000; i++)
tx.getOutputHashes('hex');
end(i);
{
const [tx] = tx5.getTX();
const end = bench('output hashes');
var end = bench('all hashes');
for (var i = 0; i < 1000; i++)
tx.getHashes('hex');
end(i);
for (let i = 0; i < 10000; i++)
tx.getOutputHashes();
var end = bench('verify');
for (var i = 0; i < 3000; i++)
tx1.verify(constants.flags.VERIFY_P2SH);
end(i * tx1.inputs.length);
end(10000);
}
var flags = constants.flags.VERIFY_P2SH | constants.flags.VERIFY_DERSIG;
var end = bench('verify multisig');
for (var i = 0; i < 3000; i++)
btx.verify(flags);
end(i * btx.inputs.length);
{
const [tx] = tx5.getTX();
const end = bench('all hashes');
var tx = bcoin.mtx();
for (let i = 0; i < 10000; i++)
tx.getHashes();
for (var i = 0; i < 100; i++) {
tx.addInput({
end(10000);
}
{
const [tx, view] = tx3.getTX();
const end = bench('verify');
for (let i = 0; i < 30000; i++)
tx.verify(view, Script.flags.VERIFY_P2SH);
end(30000 * tx.inputs.length);
}
{
const [tx, view] = tx3.getTX();
const {script} = view.getOutputFor(tx.inputs[0]);
const end = bench('sighash');
for (let i = 0; i < 1000000; i++)
tx.signatureHashV0(0, script, Script.hashType.ALL);
end(1000000);
}
{
const [tx, view] = tx3.getTX();
const end = bench('fee');
for (let i = 0; i < 10000; i++)
tx.getFee(view);
end(10000);
}
{
const [tx, view] = tx10.getTX();
const flags = Script.flags.VERIFY_P2SH | Script.flags.VERIFY_DERSIG;
const end = bench('verify multisig');
for (let i = 0; i < 30000; i++)
tx.verify(view, flags);
end(30000 * tx.inputs.length);
}
const mtx = new MTX();
for (let i = 0; i < 100; i++) {
mtx.addInput({
prevout: {
hash: constants.NULL_HASH,
hash: consensus.ZERO_HASH,
index: 0
},
script: [
new Buffer(9),
bcoin.crypto.randomBytes(33)
]
script: new Script()
.pushData(Buffer.allocUnsafe(9))
.pushData(random.randomBytes(33))
.compile()
});
tx.addOutput({
address: bcoin.address.fromHash(bcoin.crypto.randomBytes(20)),
mtx.addOutput({
address: Address.fromHash(random.randomBytes(20)),
value: 0
});
}
tx = tx.toTX();
const tx2 = mtx.toTX();
var end = bench('input hashes');
for (var i = 0; i < 1000; i++)
tx.getInputHashes('hex');
end(i);
{
const end = bench('input hashes');
var end = bench('output hashes');
for (var i = 0; i < 1000; i++)
tx.getOutputHashes('hex');
end(i);
for (let i = 0; i < 10000; i++)
tx2.getInputHashes();
var end = bench('all hashes');
for (var i = 0; i < 1000; i++)
tx.getHashes('hex');
end(i);
end(10000);
}
{
const end = bench('output hashes');
for (let i = 0; i < 10000; i++)
tx2.getOutputHashes();
end(10000);
}
{
const end = bench('all hashes');
for (let i = 0; i < 10000; i++)
tx2.getHashes();
end(10000);
}

View File

@ -1,143 +1,132 @@
'use strict';
var BN = require('bn.js');
var bcoin = require('../').set('main');
var constants = bcoin.constants;
var utils = bcoin.utils;
var assert = require('assert');
var scriptTypes = constants.scriptTypes;
var bench = require('./bench');
var co = require('../lib/utils/co');
var crypto = require('../lib/crypto/crypto');
bcoin.cache();
const bench = require('./bench');
const random = require('bcrypto/lib/random');
const WalletDB = require('../lib/wallet/walletdb');
const MTX = require('../lib/primitives/mtx');
const Outpoint = require('../lib/primitives/outpoint');
function dummy() {
var hash = crypto.randomBytes(32).toString('hex');
return {
prevout: {
hash: hash,
index: 0
},
coin: {
version: 1,
height: 0,
value: 50460 * 4,
script: new bcoin.script(),
coinbase: false,
hash: hash,
index: 0
},
script: new bcoin.script(),
witness: new bcoin.witness(),
sequence: 0xffffffff
};
const hash = random.randomBytes(32);
return new Outpoint(hash, 0);
}
var walletdb = new bcoin.walletdb({
const walletdb = new WalletDB({
name: 'wallet-test',
// location: __dirname + '/../walletdb-bench',
// db: 'leveldb'
db: 'memory',
resolution: false,
verify: false
});
var runBench = co(function* runBench() {
var i, j, wallet, addrs, jobs, end;
var result, tx, options;
(async () => {
// Open and Create
yield walletdb.open();
wallet = yield walletdb.create();
addrs = [];
await walletdb.open();
const wallet = await walletdb.create();
const addrs = [];
let tx;
// Accounts
jobs = [];
for (i = 0; i < 1000; i++)
jobs.push(wallet.createAccount({}));
{
const jobs = [];
for (let i = 0; i < 1000; i++)
jobs.push(wallet.createAccount({}));
end = bench('accounts');
result = yield Promise.all(jobs);
end(1000);
const end = bench('accounts');
const result = await Promise.all(jobs);
end(1000);
for (i = 0; i < result.length; i++)
addrs.push(result[i].receive.getAddress());
// Addresses
jobs = [];
for (i = 0; i < 1000; i++) {
for (j = 0; j < 10; j++)
jobs.push(wallet.createReceive(i));
for (const addr of result)
addrs.push(addr.receiveAddress());
}
end = bench('addrs');
result = yield Promise.all(jobs);
end(1000 * 10);
// Keys
{
const jobs = [];
for (let i = 0; i < 1000; i++) {
for (let j = 0; j < 10; j++)
jobs.push(wallet.createReceive(i));
}
for (i = 0; i < result.length; i++)
addrs.push(result[i].getAddress());
const end = bench('keys');
const result = await Promise.all(jobs);
end(1000 * 10);
for (const addr of result)
addrs.push(addr.getAddress());
}
// TX deposit
jobs = [];
for (i = 0; i < 10000; i++) {
tx = bcoin.mtx()
.addInput(dummy())
.addOutput(addrs[(i + 0) % addrs.length], 50460)
.addOutput(addrs[(i + 1) % addrs.length], 50460)
.addOutput(addrs[(i + 2) % addrs.length], 50460)
.addOutput(addrs[(i + 3) % addrs.length], 50460)
.toTX();
{
const jobs = [];
for (let i = 0; i < 10000; i++) {
const mtx = new MTX();
mtx.addOutpoint(dummy());
mtx.addOutput(addrs[(i + 0) % addrs.length], 50460);
mtx.addOutput(addrs[(i + 1) % addrs.length], 50460);
mtx.addOutput(addrs[(i + 2) % addrs.length], 50460);
mtx.addOutput(addrs[(i + 3) % addrs.length], 50460);
tx = mtx.toTX();
jobs.push(walletdb.addTX(tx));
jobs.push(walletdb.addTX(tx));
}
const end = bench('deposit');
await Promise.all(jobs);
end(10000);
}
end = bench('deposit');
result = yield Promise.all(jobs);
end(10000);
// TX redemption
jobs = [];
for (i = 0; i < 10000; i++) {
tx = bcoin.mtx()
.addInput(tx, 0)
.addInput(tx, 1)
.addInput(tx, 2)
.addInput(tx, 3)
.addOutput(addrs[(i + 0) % addrs.length], 50460)
.addOutput(addrs[(i + 1) % addrs.length], 50460)
.addOutput(addrs[(i + 2) % addrs.length], 50460)
.addOutput(addrs[(i + 3) % addrs.length], 50460)
.toTX();
{
const jobs = [];
for (let i = 0; i < 10000; i++) {
const mtx = new MTX();
mtx.addTX(tx, 0);
mtx.addTX(tx, 1);
mtx.addTX(tx, 2);
mtx.addTX(tx, 3);
mtx.addOutput(addrs[(i + 0) % addrs.length], 50460);
mtx.addOutput(addrs[(i + 1) % addrs.length], 50460);
mtx.addOutput(addrs[(i + 2) % addrs.length], 50460);
mtx.addOutput(addrs[(i + 3) % addrs.length], 50460);
tx = mtx.toTX();
jobs.push(walletdb.addTX(tx));
jobs.push(walletdb.addTX(tx));
}
const end = bench('redemption');
await Promise.all(jobs);
end(10000);
}
end = bench('redemption');
result = yield Promise.all(jobs);
end(10000);
// Balance
end = bench('balance');
result = yield wallet.getBalance();
end(1);
{
const end = bench('balance');
await wallet.getBalance();
end(1);
}
// Coins
end = bench('coins');
result = yield wallet.getCoins();
end(1);
{
const end = bench('coins');
await wallet.getCoins();
end(1);
}
// Create
end = bench('create');
options = {
rate: 10000,
outputs: [{
value: 50460,
address: addrs[0]
}]
};
yield wallet.createTX(options);
end(1);
{
const end = bench('create');
const options = {
rate: 10000,
outputs: [{
value: 50460,
address: addrs[0]
}]
};
await wallet.createTX(options);
end(1);
}
})().catch((err) => {
console.error(err);
process.exit(1);
});
runBench().then(process.exit);

685
bin/cli
View File

@ -2,685 +2,6 @@
'use strict';
var config = require('../lib/node/config');
var utils = require('../lib/utils/utils');
var co = require('../lib/utils/co');
var Client = require('../lib/http/client');
var Wallet = require('../lib/http/wallet');
var main;
function CLI() {
this.config = config({
config: true,
arg: true,
env: true,
network: 'main'
}).data;
this.argv = this.config.args;
this.client = null;
this.wallet = null;
}
CLI.prototype.log = function log(json) {
if (typeof json === 'string')
return console.log.apply(console, arguments);
console.log(JSON.stringify(json, null, 2));
};
CLI.prototype.getInfo = co(function* getInfo() {
var info = yield this.client.getInfo();
this.log(info);
});
CLI.prototype.createWallet = co(function* createWallet() {
var options = { id: this.argv[0] };
var wallet;
if (this.config.type)
options.type = this.config.type;
if (this.config.master)
options.master = this.config.master;
if (this.config.mnemonic)
options.master = this.config.mnemonic;
if (this.config.m)
options.m = this.config.m >>> 0;
if (this.config.n)
options.n = this.config.n >>> 0;
if (this.config.witness != null)
options.witness = !!this.config.witness;
if (this.config.passphrase)
options.passphrase = this.config.passphrase;
if (this.config.watch) {
options.watchOnly = true;
options.accountKey = this.config.watch;
}
wallet = yield this.client.createWallet(options);
this.log(wallet);
});
CLI.prototype.getMaster = co(function* getMaster() {
var master = yield this.wallet.getMaster();
this.log(master);
});
CLI.prototype.getKey = co(function* getKey() {
var address = this.argv[0];
var key = yield this.wallet.getKey(address);
this.log(key);
});
CLI.prototype.getWIF = co(function* getWIF() {
var address = this.argv[0];
var key = yield this.wallet.getWIF(address, this.config.passphrase);
this.log(key.privateKey);
});
CLI.prototype.addSharedKey = co(function* addSharedKey() {
var key = this.argv[0];
yield this.wallet.addSharedKey(this.config.account, key);
this.log('Added key.');
});
CLI.prototype.removeSharedKey = co(function* removeSharedKey() {
var key = this.argv[0];
yield this.wallet.removeSharedKey(this.config.account, key);
this.log('Removed key.');
});
CLI.prototype.getSharedKeys = co(function* getSharedKeys() {
var acct = this.argv[0] || this.config.account;
var account = yield this.wallet.getAccount(acct);
this.log(account.keys);
});
CLI.prototype.getAccount = co(function* getAccount() {
var acct = this.argv[0] || this.config.account;
var account = yield this.wallet.getAccount(acct);
this.log(account);
});
CLI.prototype.createAccount = co(function* createAccount() {
var options = { name: this.argv[0] };
var account;
if (this.config.type)
options.type = this.config.type;
if (this.config.m)
options.m = this.config.m >>> 0;
if (this.config.n)
options.n = this.config.n >>> 0;
if (this.config.witness != null)
options.witness = !!this.config.witness;
if (this.config.watch)
options.accountKey = this.config.watch;
account = yield this.wallet.createAccount(options);
this.log(account);
});
CLI.prototype.createAddress = co(function* createAddress() {
var account = this.argv[0];
var addr = yield this.wallet.createAddress(account);
this.log(addr);
});
CLI.prototype.createChange = co(function* createChange() {
var account = this.argv[0];
var addr = yield this.wallet.createChange(account);
this.log(addr);
});
CLI.prototype.createNested = co(function* createNested() {
var account = this.argv[0];
var addr = yield this.wallet.createNested(account);
this.log(addr);
});
CLI.prototype.getAccounts = co(function* getAccounts() {
var accounts = yield this.wallet.getAccounts();
this.log(accounts);
});
CLI.prototype.getWallet = co(function* getWallet() {
var info = yield this.wallet.getInfo();
this.log(info);
});
CLI.prototype.getTX = co(function* getTX() {
var hash = this.argv[0];
var txs, tx;
if (utils.isBase58(hash)) {
txs = yield this.client.getTXByAddress(hash);
this.log(txs);
return;
}
tx = yield this.client.getTX(hash);
if (!tx) {
this.log('TX not found.');
return;
}
this.log(tx);
});
CLI.prototype.getBlock = co(function* getBlock() {
var hash = this.argv[0];
var block;
if (hash.length !== 64)
hash = +hash;
block = yield this.client.getBlock(hash);
if (!block) {
this.log('Block not found.');
return;
}
this.log(block);
});
CLI.prototype.getCoin = co(function* getCoin() {
var hash = this.argv[0];
var index = this.argv[1];
var coins, coin;
if (utils.isBase58(hash)) {
coins = yield this.client.getCoinsByAddress(hash);
this.log(coins);
return;
}
coin = yield this.client.getCoin(hash, index);
if (!coin) {
this.log('Coin not found.');
return;
}
this.log(coin);
});
CLI.prototype.getWalletHistory = co(function* getWalletHistory() {
var txs = yield this.wallet.getHistory(this.config.account);
this.log(txs);
});
CLI.prototype.getWalletPending = co(function* getWalletPending() {
var txs = yield this.wallet.getPending(this.config.account);
this.log(txs);
});
CLI.prototype.getWalletCoins = co(function* getWalletCoins() {
var coins = yield this.wallet.getCoins(this.config.account);
this.log(coins);
});
CLI.prototype.listenWallet = co(function* listenWallet() {
var self = this;
yield this.wallet.open();
this.wallet.on('tx', function(details) {
self.log('TX:');
self.log(details);
});
this.wallet.on('confirmed', function(details) {
self.log('TX confirmed:');
self.log(details);
});
this.wallet.on('unconfirmed', function(details) {
self.log('TX unconfirmed:');
self.log(details);
});
this.wallet.on('conflict', function(details) {
self.log('TX conflict:');
self.log(details);
});
this.wallet.on('address', function(receive) {
self.log('New addresses allocated:');
self.log(receive);
});
this.wallet.on('balance', function(balance) {
self.log('Balance:');
self.log(balance);
});
return yield this.wallet.onDisconnect();
});
CLI.prototype.getBalance = co(function* getBalance() {
var balance = yield this.wallet.getBalance(this.config.account);
this.log(balance);
});
CLI.prototype.getMempool = co(function* getMempool() {
var txs = yield this.client.getMempool();
this.log(txs);
});
CLI.prototype.sendTX = co(function* sendTX() {
var output = {};
var options, tx;
if (this.config.script) {
output.script = this.config.script;
output.value = utils.satoshi(this.config.value || this.argv[0]);
} else {
output.address = this.config.address || this.argv[0];
output.value = utils.satoshi(this.config.value || this.argv[1]);
}
options = {
account: this.config.account,
passphrase: this.config.passphrase,
outputs: [output]
};
tx = yield this.wallet.send(options);
this.log(tx);
});
CLI.prototype.createTX = co(function* createTX() {
var output = {};
var options, tx;
if (this.config.script) {
output.script = this.config.script;
output.value = utils.satoshi(this.config.value || this.argv[0]);
} else {
output.address = this.config.address || this.argv[0];
output.value = utils.satoshi(this.config.value || this.argv[1]);
}
options = {
account: this.config.account,
passphrase: this.config.passphrase,
outputs: [output]
};
tx = yield this.wallet.createTX(options);
this.log(tx);
});
CLI.prototype.signTX = co(function* signTX() {
var options = { passphrase: this.config.passphrase };
var raw = options.tx || this.argv[0];
var tx = yield this.wallet.sign(raw, options);
this.log(tx);
});
CLI.prototype.zapWallet = co(function* zapWallet() {
var age = (this.config.age >>> 0) || 72 * 60 * 60;
yield this.wallet.zap(this.config.account, age);
this.log('Zapped!');
});
CLI.prototype.broadcast = co(function* broadcast() {
var raw = this.argv[0] || this.config.tx;
var tx = yield this.client.broadcast(raw);
this.log('Broadcasted:');
this.log(tx);
});
CLI.prototype.viewTX = co(function* viewTX() {
var raw = this.argv[0] || this.config.tx;
var tx = yield this.wallet.fill(raw);
this.log(tx);
});
CLI.prototype.getDetails = co(function* getDetails() {
var hash = this.argv[0];
var details = yield this.wallet.getTX(hash);
this.log(details);
});
CLI.prototype.getWalletBlocks = co(function* getWalletBlocks() {
var blocks = yield this.wallet.getBlocks();
this.log(blocks);
});
CLI.prototype.getWalletBlock = co(function* getWalletBlock() {
var height = this.argv[0] | 0;
var block = yield this.wallet.getBlock(height);
this.log(block);
});
CLI.prototype.retoken = co(function* retoken() {
var result = yield this.wallet.retoken();
this.log(result);
});
CLI.prototype.rescan = co(function* rescan() {
var height = this.argv[0];
if (!utils.isUInt32(height))
height = null;
yield this.client.rescan(height);
this.log('Rescanning...');
});
CLI.prototype.reset = co(function* reset() {
var hash = this.argv[0];
if (hash.length !== 64)
hash = +hash;
yield this.client.reset(hash);
this.log('Chain has been reset.');
});
CLI.prototype.resend = co(function* resend() {
yield this.client.resend();
this.log('Resending...');
});
CLI.prototype.resendWallet = co(function* resendWallet() {
yield this.wallet.resend();
this.log('Resending...');
});
CLI.prototype.backup = co(function* backup() {
var path = this.argv[0];
yield this.client.backup(path);
this.log('Backup complete.');
});
CLI.prototype.importKey = co(function* importKey() {
var key = this.argv[0];
if (!key)
throw new Error('No key for import.');
if (utils.isBase58(key)) {
yield this.wallet.importPrivate(key);
this.log('Imported private key.');
return;
}
if (utils.isHex(key)) {
yield this.wallet.importPublic(key);
this.log('Imported public key.');
return;
}
throw new Error('Bad key for import.');
});
CLI.prototype.importAddress = co(function* importKey() {
var address = this.argv[0];
yield this.wallet.importAddress(address);
this.log('Imported address.');
});
CLI.prototype.lock = co(function* lock() {
yield this.wallet.lock();
this.log('Locked.');
});
CLI.prototype.unlock = co(function* unlock() {
var passphrase = this.argv[0];
var timeout = +this.argv[1] || null;
yield this.wallet.unlock(passphrase, timeout);
this.log('Unlocked.');
});
CLI.prototype.rpc = co(function* rpc() {
var method = this.argv.shift();
var params = [];
var i, arg, param, result;
for (i = 0; i < this.argv.length; i++) {
arg = this.argv[i];
try {
param = JSON.parse(arg);
} catch (e) {
param = arg;
}
params.push(param);
}
result = yield this.client.rpc.call(method, params);
this.log(result);
});
CLI.prototype.handleWallet = co(function* handleWallet() {
this.wallet = new Wallet({
uri: this.config.url || this.config.uri,
apiKey: this.config.apikey,
network: this.config.network,
id: this.config.id || 'primary',
token: this.config.token
});
switch (this.argv.shift()) {
case 'listen':
return yield this.listenWallet();
case 'get':
return yield this.getWallet();
case 'master':
return yield this.getMaster();
case 'shared':
if (this.argv[0] === 'add') {
this.argv.shift();
return yield this.addSharedKey();
}
if (this.argv[0] === 'remove') {
this.argv.shift();
return yield this.removeSharedKey();
}
if (this.argv[0] === 'list')
this.argv.shift();
return yield this.getSharedKeys();
case 'balance':
return yield this.getBalance();
case 'history':
return yield this.getWalletHistory();
case 'pending':
return yield this.getWalletPending();
case 'coins':
return yield this.getWalletCoins();
case 'account':
if (this.argv[0] === 'list') {
this.argv.shift();
return yield this.getAccounts();
}
if (this.argv[0] === 'create') {
this.argv.shift();
return yield this.createAccount();
}
if (this.argv[0] === 'get')
this.argv.shift();
return yield this.getAccount();
case 'address':
return yield this.createAddress();
case 'change':
return yield this.createChange();
case 'nested':
return yield this.createNested();
case 'retoken':
return yield this.retoken();
case 'sign':
return yield this.signTX();
case 'mktx':
return yield this.createTX();
case 'send':
return yield this.sendTX();
case 'zap':
return yield this.zapWallet();
case 'tx':
return yield this.getDetails();
case 'blocks':
return yield this.getWalletBlocks();
case 'block':
return yield this.getWalletBlock();
case 'view':
return yield this.viewTX();
case 'import':
return yield this.importKey();
case 'watch':
return yield this.importAddress();
case 'key':
return yield this.getKey();
case 'dump':
return yield this.getWIF();
case 'lock':
return yield this.lock();
case 'unlock':
return yield this.unlock();
case 'resend':
return yield this.resendWallet();
default:
this.log('Unrecognized command.');
this.log('Commands:');
this.log(' $ listen: Listen for events.');
this.log(' $ get: View wallet.');
this.log(' $ master: View wallet master key.');
this.log(' $ shared add [xpubkey]: Add key to wallet.');
this.log(' $ shared remove [xpubkey]: Remove key from wallet.');
this.log(' $ balance: Get wallet balance.');
this.log(' $ history: View TX history.');
this.log(' $ pending: View pending TXs.');
this.log(' $ coins: View wallet coins.');
this.log(' $ account list: List account names.');
this.log(' $ account create [account-name]: Create account.');
this.log(' $ account get [account-name]: Get account details.');
this.log(' $ address: Derive new address.');
this.log(' $ change: Derive new change address.');
this.log(' $ nested: Derive new nested address.');
this.log(' $ retoken: Create new api key.');
this.log(' $ send [address] [value]: Send transaction.');
this.log(' $ mktx [address] [value]: Create transaction.');
this.log(' $ sign [tx-hex]: Sign transaction.');
this.log(' $ zap [age?]: Zap pending wallet TXs.');
this.log(' $ tx [hash]: View transaction details.');
this.log(' $ blocks: List wallet blocks.');
this.log(' $ block [height]: View wallet block.');
this.log(' $ view [tx-hex]: Parse and view transaction.');
this.log(' $ import [wif|hex]: Import private or public key.');
this.log(' $ watch [address]: Import an address.');
this.log(' $ key [address]: Get wallet key by address.');
this.log(' $ dump [address]: Get wallet key WIF by address.');
this.log(' $ lock: Lock wallet.');
this.log(' $ unlock [passphrase] [timeout?]: Unlock wallet.');
this.log(' $ resend: Resend pending transactions.');
this.log('Other Options:');
this.log(' --passphrase [passphrase]: For signing and account creation.');
this.log(' --account [account-name]: Account name.');
return;
}
});
CLI.prototype.handleNode = co(function* handleNode() {
this.client = new Client({
uri: this.config.url || this.config.uri,
apiKey: this.config.apikey,
network: this.config.network
});
switch (this.argv.shift()) {
case 'info':
return yield this.getInfo();
case 'mkwallet':
return yield this.createWallet();
case 'broadcast':
return yield this.broadcast();
case 'mempool':
return yield this.getMempool();
case 'tx':
return yield this.getTX();
case 'coin':
return yield this.getCoin();
case 'block':
return yield this.getBlock();
case 'rescan':
return yield this.rescan();
case 'reset':
return yield this.reset();
case 'resend':
return yield this.resend();
case 'backup':
return yield this.backup();
case 'rpc':
return yield this.rpc();
default:
this.log('Unrecognized command.');
this.log('Commands:');
this.log(' $ info: Get server info.');
this.log(' $ wallet create [id]: Create wallet.');
this.log(' $ broadcast [tx-hex]: Broadcast transaction.');
this.log(' $ mempool: Get mempool snapshot.');
this.log(' $ tx [hash/address]: View transactions.');
this.log(' $ coin [hash+index/address]: View coins.');
this.log(' $ block [hash/height]: View block.');
this.log(' $ rescan [height]: Rescan for transactions.');
this.log(' $ reset [height/hash]: Reset chain to desired block.');
this.log(' $ resend: Resend pending transactions.');
this.log(' $ backup [path]: Backup the wallet db.');
this.log(' $ rpc [command] [args]: Execute RPC command.');
return;
}
});
CLI.prototype.open = co(function* open() {
switch (this.argv[0]) {
case 'w':
case 'wallet':
this.argv.shift();
if (this.argv[0] === 'create') {
this.argv[0] = 'mkwallet';
return yield this.handleNode();
}
return yield this.handleWallet();
default:
return yield this.handleNode();
}
});
CLI.prototype.destroy = function destroy() {
if (this.wallet)
this.wallet.client.destroy();
if (this.client)
this.client.destroy();
return Promise.resolve();
};
main = co(function* main() {
var cli = new CLI();
yield cli.open();
yield cli.destroy();
});
main().then(process.exit).catch(function(err) {
console.error(err.stack + '');
return process.exit(1);
});
console.error('%s%s',
'Warning: The `fcoin cli` interface is deprecated.\n',
'Please use `fcoin-cli` and `fwallet-cli` instead.');

View File

@ -6,7 +6,7 @@ cmd='node'
if ! type perl > /dev/null 2>& 1; then
if uname | grep -i 'darwin' > /dev/null; then
echo 'BCoin requires perl to start.' >& 2
echo 'Bcoin requires perl to start on OSX.' >& 2
exit 1
fi
rl=1
@ -50,9 +50,13 @@ for arg in "$@"; do
done
if test $daemon -eq 1; then
# And yet again, OSX doesn't support something.
if ! type setsid > /dev/null 2>& 1; then
echo 'BCoin requires setsid to start as a daemon.' >& 2
exit 1
(
"${dir}/${cmd}" "$@" > /dev/null 2>& 1 &
echo "$!"
)
exit 0
fi
(
setsid "${dir}/${cmd}" "$@" > /dev/null 2>& 1 &

5
bin/fcoin-cli Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env node
'use strict';
require('@oipwg/fclient/bin/fcoin-cli');

55
bin/fwallet Executable file
View File

@ -0,0 +1,55 @@
#!/bin/bash
rl=0
daemon=0
if ! type perl > /dev/null 2>& 1; then
if uname | grep -i 'darwin' > /dev/null; then
echo 'Bcoin requires perl to start on OSX.' >& 2
exit 1
fi
rl=1
fi
if test $rl -eq 1; then
file=$(readlink -f "$0")
else
# Have to do it this way
# because OSX isn't a real OS
file=$(perl -MCwd -e "print Cwd::realpath('$0')")
fi
dir=$(dirname "$file")
if test x"$1" = x'cli'; then
shift
exec "${dir}/cli" "wallet" "$@"
exit 1
fi
for arg in "$@"; do
case "$arg" in
--daemon)
daemon=1
;;
esac
done
if test $daemon -eq 1; then
# And yet again, OSX doesn't support something.
if ! type setsid > /dev/null 2>& 1; then
(
"${dir}/wallet" "$@" > /dev/null 2>& 1 &
echo "$!"
)
exit 0
fi
(
setsid "${dir}/wallet" "$@" > /dev/null 2>& 1 &
echo "$!"
)
exit 0
else
exec "${dir}/wallet" "$@"
exit 1
fi

5
bin/fwallet-cli Executable file
View File

@ -0,0 +1,5 @@
#!/usr/bin/env node
'use strict';
require('@oipwg/fclient/bin/fwallet-cli');

View File

@ -2,37 +2,59 @@
'use strict';
process.title = 'bcoin';
process.title = 'fcoin';
var bcoin = require('../');
var utils = bcoin.utils;
var assert = require('assert');
if (process.argv.indexOf('--help') !== -1
|| process.argv.indexOf('-h') !== -1) {
console.error('See the bcoin docs at: https://github.com/bcoin-org/bcoin/tree/master/docs.');
process.exit(1);
throw new Error('Could not exit.');
}
var options = bcoin.config({
config: true,
arg: true,
if (process.argv.indexOf('--version') !== -1
|| process.argv.indexOf('-v') !== -1) {
const pkg = require('../package.json');
console.log(pkg.version);
process.exit(0);
throw new Error('Could not exit.');
}
const FullNode = require('../lib/node/fullnode');
const node = new FullNode({
file: true,
argv: true,
env: true,
logLevel: 'debug',
logFile: true,
db: 'leveldb',
listen: true
logConsole: true,
logLevel: 'debug',
checkpoints: true,
memory: false,
workers: true,
listen: true,
loader: require
});
bcoin.set(options);
// Temporary hack
if (!node.config.bool('no-wallet') && !node.has('walletdb')) {
const plugin = require('../lib/wallet/plugin');
node.use(plugin);
}
var node = new bcoin.fullnode(options);
node.on('error', function(err) {
;
process.on('unhandledRejection', (err, promise) => {
throw err;
});
process.on('uncaughtException', function(err) {
node.logger.debug(err.stack);
node.logger.error(err);
process.on('SIGINT', async () => {
await node.close();
});
(async () => {
await node.ensure();
await node.open();
await node.connect();
node.startSync();
})().catch((err) => {
console.error(err.stack);
process.exit(1);
});
node.open().then(function() {
node.pool.connect();
node.startSync();
});

View File

@ -2,45 +2,58 @@
'use strict';
process.title = 'bcoin';
process.title = 'fcoin';
var bcoin = require('../');
var utils = bcoin.utils;
var assert = require('assert');
const assert = require('assert');
const SPVNode = require('../lib/node/spvnode');
const Outpoint = require('../lib/primitives/outpoint');
var options = bcoin.config({
config: true,
arg: true,
const node = new SPVNode({
file: true,
argv: true,
env: true,
logLevel: 'debug',
logFile: true,
db: 'leveldb'
logConsole: true,
logLevel: 'debug',
db: 'leveldb',
memory: false,
persistent: true,
workers: true,
listen: true,
loader: require
});
bcoin.set(options);
// Temporary hack
if (!node.config.bool('no-wallet') && !node.has('walletdb')) {
const plugin = require('../lib/wallet/plugin');
node.use(plugin);
}
var node = bcoin.spvnode(options);
node.on('error', function(err) {
;
process.on('unhandledRejection', (err, promise) => {
throw err;
});
process.on('uncaughtException', function(err) {
node.logger.debug(err.stack);
node.logger.error(err);
process.exit(1);
process.on('SIGINT', async () => {
await node.close();
});
node.open().then(function() {
if (process.argv.indexOf('--test') !== -1) {
(async () => {
await node.ensure();
await node.open();
await node.connect();
if (node.config.bool('test')) {
node.pool.watchAddress('1VayNert3x1KzbpzMGt2qdqrAThiRovi8');
node.pool.watch(bcoin.outpoint().toRaw());
node.on('block', function(block) {
node.pool.watchOutpoint(new Outpoint());
node.on('block', (block) => {
assert(block.txs.length >= 1);
if (block.txs.length > 1)
utils.log(block.txs[1]);
console.log(block.txs[1]);
});
}
node.startSync();
})().catch((err) => {
console.error(err.stack);
process.exit(1);
});

51
bin/wallet Executable file
View File

@ -0,0 +1,51 @@
#!/usr/bin/env node
'use strict';
process.title = 'fwallet';
if (process.argv.indexOf('--help') !== -1
|| process.argv.indexOf('-h') !== -1) {
console.error('See the bcoin docs at: https://github.com/bcoin-org/bcoin/tree/master/docs.');
process.exit(1);
throw new Error('Could not exit.');
}
if (process.argv.indexOf('--version') !== -1
|| process.argv.indexOf('-v') !== -1) {
const pkg = require('../package.json');
console.log(pkg.version);
process.exit(0);
throw new Error('Could not exit.');
}
const Node = require('../lib/wallet/node');
const node = new Node({
file: true,
argv: true,
env: true,
logFile: true,
logConsole: true,
logLevel: 'debug',
memory: false,
workers: true,
listen: true,
loader: require
});
process.on('unhandledRejection', (err, promise) => {
throw err;
});
process.on('SIGINT', async () => {
await node.close();
});
(async () => {
await node.ensure();
await node.open();
})().catch((err) => {
console.error(err.stack);
process.exit(1);
});

11
browser/debug.html Normal file
View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html>
<head>
<title>bcoin</title>
<script src="/bcoin.js"></script>
</head>
<body>
<h1>Bcoin</h1>
<p>Use the console to access `global.bcoin`.</p>
</body>
</html>

View File

@ -1,3 +0,0 @@
// Empty module for browserify.
module.exports = null;
throw new Error('Module not available.');

View File

@ -1,101 +1,110 @@
<!doctype html>
<html>
<head>
<title>bcoin</title>
<style>
html { height: 100%; }
body { height: 90%; padding: 20px; }
h1 {
font: 3em monospace;
margin: 10px;
padding: 0;
}
small {
margin: 10px;
width: 50%;
display: block;
}
.log {
padding: 5px;
margin-left: 10px;
overflow-y: scroll;
border: 1px solid black;
white-space: pre-wrap;
height: 40%;
width: 40%;
font: 1em monospace;
margin-top: 10px;
}
.wallet {
padding: 5px;
margin-left: 5px;
margin-top: 10px;
font: 1em monospace;
}
.rpc, .send {
padding: 5px;
margin-left: 5px;
margin-top: 10px;
font: 1em monospace;
}
#newaddr{
display: block;
margin-left: 10px;
}
.tx {
float: right;
font: 1em monospace;
padding: 5px;
border: 1px solid black;
margin-top: 10px;
}
a {
text-decoration: none;
}
.floating {
font: 1em monospace;
white-space: pre-wrap;
position: absolute;
display: none;
padding: 5px;
background: white;
border: 1px solid black;
width: 40%;
height: 30%;
top: 50%;
left: 50%;
margin-left: -20%;
margin-top: -15%;
overflow-y: scroll;
}
</style>
<script src="/bcoin.js"></script>
</head>
<body>
<h1>BCoin, the browser full node</h1>
<small>Welcome. Your machine is currently validating the blockchain.
The blocks and wallet are stored on your local disk with indexed DB. You are
connecting to the actual bitcoin P2P network via a websocket-&gt;tcp proxy.
Enjoy. (See the <a href="https://github.com/bcoin-org/bcoin">bcoin repo</a> for
more bitcoin magic).</small>
<div class="tx">
<div>Chain State: <span id="state"></span></div>
<div>Last 20 Blocks/TXs:</div>
<div id="tx"></div>
</div>
<div id="log" class="log"></div>
<form id="rpc" class="rpc" action="#">
<input type="text" name="cmd" id="cmd"
placeholder="RPC command (e.g. getblockchaininfo)">
</form>
<div id="wallet" class="wallet"></div>
<form id="send" class="send" action="#">
<input type="text" name="address" id="address" placeholder="Address">
<input type="text" name="amount" id="amount" placeholder="Amount (BTC)">
<input type="submit" value="Send">
</form>
<input type="button" id="newaddr" value="New Address">
<div id="floating" class="floating"></div>
<script src="/index.js"></script>
</body>
<!DOCTYPE html>
<html lang="en">
<head>
<title>bcoin</title>
<meta charset="utf-8">
<style>
html {
height: 100%;
}
body {
height: 90%;
padding: 20px;
}
h1 {
font: 3em monospace;
margin: 10px;
padding: 0;
}
small {
margin: 10px;
width: 50%;
display: block;
}
.log {
padding: 5px;
margin-left: 10px;
overflow-y: scroll;
border: 1px solid black;
white-space: pre-wrap;
height: 40%;
width: 40%;
font: 1em monospace;
margin-top: 10px;
}
.wallet {
padding: 5px;
margin-left: 5px;
margin-top: 10px;
font: 1em monospace;
}
.rpc, .send {
padding: 5px;
margin-left: 5px;
margin-top: 10px;
font: 1em monospace;
}
#newaddr{
display: block;
margin-left: 10px;
}
.tx {
float: right;
font: 1em monospace;
padding: 5px;
border: 1px solid black;
margin-top: 10px;
}
a {
text-decoration: none;
}
.floating {
font: 1em monospace;
white-space: pre-wrap;
position: absolute;
display: none;
padding: 5px;
background: white;
border: 1px solid black;
width: 40%;
height: 30%;
top: 50%;
left: 50%;
margin-left: -20%;
margin-top: -15%;
overflow-y: scroll;
}
</style>
<script src="app.js" defer></script>
</head>
<body>
<h1>Bcoin, the browser full node</h1>
<small>
Welcome. Your machine is currently validating the blockchain. The blocks
and wallet are stored on your local disk with indexed DB. You are
connecting to the actual bitcoin P2P network via a websocket-&gt;tcp
proxy. Enjoy. (See the
<a href="https://github.com/bcoin-org/bcoin"
target="_blank">bcoin repo</a>
for more bitcoin magic).
</small>
<div class="tx">
<div>Chain State: <span id="state"></span></div>
<div>Last 20 Blocks/TXs:</div>
<div id="tx"></div>
</div>
<div id="log" class="log"></div>
<form id="rpc" class="rpc" action="#">
<input type="text" name="cmd" id="cmd"
placeholder="RPC command (e.g. getblockchaininfo)">
</form>
<div id="wallet" class="wallet"></div>
<form id="send" class="send" action="#">
<input type="text" name="address" id="address" placeholder="Address">
<input type="text" name="amount" id="amount" placeholder="Amount (BTC)">
<input type="submit" value="Send">
</form>
<input type="button" id="newaddr" value="New Address">
<div id="floating" class="floating"></div>
</body>
</html>

View File

@ -1,243 +0,0 @@
;(function() {
'use strict';
var utils = bcoin.utils;
var body = document.getElementsByTagName('body')[0];
var log = document.getElementById('log');
var wdiv = document.getElementById('wallet');
var tdiv = document.getElementById('tx');
var floating = document.getElementById('floating');
var send = document.getElementById('send');
var newaddr = document.getElementById('newaddr');
var chainState = document.getElementById('state');
var rpc = document.getElementById('rpc');
var cmd = document.getElementById('cmd');
var items = [];
var scrollback = 0;
var logger, node, options;
body.onmouseup = function() {
floating.style.display = 'none';
};
floating.onmouseup = function(ev) {
ev.stopPropagation();
return false;
};
function show(obj) {
floating.innerHTML = escape(utils.inspectify(obj, false));
floating.style.display = 'block';
}
logger = new bcoin.logger({ level: 'debug' });
logger.writeConsole = function(level, args) {
var msg = utils.format(args, false);
if (++scrollback > 1000) {
log.innerHTML = '';
scrollback = 1;
}
log.innerHTML += '<span style="color:blue;">' + utils.now() + '</span> ';
if (level === 'error')
log.innerHTML += '<span style="color:red;">[' + level + ']</span> ';
else
log.innerHTML += '[' + level + '] ';
log.innerHTML += escape(msg) + '\n';
log.scrollTop = log.scrollHeight;
};
rpc.onsubmit = function(ev) {
var text = cmd.value || '';
var argv = text.trim().split(/\s+/);
var method = argv.shift();
var params = [];
var i, arg, param;
cmd.value = '';
for (i = 0; i < argv.length; i++) {
arg = argv[i];
try {
param = JSON.parse(arg);
} catch (e) {
param = arg;
}
params.push(param);
}
node.rpc.execute({ method: method, params: params }).then(show, show);
ev.preventDefault();
ev.stopPropagation();
return false;
};
send.onsubmit = function(ev) {
var value = document.getElementById('amount').value;
var address = document.getElementById('address').value;
var tx, options;
options = {
outputs: [{
address: address,
value: utils.satoshi(value)
}]
};
node.wallet.createTX(options).then(function(mtx) {
tx = mtx;
return node.wallet.sign(tx);
}).then(function() {
return node.sendTX(tx);
}).then(function() {
show(tx);
});
ev.preventDefault();
ev.stopPropagation();
return false;
};
newaddr.onmouseup = function() {
node.wallet.createReceive().then(function() {
formatWallet(node.wallet);
});
};
function kb(size) {
size /= 1000;
return size.toFixed(2) + 'kb';
}
function create(html) {
var el = document.createElement('div');
el.innerHTML = html;
return el.firstChild;
}
function escape(html, encode) {
return html
.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;');
}
function addItem(tx) {
var el;
if (items.length === 20) {
el = items.shift();
tdiv.removeChild(el);
el.onmouseup = null;
}
el = create('<a style="display:block;" href="#'
+ tx.rhash + '">' + tx.rhash + ' (' + tx.height
+ ' - ' + kb(tx.getSize()) + ')</a>');
tdiv.appendChild(el);
setMouseup(el, tx);
items.push(el);
chainState.innerHTML = ''
+ 'tx=' + node.chain.db.state.tx
+ ' coin=' + node.chain.db.state.coin
+ ' value=' + utils.btc(node.chain.db.state.value);
}
function setMouseup(el, obj) {
el.onmouseup = function(ev) {
show(obj);
ev.stopPropagation();
return false;
};
}
function formatWallet(wallet) {
var html = '';
var key = wallet.master.toJSON(true).key;
var i, tx, el;
html += '<b>Wallet</b><br>';
if (wallet.account.witness) {
html += 'Current Address (p2wpkh): <b>'
+ wallet.getAddress()
+ '</b><br>';
html += 'Current Address (p2wpkh behind p2sh): <b>'
+ wallet.getNestedAddress()
+ '</b><br>';
} else {
html += 'Current Address: <b>' + wallet.getAddress() + '</b><br>';
}
html += 'Extended Private Key: <b>' + key.xprivkey + '</b><br>';
html += 'Mnemonic: <b>' + key.mnemonic.phrase + '</b><br>';
wallet.getBalance().then(function(balance) {
html += 'Confirmed Balance: <b>'
+ utils.btc(balance.confirmed)
+ '</b><br>';
html += 'Unconfirmed Balance: <b>'
+ utils.btc(balance.unconfirmed)
+ '</b><br>';
return wallet.getHistory();
}).then(function(txs) {
return wallet.toDetails(txs);
}).then(function(txs) {
html += 'TXs:\n';
wdiv.innerHTML = html;
for (i = 0; i < txs.length; i++) {
tx = txs[i];
el = create(
'<a style="display:block;" href="#' + tx.hash + '">'
+ tx.hash + '</a>');
wdiv.appendChild(el);
setMouseup(el, tx.toJSON());
}
});
}
options = bcoin.config({
query: true,
network: 'segnet4',
db: 'leveldb',
useWorkers: true,
coinCache: true,
logger: logger
});
bcoin.set(options);
node = new bcoin.fullnode(options);
node.rpc = new bcoin.rpc(node);
node.on('error', function(err) {
;
});
node.chain.on('block', addItem);
node.mempool.on('tx', addItem);
node.open().then(function() {
node.startSync();
formatWallet(node.wallet);
node.wallet.on('balance', function() {
formatWallet(node.wallet);
});
});
})();

View File

@ -1,48 +1,45 @@
'use strict';
var HTTPBase = require('../lib/http/base');
var WSProxy = require('./wsproxy');
var fs = require('fs');
const bweb = require('bweb');
const fs = require('bfile');
const WSProxy = require('./wsproxy');
var server = new HTTPBase();
var proxy = new WSProxy({
const index = fs.readFileSync(`${__dirname}/index.html`);
const app = fs.readFileSync(`${__dirname}/app.js`);
const worker = fs.readFileSync(`${__dirname}/worker.js`);
const proxy = new WSProxy({
pow: process.argv.indexOf('--pow') !== -1,
ports: [8333, 18333, 18444, 28333, 28901]
ports: [7312, 17312, 17412, 28333, 28901]
});
proxy.on('error', function(err) {
console.error(err.stack + '');
const server = bweb.server({
port: Number(process.argv[2]) || 8080,
sockets: false
});
var index = fs.readFileSync(__dirname + '/index.html');
var indexjs = fs.readFileSync(__dirname + '/index.js');
var bcoin = fs.readFileSync(__dirname + '/bcoin.js');
var worker = fs.readFileSync(__dirname + '/../lib/workers/worker-browser.js');
server.use(server.router());
server.get('/favicon.ico', function(req, res, send, next) {
send(404, '', 'text');
proxy.on('error', (err) => {
console.error(err.stack);
});
server.get('/', function(req, res, send, next) {
send(200, index, 'html');
server.on('error', (err) => {
console.error(err.stack);
});
server.get('/index.js', function(req, res, send, next) {
send(200, indexjs, 'js');
server.get('/', (req, res) => {
res.send(200, index, 'html');
});
server.get('/bcoin.js', function(req, res, send, next) {
send(200, bcoin, 'js');
server.get('/app.js', (req, res) => {
res.send(200, app, 'js');
});
server.get('/bcoin-worker.js', function(req, res, send, next) {
send(200, worker, 'js');
server.get('/worker.js', (req, res) => {
res.send(200, worker, 'js');
});
server.on('error', function(err) {
console.error(err.stack + '');
});
proxy.attach(server.http);
proxy.attach(server.server);
server.listen(+process.argv[2] || 8080);
server.open();

292
browser/src/app.js Normal file
View File

@ -0,0 +1,292 @@
/* eslint-env browser */
'use strict';
const Logger = require('blgr');
const FullNode = require('../../lib/node/fullnode');
const Amount = require('../../lib/btc/amount');
const plugin = require('../../lib/wallet/plugin');
const util = require('../../lib/utils/util');
const ProxySocket = require('./proxysocket');
const body = document.getElementsByTagName('body')[0];
const log = document.getElementById('log');
const wdiv = document.getElementById('wallet');
const tdiv = document.getElementById('tx');
const floating = document.getElementById('floating');
const send = document.getElementById('send');
const newaddr = document.getElementById('newaddr');
const chainState = document.getElementById('state');
const rpc = document.getElementById('rpc');
const cmd = document.getElementById('cmd');
const items = [];
let scrollback = 0;
const logger = new Logger({
level: 'debug',
console: true
});
logger.writeConsole = function writeConsole(level, module, args) {
const name = Logger.levelsByVal[level];
const msg = this.fmt(args, false);
if (++scrollback > 1000) {
log.innerHTML = '';
scrollback = 1;
}
const now = Math.floor(Date.now() / 1000);
log.innerHTML += `<span style="color:blue;">${now}</span> `;
if (name === 'error') {
log.innerHTML += `<span style="color:red;">[${name}] `;
if (module)
log.innerHTML += `(${module}) `;
log.innerHTML += '</span>';
} else {
log.innerHTML += `[${name}] `;
if (module)
log.innerHTML += `(${module}) `;
}
log.innerHTML += escape(msg) + '\n';
log.scrollTop = log.scrollHeight;
};
const node = new FullNode({
hash: true,
query: true,
prune: true,
network: 'main',
memory: false,
logConsole: true,
workers: true,
workerFile: '/worker.js',
createSocket: (port, host) => {
const proto = global.location.protocol === 'https:' ? 'wss' : 'ws';
const hostname = global.location.host;
return ProxySocket.connect(`${proto}://${hostname}`, port, host);
},
logger: logger,
plugins: [plugin]
});
const {wdb} = node.require('walletdb');
wdb.options.witness = true;
window.onunhandledrejection = function onunhandledrejection(event) {
throw event.reason;
};
body.onmouseup = function onmouseup() {
floating.style.display = 'none';
};
floating.onmouseup = function onmouseup(ev) {
ev.stopPropagation();
return false;
};
function show(obj) {
if (obj instanceof Error) {
floating.innerHTML = obj.stack;
floating.style.display = 'block';
return;
}
floating.innerHTML = escape(JSON.stringify(obj, null, 2));
floating.style.display = 'block';
}
rpc.onsubmit = function onsubmit(ev) {
const text = cmd.value || '';
const argv = text.trim().split(/\s+/);
const method = argv.shift();
const params = [];
cmd.value = '';
for (const arg of argv) {
let param;
try {
param = JSON.parse(arg);
} catch (e) {
param = arg;
}
params.push(param);
}
(async () => {
try {
const result = await node.rpc.execute({ method, params });
show(result);
} catch (e) {
show(e);
}
})();
ev.preventDefault();
ev.stopPropagation();
return false;
};
send.onsubmit = function onsubmit(ev) {
const value = document.getElementById('amount').value;
const address = document.getElementById('address').value;
const options = {
outputs: [{
address: address,
value: Amount.value(value)
}]
};
(async () => {
try {
const mtx = await wdb.primary.createTX(options);
await wdb.primary.sign(mtx);
await node.relay(mtx.toTX());
show(mtx);
} catch (e) {
show(e);
}
})();
ev.preventDefault();
ev.stopPropagation();
return false;
};
newaddr.onmouseup = function onmouseup() {
(async () => {
try {
await wdb.primary.createReceive();
formatWallet(wdb.primary);
} catch (e) {
show(e);
}
})();
};
function kb(size) {
size /= 1000;
return size.toFixed(2) + 'kb';
}
function create(html) {
const el = document.createElement('div');
el.innerHTML = html;
return el.firstChild;
}
function escape(html, encode) {
return html
.replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#39;');
}
function addItem(item, entry) {
const height = entry ? entry.height : -1;
if (items.length === 20) {
const el = items.shift();
tdiv.removeChild(el);
el.onmouseup = null;
}
const el = create(''
+ `<a style="display:block;" href="#${item.rhash()}">`
+ `${item.rhash()} (${height} - ${kb(item.getSize())})`
+ '</a>'
);
tdiv.appendChild(el);
setMouseup(el, item);
items.push(el);
chainState.innerHTML = ''
+ `tx=${node.chain.db.state.tx} `
+ `coin=${node.chain.db.state.coin} `
+ `value=${Amount.btc(node.chain.db.state.value)}`;
}
function setMouseup(el, obj) {
el.onmouseup = function onmouseup(ev) {
show(obj);
ev.stopPropagation();
return false;
};
}
async function formatWallet(wallet) {
try {
await _formatWallet(wallet);
} catch (e) {
show(e);
}
}
async function _formatWallet(wallet) {
const {key, mnemonic} = wallet.master.toJSON(node.network, true);
const account = await wallet.getAccount('default');
const receive = account.receiveAddress();
const nested = account.nestedAddress();
const raddr = receive.toString(node.network);
const naddr = nested ? nested.toString(node.network) : null;
let html = '';
html += '<b>Wallet</b><br>';
if (naddr) {
html += `Current Address (p2wpkh): <b>${raddr}</b><br>`;
html += `Current Address (p2wpkh behind p2sh): <b>${naddr}</b><br>`;
} else {
html += `Current Address: <b>${raddr}</b><br>`;
}
html += `Extended Private Key: <b>${key.xprivkey}</b><br>`;
html += `Mnemonic: <b>${mnemonic.phrase}</b><br>`;
const balance = await wallet.getBalance();
html += `Confirmed Balance: <b>${Amount.btc(balance.confirmed)}</b><br>`;
html += `Unconfirmed Balance: <b>${Amount.btc(balance.unconfirmed)}</b><br>`;
const txs = await wallet.getHistory();
const det = await wallet.toDetails(txs);
html += 'TXs:\n';
wdiv.innerHTML = html;
for (const tx of det) {
const hash = util.revHex(tx.hash);
const el = create(
`<a style="display:block;" href="#${hash}">${hash}</a>`);
wdiv.appendChild(el);
setMouseup(el, tx.toJSON());
}
}
node.chain.on('block', addItem);
node.mempool.on('tx', addItem);
(async () => {
await node.open();
await node.connect();
node.startSync();
wdb.primary.on('balance', () => {
formatWallet(wdb.primary);
});
formatWallet(wdb.primary);
})().catch((err) => {
throw err;
});

154
browser/src/proxysocket.js Normal file
View File

@ -0,0 +1,154 @@
/*!
* proxysocket.js - wsproxy socket for bcoin
* Copyright (c) 2016-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
const assert = require('assert');
const EventEmitter = require('events');
const bsock = require('bsock');
class ProxySocket extends EventEmitter {
constructor(uri) {
super();
this.socket = bsock.socket();
this.socket.reconnection = false;
this.socket.connect(uri);
this.sendBuffer = [];
this.recvBuffer = [];
this.paused = false;
this.bytesWritten = 0;
this.bytesRead = 0;
this.remoteAddress = null;
this.remotePort = 0;
this.closed = false;
this.init();
}
init() {
this.socket.on('error', (err) => {
console.error(err);
});
this.socket.bind('tcp connect', (addr, port) => {
if (this.closed)
return;
this.remoteAddress = addr;
this.remotePort = port;
this.emit('connect');
});
this.socket.bind('tcp data', (data) => {
data = Buffer.from(data, 'hex');
if (this.paused) {
this.recvBuffer.push(data);
return;
}
this.bytesRead += data.length;
this.emit('data', data);
});
this.socket.bind('tcp close', (data) => {
if (this.closed)
return;
this.closed = true;
this.emit('close');
});
this.socket.bind('tcp error', (e) => {
const err = new Error(e.message);
err.code = e.code;
this.emit('error', err);
});
this.socket.bind('tcp timeout', () => {
this.emit('timeout');
});
this.socket.on('disconnect', () => {
if (this.closed)
return;
this.closed = true;
this.emit('close');
});
}
connect(port, host) {
this.remoteAddress = host;
this.remotePort = port;
if (this.closed) {
this.sendBuffer.length = 0;
return;
}
this.socket.fire('tcp connect', port, host);
for (const chunk of this.sendBuffer)
this.write(chunk);
this.sendBuffer.length = 0;
}
setKeepAlive(enable, delay) {
this.socket.fire('tcp keep alive', enable, delay);
}
setNoDelay(enable) {
this.socket.fire('tcp no delay', enable);
}
setTimeout(timeout, callback) {
this.socket.fire('tcp set timeout', timeout);
if (callback)
this.on('timeout', callback);
}
write(data, callback) {
this.bytesWritten += data.length;
this.socket.fire('tcp data', data.toString('hex'));
if (callback)
callback();
return true;
}
pause() {
this.paused = true;
}
resume() {
const recv = this.recvBuffer;
this.paused = false;
this.recvBuffer = [];
for (const data of recv) {
this.bytesRead += data.length;
this.emit('data', data);
}
}
destroy() {
if (this.closed)
return;
this.closed = true;
this.socket.destroy();
}
static connect(uri, port, host) {
const socket = new this(uri);
socket.connect(port, host);
return socket;
}
}
module.exports = ProxySocket;

View File

@ -1,75 +0,0 @@
var Transform = require('stream').Transform;
var path = require('path');
var assert = require('assert');
var fs = require('fs');
var StringDecoder = require('string_decoder').StringDecoder;
function nil() {
var stream = new Transform();
stream._transform = function(chunk, encoding, callback) {
callback(null, chunk);
};
stream._flush = function(callback) {
callback();
};
return stream;
}
function processEnv(str) {
return str.replace(
/^( *)this\.require\('(\w+)', '([^']+)'\)/gm,
'$1this.$2 = require(\'$3\')');
}
function processLazy(str) {
str.replace(
/^( *)lazy\('(\w+)', '([^']+)'\)/gm,
function(_, sp, w1, w2) {
str += sp + 'if (0) require(\'' + w2 + '\');\n';
return '';
}
);
return str;
}
function transformer(file, process) {
var stream = new Transform();
var decoder = new StringDecoder('utf8');
var str = '';
stream._transform = function(chunk, encoding, callback) {
assert(Buffer.isBuffer(chunk));
str += decoder.write(chunk);
callback(null, new Buffer(0));
};
stream._flush = function(callback) {
str = process(str);
stream.push(new Buffer(str, 'utf8'));
callback();
};
return stream;
}
function end(file, offset) {
return path.normalize(file).split(path.sep).slice(-offset).join('/');
}
module.exports = function(file) {
if (end(file, 3) === 'lib/utils/utils.js')
return transformer(file, processLazy);
if (end(file, 3) === 'lib/crypto/crypto.js')
return transformer(file, processLazy);
if (end(file, 2) === 'lib/env.js')
return transformer(file, processEnv);
return nil();
};

View File

@ -1,216 +1,204 @@
'use strict';
var net = require('net');
var IOServer = require('socket.io');
var utils = require('../lib/utils/utils');
var IP = require('../lib/utils/ip');
var BufferWriter = require('../lib/utils/writer');
var EventEmitter = require('events').EventEmitter;
const assert = require('assert');
const net = require('net');
const EventEmitter = require('events');
const bsock = require('bsock');
const IP = require('binet');
var TARGET = new Buffer(
'0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
'hex');
class WSProxy extends EventEmitter {
constructor(options) {
super();
function WSProxy(options) {
if (!(this instanceof WSProxy))
return new WSProxy(options);
if (!options)
options = {};
EventEmitter.call(this);
this.options = options;
this.ports = new Set();
this.io = bsock.server();
this.sockets = new WeakMap();
if (!options)
options = {};
if (options.ports) {
for (const port of options.ports)
this.ports.add(port);
}
this.options = options;
this.target = options.target || TARGET;
this.pow = options.pow === true;
this.ports = options.ports || [];
this.io = new IOServer();
this.sockets = new WeakMap();
this._init();
}
utils.inherits(WSProxy, EventEmitter);
WSProxy.prototype._init = function _init() {
var self = this;
this.io.on('error', function(err) {
self.emit('error', err);
});
this.io.on('connection', function(ws) {
self._handleSocket(ws);
});
};
WSProxy.prototype._handleSocket = function _handleSocket(ws) {
var self = this;
var state = new SocketState(this, ws);
// Use a weak map to avoid
// mutating the websocket object.
this.sockets.set(ws, state);
ws.emit('info', state.toInfo());
ws.on('error', function(err) {
self.emit('error', err);
});
ws.on('tcp connect', function(port, host, nonce) {
self._handleConnect(ws, port, host, nonce);
});
};
WSProxy.prototype._handleConnect = function _handleConnect(ws, port, host, nonce) {
var self = this;
var state = this.sockets.get(ws);
var socket, pow;
if (state.socket) {
this.log('Client is trying to reconnect (%s).', state.host);
return;
this.init();
}
if (!utils.isNumber(port)
|| typeof host !== 'string'
|| host.length === 0) {
this.log('Client gave bad arguments (%s).', state.host);
ws.emit('tcp close');
ws.disconnect();
return;
init() {
this.io.on('error', (err) => {
this.emit('error', err);
});
this.io.on('socket', (ws) => {
this.handleSocket(ws);
});
}
if (this.pow) {
if (!utils.isNumber(nonce)) {
this.log('Client did not solve proof of work.', state.host);
ws.emit('tcp close');
ws.disconnect();
handleSocket(ws) {
const state = new SocketState(this, ws);
// Use a weak map to avoid
// mutating the websocket object.
this.sockets.set(ws, state);
ws.on('error', (err) => {
this.emit('error', err);
});
ws.bind('tcp connect', (port, host) => {
this.handleConnect(ws, port, host);
});
}
handleConnect(ws, port, host) {
const state = this.sockets.get(ws);
assert(state);
if (state.socket) {
this.log('Client is trying to reconnect (%s).', state.host);
return;
}
pow = new BufferWriter();
pow.writeU32(nonce);
pow.writeBytes(state.snonce);
pow.writeU32(port);
pow.writeString(host, 'ascii');
pow = pow.render();
if (utils.cmp(utils.hash256(pow), this.target) > 0) {
this.log('Client did not solve proof of work (%s).', state.host);
ws.emit('tcp close');
ws.disconnect();
if ((port & 0xffff) !== port
|| typeof host !== 'string'
|| host.length === 0) {
this.log('Client gave bad arguments (%s).', state.host);
ws.fire('tcp close');
ws.destroy();
return;
}
}
if (!/^[a-zA-Z0-9\.:\-]+$/.test(host)) {
this.log('Client gave a bad host (%s).', state.host);
ws.emit('tcp error', {
message: 'EHOSTUNREACH',
code: 'EHOSTUNREACH'
});
ws.disconnect();
return;
}
if (IP.isPrivate(host)) {
this.log('Client is trying to connect to a private ip (%s).', state.host);
ws.emit('tcp error', {
message: 'ENETUNREACH',
code: 'ENETUNREACH'
});
ws.disconnect();
return;
}
if (this.ports.indexOf(port) === -1) {
this.log('Client is connecting to non-whitelist port (%s).', state.host);
ws.emit('tcp error', {
message: 'ENETUNREACH',
code: 'ENETUNREACH'
});
ws.disconnect();
return;
}
try {
socket = state.connect(port, host);
this.log('Connecting to %s (%s).', state.remoteHost, state.host);
} catch (e) {
this.log(e.message);
this.log('Closing %s (%s).', state.remoteHost, state.host);
ws.emit('tcp error', {
message: 'ENETUNREACH',
code: 'ENETUNREACH'
});
ws.disconnect();
return;
}
socket.on('connect', function() {
ws.emit('tcp connect');
});
socket.on('data', function(data) {
ws.emit('tcp data', data.toString('hex'));
});
socket.on('error', function(err) {
ws.emit('tcp error', {
message: err.message,
code: err.code || null
});
});
socket.on('close', function() {
self.log('Closing %s (%s).', state.remoteHost, state.host);
ws.emit('tcp close');
ws.disconnect();
});
ws.on('tcp data', function(data) {
if (typeof data !== 'string')
let raw, addr;
try {
raw = IP.toBuffer(host);
addr = IP.toString(raw);
} catch (e) {
this.log('Client gave a bad host: %s (%s).', host, state.host);
ws.fire('tcp error', {
message: 'EHOSTUNREACH',
code: 'EHOSTUNREACH'
});
ws.destroy();
return;
socket.write(new Buffer(data, 'hex'));
});
}
ws.on('disconnect', function() {
socket.destroy();
});
};
if (!IP.isRoutable(raw) || IP.isOnion(raw)) {
this.log(
'Client is trying to connect to a bad ip: %s (%s).',
addr, state.host);
ws.fire('tcp error', {
message: 'ENETUNREACH',
code: 'ENETUNREACH'
});
ws.destroy();
return;
}
WSProxy.prototype.log = function log() {
process.stdout.write('wsproxy: ');
console.log.apply(console, arguments);
};
if (!this.ports.has(port)) {
this.log('Client is connecting to non-whitelist port (%s).', state.host);
ws.fire('tcp error', {
message: 'ENETUNREACH',
code: 'ENETUNREACH'
});
ws.destroy();
return;
}
WSProxy.prototype.attach = function attach(server) {
this.io.attach(server);
};
let socket;
try {
socket = state.connect(port, addr);
this.log('Connecting to %s (%s).', state.remoteHost, state.host);
} catch (e) {
this.log(e.message);
this.log('Closing %s (%s).', state.remoteHost, state.host);
ws.fire('tcp error', {
message: 'ENETUNREACH',
code: 'ENETUNREACH'
});
ws.destroy();
return;
}
function SocketState(server, socket) {
this.pow = server.pow;
this.target = server.target;
this.snonce = utils.nonce(true);
this.socket = null;
this.host = IP.normalize(socket.conn.remoteAddress);
this.remoteHost = null;
socket.on('connect', () => {
ws.fire('tcp connect', socket.remoteAddress, socket.remotePort);
});
socket.on('data', (data) => {
ws.fire('tcp data', data.toString('hex'));
});
socket.on('error', (err) => {
ws.fire('tcp error', {
message: err.message,
code: err.code || null
});
});
socket.on('timeout', () => {
ws.fire('tcp timeout');
});
socket.on('close', () => {
this.log('Closing %s (%s).', state.remoteHost, state.host);
ws.fire('tcp close');
ws.destroy();
});
ws.bind('tcp data', (data) => {
if (typeof data !== 'string')
return;
socket.write(Buffer.from(data, 'hex'));
});
ws.bind('tcp keep alive', (enable, delay) => {
socket.setKeepAlive(enable, delay);
});
ws.bind('tcp no delay', (enable) => {
socket.setNoDelay(enable);
});
ws.bind('tcp set timeout', (timeout) => {
socket.setTimeout(timeout);
});
ws.bind('tcp pause', () => {
socket.pause();
});
ws.bind('tcp resume', () => {
socket.resume();
});
ws.on('disconnect', () => {
socket.destroy();
});
}
log(...args) {
process.stdout.write('wsproxy: ');
console.log(...args);
}
attach(server) {
this.io.attach(server);
}
}
SocketState.prototype.toInfo = function toInfo() {
return {
pow: this.pow,
target: this.target.toString('hex'),
snonce: this.snonce.toString('hex')
};
};
class SocketState {
constructor(server, socket) {
this.socket = null;
this.host = socket.host;
this.remoteHost = null;
}
SocketState.prototype.connect = function connect(port, host) {
this.socket = net.connect(port, host);
this.remoteHost = IP.hostname(host, port);
return this.socket;
};
connect(port, host) {
this.socket = net.connect(port, host);
this.remoteHost = IP.toHostname(host, port);
return this.socket;
}
}
module.exports = WSProxy;

View File

@ -1,28 +0,0 @@
version: '2'
services:
bcoin:
build: .
ports:
#-- Mainnet
#- "8333:8333"
#- "8332:8332" # RPC
#-- Testnet
#- "18333:18333"
#- "18332:18332" # RPC
#-- SEGNET4
- "28901:28901"
- "28902:28902" # RPC
environment:
BCOIN_NETWORK: segnet4 # main, testnet
BCOIN_PREFIX: /data
networks:
- "bcoin"
volumes:
- ./docker_data:/data
networks:
bcoin:
external:
# docker network create bcoin
name: "bcoin"

44
docs/README.md Normal file
View File

@ -0,0 +1,44 @@
# Documentation
## Table of contents
- [Getting started](getting-started.md)
- [Configuration](configuration.md)
- [Wallet system](wallet-system.md)
- [Design](design.md)
- [Node and wallet CLI](cli.md)
## External links
- [Guides](https://bcoin.io/guides.html)
- [Running in the browser](https://bcoin.io/guides/browser.html)
- [Node and wallet REST and RPC API](https://bcoin.io/api-docs/index.html)
## Library examples
These code examples are designed to demonstrate how to integrate bcoin modules
with minimal configuration.
- [Simple fullnode](examples/fullnode.js) - Creates a `FullNode` object and
connects to `testnet`.
- [Connect to peer](examples/connect-to-peer.js) - Connects to a user-defined
peer in `regtest` mode.
- [Connecting to the P2P network](examples/connect-to-the-p2p-network.js) -
Creates `chain`, `pool`, and `mempool` objects for both main and
testnet networks.
- [Creating a blockchain and mempool](examples/create-a-blockchain-and-mempool.js) -
Mines a block from the mempool to the chain.
- [Wallet with dummy TX](examples/wallet.js) - Adds a "dummy" transaction to
the wallet and `tx` event is handled.
- [SPV sync](examples/spv-sync-wallet.js) - A transaction matching the SPV
node's bloom filter is broadcast by a minimal full node to the SPV node.
- [Plugin example](examples/peers-plugin.js) - Demonstrates the `plugin`
feature of bcoin's `node` object.
- [Client API usage](examples/client-api.js) - Demonstrates usage of the node
and wallet API.
- [Create and sign TX](examples/create-sign-tx.js) - Demonstrates how to use
`mtx` and `keyring` modules to sign a transaction.
- [Get transaction from chain](examples/get-tx-from-chain.js) - Connects to
live testnet network and syncs the first 1000 blocks with tx indexing active.
- [Create watch only wallet](examples/watch-only-wallet.js) - Imports an `xpub`
into a new watch-only wallet that can derive addresses.

73
docs/cli.md Normal file
View File

@ -0,0 +1,73 @@
# Node and wallet CLI
Bcoin ships with [bclient](https://github.com/bcoin-org/bclient) as its
default client to the [API](https://bcoin.io/api-docs) for command
line access.
## Configuration
Using environment variables:
```bash
$ export BCOIN_API_KEY=hunter2
$ export BCOIN_NETWORK=testnet
$ bcoin --daemon
$ bcoin-cli info
```
With command-line arguments:
```bash
$ bcoin-cli --network=testnet --api-key=hunter2 info
```
You can also use `~/.bcoin/bcoin.conf` for configuration options,
see [Configuration](configuration.md) for the full details.
## Examples
Common node commands:
```bash
# View the genesis block
$ bcoin-cli block 0
# View the mempool
$ bcoin-cli mempool
# Execute an RPC command to list network peers
$ bcoin-cli rpc getpeerinfo
```
Common wallet commands:
```bash
# View primary wallet
$ bwallet-cli get
# View transaction history
$ bwallet-cli history
# Send a transaction
$ bwallet-cli send <address> 0.01
# View balance
$ bwallet-cli balance
# Derive new address
$ bwallet-cli address
# Create a new account
$ bwallet-cli account create foo
# Send from account
$ bwallet-cli send <address> 0.01 --account=foo
```
Get more help:
```bash
$ bcoin-cli help
$ bcoin-cli rpc help
$ bwallet-cli help
$ bwallet-cli rpc help
```

190
docs/configuration.md Normal file
View File

@ -0,0 +1,190 @@
# Configuration
By default, the mainnet bcoin config files will reside in `~/.bcoin/bcoin.conf`
and `~/.bcoin/wallet.conf`. Any parameter passed to bcoin at startup will have
precedence over the config file. Even if you are just running `bclient` without
bcoin installed (to access a remote server, for example) the configuration
files would still reside in `~/.bcoin/`
For example:
``` bash
bcoin --network=regtest --api-key=menace --daemon
```
...will read the config file at `~/.bcoin/regtest/bcoin.conf` and ignore any
`network` or `api-key` parameters listed in that file.
All bcoin configuration options work in the config file, CLI arguments,
process environment, and in the constructor parameters when instantiating
new `node` objects in JavaScript. Each method has slightly different
formatting. Note specifically the usage of hyphens and capital letters.
See the examples below:
| config file | CLI parameter | environment variable | JS object constructor |
|---|---|---|---|
| `network: testnet` | `--network=testnet` | `BCOIN_NETWORK=testnet` | `{network: 'testnet'}` |
| `log-level: debug` | `--log-level=debug` | `BCOIN_LOG_LEVEL=debug` | `{logLevel: 'debug'}` |
| `max-outbound: 8` | `--max-outbound=8` | `BCOIN_MAX_OUTBOUND=8` | `{maxOutbound: 8}`|
## Prefix
Bcoin's data directory is determined by the `prefix` option.
Example:
``` bash
$ bcoin --prefix ~/.bcoin_spv --spv
```
Will create a datadir of `~/.bcoin_spv`, containing a chain database, wallet
database and log file.
## Common options
- `config`: Points to a custom config file, not in the prefix directory.
- `network`: Which network's chainparams to use for the node (main, testnet,
regtest, or simnet) (default: main).
- `workers`: Whether to use a worker process pool for transaction
verification (default: true).
- `workers-size`: Number of worker processes to spawn for transaction
verification. By default, the worker pool will be sized based on the number
of CPUs/cores in the machine.
- `workers-timeout`: Worker process execution timeout in
milliseconds (default: 120000).
- `sigcache-size`: Max number of items in signature cache.
## Node options
- `prefix`: The data directory (stores databases, logs, and configs)
(default=~/.bcoin).
- `db`: Which database backend to use (default=leveldb).
- `max-files`: Max open files for leveldb. Higher generally means more disk
page cache benefits, but also more memory usage (default: 64).
- `cache-size`: Size (in MB) of leveldb cache and write buffer
(default: 32mb).
- `spv`: Enable Simplified Payments Verification (SPV) mode
*Note: The `spv` and `daemon` options can not be entered in `bcoin.conf`.
They will only work when passed as a launch argument:*
```
bcoin --spv --daemon
```
## Logger options
- `log-level`: `error`, `warning`, `info`, `debug`, or `spam` (default: debug).
- `log-console`: `true` or `false` - whether to actually write to stdout/stderr
if foregrounded (default: true).
- `log-file`: Whether to use a log file (default: true).
## Chain options
Note that certain chain options affect the format and indexing of the chain
database and must be passed in consistently.
- `prune`: Prune from the last 288 blocks (default: false).
- `checkpoints`: Use checkpoints and getheaders for the initial
sync (default: true).
- `index-tx`: Index transactions (enables transaction endpoints in REST api)
(default: false).
- `index-address`: Index transactions and utxos by address (default: false).
## Mempool options
- `mempool-size`: Max mempool size in MB (default: 100).
- `replace-by-fee`: Allow replace-by-fee transactions (default: false).
- `persistent-mempool`: Save mempool to disk and read into memory on boot
(default: false).
## Pool options
- `selfish`: Enable "selfish" mode (no relaying of txes or blocks)
(default: false).
- `compact`: Enable compact block relay (default: true).
- `bip37`: Enable serving of bip37 merkleblocks (default: false).
- `listen`: Accept incoming connections (default: true).
- `max-outbound`: Max number of outbound connections (default: 8).
- `max-inbound`: Max number of inbound connections (default: 8).
- `seeds`: Custom list of DNS seeds (comma-separated).
- `host`: Host to listen on (default: 0.0.0.0).
- `port`: Port to listen on (default: 8333).
- `public-host`: Public host to advertise on network.
- `public-port`: Public port to advertise on network.
- `nodes`: List of target nodes to connect to (comma-separated).
- `only`: List of nodes to ONLY connect to (no other nodes or dns seeds will
be contacted).
## Miner options
- `coinbase-flags`: Coinbase flags (default: mined by bcoin).
- `coinbase-address`: List of payout addresses, randomly selected during block
creation (comma-separated).
- `max-block-weight`: Max block weight to mine (default: 4000000).
- `reserved-block-weight`: Amount of space reserved for coinbase
(default: 4000).
- `reserved-block-sigops`: Amount of sigops reserved for coinbase
(default: 400).
## HTTP
- `http-host`: HTTP host to listen on (default: 127.0.0.1).
- `http-port`: HTTP port to listen on (default: 8332 for mainnet).
- `ssl-cert`: Path to SSL cert.
- `ssl-key`: Path to SSL key.
- `service-key`: Service key (used for accessing wallet system only).
- `api-key`: API key (used for accessing all node APIs, may be different than
API key for wallet server).
- `cors`: Enable "Cross-Origin Resource Sharing" HTTP headers (default: false).
Note: For security `cors` should not be used with `no-auth`. \
If enabled you should also enable `wallet-auth` and set `api-key`.
## Wallet options
These options must be saved in `wallet.conf`. They can also be passed as
environment variables or command-line variables if they are preceeded with
a `wallet-` prefix. (See [CHANGELOG.md](https://github.com/bcoin-org/bcoin/blob/master/CHANGELOG.md#configuration-changes))
For example, to run a bcoin and wallet node on a remote server that you can
access from a local machine, you would launch bcoin with the command:
`bcoin --network=testnet --http-host=0.0.0.0 --wallet-http-host=0.0.0.0
--wallet-api-key=hunter2 --wallet-wallet-auth=true`
### Bcoin client:
- `node-host`: Location of bcoin node HTTP server (default: localhost).
- `node-port`: Port of bcoin node HTTP server (defaults to RPC port
of network).
- `node-ssl`: Whether to use SSL (default: false).
- `node-api-key`: API-key for bcoin HTTP server.
### Wallet database:
- `memory`: Keep database in memory rather than write to disk.
- `max-files`: Max open files for leveldb.
- `cache-size`: Size (in MB) of leveldb cache and write buffer.
- `witness`: Make SegWit enabled wallets.
- `checkpoints`: Trust hard-coded blockchain checkpoints.
### Wallet http server:
- `ssl`: Whether to use SSL (default: false).
- `ssl-key`: Path to SSL key.
- `ssl-cert`: Path to SSL cert.
- `http-host`: HTTP host to listen on (default: 127.0.0.1).
- `http-port`: HTTP port to listen on (default: 8334 for mainnet).
- `api-key`: API key (used for accessing all wallet APIs, may be different
than API key for node server).
- `cors`: Enable "Cross-Origin Resource Sharing" HTTP headers (default: false).
- `no-auth`: Disable auth for API server and wallets (default: false).
- `wallet-auth`: Enable token auth for wallets (default: false).
- `admin-token`: Token required if `wallet-auth` is enabled: restricts access
to [all wallet admin routes.](https://bcoin.io/api-docs/#wallet-admin-commands)
## Sample config files
- Node https://github.com/bcoin-org/bcoin/blob/master/etc/sample.conf
- Wallet https://github.com/bcoin-org/bcoin/blob/master/etc/sample.wallet.conf

72
docs/design.md Normal file
View File

@ -0,0 +1,72 @@
# Design
Bcoin is thoroughly event driven. It has a fullnode object, but Bcoin was
specifically designed so the mempool, blockchain, p2p pool, and wallet database
could all be used separately. All the fullnode object does is tie these things
together. It's essentially a huge proxying of events. The general communication
between these things looks something like this:
```
pool -> block event -> chain
pool -> tx event -> mempool
chain -> block event -> mempool/miner
chain -> tx event -> walletdb
chain -> reorg event -> walletdb/mempool/miner
mempool -> tx event -> walletdb/miner
miner -> block event -> chain
walletdb -> tx event -> websocket server
websocket server -> tx event -> websocket client
http client -> tx -> http server -> mempool
```
Not only does the loose coupling make testing easier, it ensures people can
utilize bcoin for many use cases. Learn more about specific events and
event emitters at https://bcoin.io/guides/events.html
## Performance
Non-javscript people reading this may think using JavaScript isn't a wise
decision.
### JavaScript
JavaScript is inherently slow due to how dynamic it is, but modern JITs have
solved this issue using very clever optimization and dynamic recompilation
techniques. v8 in some cases can [rival the speed of C++][v8] if the code is
well-written.
### Concurrency
Bcoin runs in node.js, so the JavaScript code is limited to one thread. We
solve this limitation by spinning up persistent worker processes for
transaction verification (webworkers when in the browser). This ensures the
blockchain and mempool do not block the master process very much. It also means
transaction verification can be parallelized.
Strangely enough, workers are faster in the browser than they are in node since
you are allowed to share memory between threads using the transferable API
(Uint8Arrays can be "transferred" to another thread). In node, you have to pipe
data to another process.
But of course, there is a benefit to having a multi-process architecture: the
worker processes can die on their own without disturbing the master process.
Bcoin uses [secp256k1-node][secp256k1-node] for ECDSA verification, which is a
node.js binding to Pieter Wuille's blazingly fast [libsecp256k1][libsecp256k1]
library.
In the browser, bcoin will use [elliptic][elliptic], the fastest JavaScript
ECDSA implementation. It will obviously never beat C and hand-optimized
assembly, but it's still usable.
### Benefits
The real feature of JavaScript is that your code will run almost anywhere. With
bcoin, we now have a full node that will run on almost any browser, on laptops,
on servers, on smartphones, on most devices you can imagine, even by simply
visiting a webpage.
[v8]: https://www.youtube.com/watch?v=UJPdhx5zTaw
[libsecp256k1]: https://github.com/bitcoin-core/secp256k1
[secp256k1-node]: https://github.com/cryptocoinjs/secp256k1-node
[elliptic]: https://github.com/indutny/elliptic

144
docs/examples/client-api.js Normal file
View File

@ -0,0 +1,144 @@
'use strict';
const bcoin = require('../..');
const client = require('bclient');
const plugin = bcoin.wallet.plugin;
const network = bcoin.Network.get('regtest');
const node = new bcoin.FullNode({
network: 'regtest',
memory: true
});
node.use(plugin);
const walletClient = new client.WalletClient({
port: network.walletPort
});
const nodeClient = new client.NodeClient({
port: network.rpcPort
});
async function fundWallet(wdb, addr) {
// Coinbase
const mtx = new bcoin.MTX();
mtx.addOutpoint(new bcoin.Outpoint(bcoin.consensus.ZERO_HASH, 0));
mtx.addOutput(addr, 50460);
mtx.addOutput(addr, 50460);
mtx.addOutput(addr, 50460);
mtx.addOutput(addr, 50460);
const tx = mtx.toTX();
walletClient.bind('balance', (walletID, balance) => {
console.log('New Balance:');
console.log(walletID, balance);
});
walletClient.bind('address', (walletID, receive) => {
console.log('New Receiving Address:');
console.log(walletID, receive);
});
walletClient.bind('tx', (walletID, details) => {
console.log('New Wallet TX:');
console.log(walletID, details);
});
await wdb.addTX(tx);
await new Promise(r => setTimeout(r, 300));
}
async function sendTX(addr, value) {
const options = {
rate: 10000,
outputs: [{
value: value,
address: addr
}]
};
// API call: walletClient.send('test', options)
const tx = await walletClient.request('POST', '/wallet/test/send', options);
return tx.hash;
}
async function callNodeApi() {
// API call: nodeClient.getInfo()
const info = await nodeClient.request('GET', '/');
console.log('Server Info:');
console.log(info);
const json = await nodeClient.execute(
'getblocktemplate',
[{rules: ['segwit']}]
);
console.log('Block Template (RPC):');
console.log(json);
}
(async () => {
const wdb = node.require('walletdb').wdb;
await node.open();
// API call: walletClient.createWallet('test')
const testWallet = await walletClient.request('PUT', '/wallet/test');
console.log('Wallet:');
console.log(testWallet);
// open socket to listen for events
await walletClient.open();
// subscribe to events from all wallets
walletClient.all();
// Fund default account.
// API call: walletClient.createAddress('test', 'default')
const receive = await walletClient.request(
'POST',
'/wallet/test/address',
{account: 'default'}
);
await fundWallet(wdb, receive.address);
// API call: walletClient.getBalance('test', 'default')
const balance = await walletClient.request(
'GET',
'/wallet/test/balance',
{account: 'default'}
);
console.log('Balance:');
console.log(balance);
// API call: walletClient.createAccount('test', 'foo')
const acct = await walletClient.request('PUT', '/wallet/test/account/foo');
console.log('Account:');
console.log(acct);
// Send to our new account.
const hash = await sendTX(acct.receiveAddress, 10000);
console.log('Sent TX:');
console.log(hash);
// API call: walletClient.getTX('test', hash)
const tx = await walletClient.request('GET', `/wallet/test/tx/${hash}`);
console.log('Sent TX details:');
console.log(tx);
await callNodeApi();
await walletClient.close();
await node.close();
})().catch((err) => {
console.error(err.stack);
process.exit(1);
});

View File

@ -0,0 +1,50 @@
'use strict';
/*
* Usage:
* Run another Bitcoin node on local regtest network, for example
* $ ../../bin/bcoin --network=regtest
* Execute this script with the other node's address and port
* $ node connect-to-peer.js 127.0.0.1:48444
*/
const bcoin = require('../..');
const network = bcoin.Network.get('regtest');
const peer = bcoin.Peer.fromOptions({
network: 'regtest',
agent: 'my-subversion',
hasWitness: () => {
return false;
}
});
const addr = bcoin.net.NetAddress.fromHostname(process.argv[2], 'regtest');
console.log(`Connecting to ${addr.hostname}`);
peer.connect(addr);
peer.tryOpen();
peer.on('error', (err) => {
console.error(err);
});
peer.on('packet', (msg) => {
console.log(msg);
if (msg.cmd === 'block') {
console.log('Block!');
console.log(msg.block.toBlock());
return;
}
if (msg.cmd === 'inv') {
peer.getData(msg.items);
return;
}
});
peer.on('open', () => {
peer.getBlock([network.genesis.hash]);
});

View File

@ -0,0 +1,117 @@
'use strict';
const bcoin = require('../..').set('main');
const Logger = require('blgr');
// Setup logger to see what's Bcoin doing.
const logger = new Logger({
level: 'info'
});
// Create a blockchain and store it in memory.
const chain = new bcoin.Chain({
memory: true,
network: 'main',
logger: logger
});
const mempool = new bcoin.Mempool({
chain: chain,
logger: logger
});
// Create a network pool of peers with a limit of 8 peers.
const pool = new bcoin.Pool({
chain: chain,
mempool: mempool,
maxPeers: 8,
logger: logger
});
(async function() {
await logger.open();
await chain.open();
await pool.open();
// Connect, start retrieving and relaying txs
await pool.connect();
// Start the blockchain sync.
pool.startSync();
// Watch the action
const color = '\x1b[31m';
chain.on('block', (block) => {
console.log(color, 'Added mainnet block:');
console.log(block.rhash());
});
mempool.on('tx', (tx) => {
console.log(color, 'Added mainnet tx to mempool:');
console.log(tx.rhash);
});
pool.on('tx', (tx) => {
console.log(color, 'Saw mainnet transaction:');
console.log(tx.rhash);
});
})().catch((err) => {
console.error(err.stack);
process.exit(1);
});;
// Start up a testnet sync in-memory
// while we're at it (because we can).
const tchain = new bcoin.Chain({
memory: true,
network: 'testnet',
logger: logger
});
const tmempool = new bcoin.Mempool({
network: 'testnet',
chain: tchain,
logger: logger
});
const tpool = new bcoin.Pool({
network: 'testnet',
chain: tchain,
mempool: tmempool,
size: 8,
logger: logger
});
(async function() {
await tchain.open();
await tpool.open();
// Connect, start retrieving and relaying txs
await tpool.connect();
// Start the blockchain sync.
tpool.startSync();
const color = '\x1b[32m';
tchain.on('block', (block) => {
console.log(color, 'Added testnet block:');
console.log(block.rhash());
});
tmempool.on('tx', (tx) => {
console.log(color, 'Added testnet tx to mempool:');
console.log(tx.rhash);
});
tpool.on('tx', (tx) => {
console.log(color, 'Saw testnet transaction:');
console.log(tx.rhash);
});
})().catch((err) => {
console.error(err.stack);
process.exit(1);
});

View File

@ -0,0 +1,43 @@
'use strict';
const bcoin = require('../..');
// Default network (so we can avoid passing
// the `network` option into every object below.)
bcoin.set('regtest');
// Start up a blockchain, mempool, and miner using in-memory
// databases (stored in a red-black tree instead of on-disk).
const chain = new bcoin.Chain({ network: 'regtest', memory: true });
const mempool = new bcoin.Mempool({ chain: chain });
const miner = new bcoin.Miner({
chain: chain,
mempool: mempool,
// Make sure miner won't block the main thread.
useWorkers: true
});
(async () => {
// Open the chain
await chain.open();
// Open the miner (initialize the databases, etc).
// Miner will implicitly call `open` on mempool.
await miner.open();
// Create a Cpu miner job
const job = await miner.createJob();
// run miner
const block = await job.mineAsync();
// Add the block to the chain
console.log('Adding %s to the blockchain.', block.rhash());
console.log(block);
await chain.add(block);
console.log('Added block!');
})().catch((err) => {
console.error(err.stack);
process.exit(1);
});

View File

@ -0,0 +1,79 @@
'use strict';
/* eslint new-cap: "off" */
const bcoin = require('../..');
const assert = require('assert');
(async () => {
const master = bcoin.hd.generate();
const key = master.derivePath('m/44\'/0\'/0\'/0/0');
const keyring = new bcoin.wallet.WalletKey(key.privateKey);
const cb = new bcoin.MTX();
cb.addInput({
prevout: new bcoin.Outpoint(),
script: new bcoin.Script(),
sequence: 0xffffffff
});
// Send 50,000 satoshis to ourselves.
cb.addOutput({
address: keyring.getAddress(),
value: 50000
});
// Our available coins.
const coins = [];
// Convert the coinbase output to a Coin
// object and add it to our available coins.
// In reality you might get these coins from a wallet.
const coin = bcoin.Coin.fromTX(cb, 0, -1);
coins.push(coin);
// Create our redeeming transaction.
const mtx = new bcoin.MTX();
// Send 10,000 satoshis to ourself.
mtx.addOutput({
address: keyring.getAddress(),
value: 10000
});
// Now that we've created the output, we can do some coin selection (the
// output must be added first so we know how much money is needed and also so
// we can accurately estimate the size for fee calculation).
// Select coins from our array and add inputs.
// Calculate fee and add a change output.
await mtx.fund(coins, {
// Use a rate of 10,000 satoshis per kb.
// With the `fullnode` object, you can
// use the fee estimator for this instead
// of blindly guessing.
rate: 10000,
// Send the change back to ourselves.
changeAddress: keyring.getAddress()
});
// Sign input 0
mtx.sign(keyring);
// The transaction should now verify.
assert(mtx.verify());
// Commit our transaction and make it immutable.
// This turns it from an MTX into a TX.
const tx = mtx.toTX();
// The transaction should still verify.
// Regular transactions require a coin
// viewpoint to be passed in.
assert(tx.verify(mtx.view));
console.log(mtx);
})().catch((err) => {
console.error(err.stack);
process.exit(1);
});

27
docs/examples/fullnode.js Normal file
View File

@ -0,0 +1,27 @@
'use strict';
const bcoin = require('../..');
const node = new bcoin.FullNode({
memory: true,
network: 'testnet',
workers: true
});
(async () => {
await node.open();
await node.connect();
node.on('connect', (entry, block) => {
console.log('%s (%d) added to chain.', entry.rhash(), entry.height);
});
node.on('tx', (tx) => {
console.log('%s added to mempool.', tx.txid());
});
node.startSync();
})().catch((err) => {
console.error(err.stack);
process.exit(1);
});

View File

@ -0,0 +1,81 @@
'use strict';
const bcoin = require('../..');
const fs = require('bfile');
// Create chain for testnet, stored in memory by default.
// To store the chain on disk at the `prefix` location,
// set `memory: false`.
const chain = new bcoin.Chain({
network: 'testnet',
indexTX: true,
indexAddress: true,
db: 'leveldb',
prefix: '/tmp/bcoin-testnet-example',
memory: true
});
// Create a network pool of peers with a limit of 8 peers.
const pool = new bcoin.Pool({
chain: chain,
maxPeers: 8
});
(async () => {
// Ensure the directory exists if we are writing to disk
if (!chain.options.memory)
await fs.mkdirp(chain.options.prefix);
await chain.open();
// Connect the blockchain to the network
await pool.open();
await pool.connect();
pool.startSync();
// Monitor blockchain height and react when we hit the target
chain.on('connect', async (entry, block) => {
const height = entry.height;
console.log(
`Height: ${chain.height} ` +
`Block: ${entry.rhash()} ` +
`TXs: ${block.txs.length}`
);
if (height === 1000) {
const entry = await chain.getEntry(1000);
console.log('Block at height 1000:\n', entry);
// testnet tx at height 500
const txhash =
'fc407d7a3b819daa5cf1ecc2c2a4b103c3782104d1425d170993bd534779a0da';
const txhashBuffer = Buffer.from(txhash, 'hex').reverse();
const txmeta = await chain.db.getMeta(txhashBuffer);
const tx = txmeta.tx;
const coinview = await chain.db.getSpentView(tx);
console.log(`Tx with hash ${txhash}:\n`, txmeta);
console.log(
`\n Input value: ${tx.getInputValue(coinview)}` +
`\n Output value: ${tx.getOutputValue()}` +
`\n Fee: ${tx.getFee(coinview)}`
);
// testnet block at height 800
const hash =
Buffer.from(
'000000004df86f64cca38c6587df348e0c6849ebee628b3f840f552c707cc862',
'hex'
);
// chainDB indexes blocks by the REVERSE (little endian) hash
const block = await chain.getBlock(hash.reverse());
console.log(`Block with hash ${hash.toString('hex')}:`, block);
process.exit(1);
}
});
})().catch((err) => {
console.error(err.stack);
process.exit(1);
});

View File

@ -0,0 +1,50 @@
'use strict';
const bcoin = require('../..');
function MyPlugin(node) {
this.node = node;
}
MyPlugin.id = 'my-plugin';
MyPlugin.init = function init(node) {
return new MyPlugin(node);
};
MyPlugin.prototype.open = function open() {
console.log('Opened my plugin.');
return Promise.resolve();
};
MyPlugin.prototype.close = function close() {
console.log('Closed my plugin.');
return Promise.resolve();
};
MyPlugin.prototype.sayPeers = function sayPeers() {
console.log('Number of peers: %d', this.node.pool.peers.size());
};
const node = new bcoin.FullNode({
memory: true,
network: 'testnet',
workers: true
});
node.use(MyPlugin);
(async () => {
const plugin = node.require('my-plugin');
await node.open();
await node.connect();
plugin.sayPeers();
await node.close();
})().catch((err) => {
console.error(err.stack);
process.exit(1);
});

View File

@ -0,0 +1,84 @@
'use strict';
const bcoin = require('../..');
bcoin.set('regtest');
// SPV chains only store the chain headers.
const chain = new bcoin.Chain({
spv: true
});
const pool = new bcoin.Pool({
chain: chain,
maxOutbound: 1
});
const walletdb = new bcoin.wallet.WalletDB({ memory: true });
// Full node will provide tx data to SPV node
const full = {};
full.chain = new bcoin.Chain();
full.pool = new bcoin.Pool({
chain: full.chain,
port: 44444,
bip37: true,
listen: true
});
(async () => {
await pool.open();
await walletdb.open();
await chain.open();
await pool.connect();
await full.pool.open();
await full.chain.open();
await full.pool.connect();
const wallet = await walletdb.create();
const walletAddress = await wallet.receiveAddress();
console.log('Created wallet with address %s', walletAddress);
// Add our address to the SPV filter.
pool.watchAddress(walletAddress);
// Start the blockchain sync.
pool.startSync();
// Get ready to receive transactions!
pool.on('tx', (tx) => {
console.log('Received TX:\n', tx);
walletdb.addTX(tx);
console.log('TX added to wallet DB!');
});
wallet.on('balance', (balance) => {
console.log('Balance updated:\n', balance.toJSON());
});
// Connect the SPV node to the full node server
const netAddr = await pool.hosts.addNode('127.0.0.1:44444');
const peer = pool.createOutbound(netAddr);
pool.peers.add(peer);
full.pool.on('peer open', async () => {
console.log('SPV node peers:\n', pool.peers);
console.log('Full node peers:\n', full.pool.peers);
// Create a dummy transaction and send it from full to SPV node
const mtx = new bcoin.MTX();
mtx.addOutpoint(new bcoin.Outpoint(bcoin.consensus.ZERO_HASH, 0));
mtx.addOutput(walletAddress, 12000);
const tx = mtx.toTX();
// Give the node a few seconds to process connection before sending
console.log('Waiting for transaction...');
await new Promise(r => setTimeout(r, 3000));
await full.pool.broadcast(tx);
});
})().catch((err) => {
console.error(err.stack);
process.exit(1);
});

45
docs/examples/wallet.js Normal file
View File

@ -0,0 +1,45 @@
'use strict';
const bcoin = require('../..');
const random = require('bcrypto/lib/random');
function dummy() {
const hash = random.randomBytes(32);
return new bcoin.Outpoint(hash, 0);
}
const walletdb = new bcoin.wallet.WalletDB({
network: 'testnet',
memory: true
});
(async () => {
await walletdb.open();
const wallet = await walletdb.create();
console.log('Created wallet');
console.log(wallet);
const acct = await wallet.createAccount({
name: 'foo'
});
console.log('Created account');
console.log(acct);
const mtx = new bcoin.MTX();
mtx.addOutpoint(dummy());
mtx.addOutput(acct.receiveAddress(), 50460);
const tx = mtx.toTX();
wallet.on('tx', (tx) => {
console.log('Received transaciton:\n', tx);
});
await walletdb.addTX(tx);
})().catch((err) => {
console.error(err.stack);
process.exit(1);
});

View File

@ -0,0 +1,70 @@
'use strict';
const bcoin = require('../..');
(async () => {
// use well known test mnemonic
const phrase = [
'abandon', 'abandon', 'abandon', 'abandon',
'abandon', 'abandon', 'abandon', 'abandon',
'abandon', 'abandon', 'abandon', 'about'
].join(' ');
const network = bcoin.Network.get('regtest');
const mnemonic = bcoin.Mnemonic.fromPhrase(phrase);
// m'
const priv = bcoin.HDPrivateKey.fromMnemonic(mnemonic);
// m'/44'
const bip44Key = priv.derive(44, true);
// m'/44'/0'
const bitcoinKey = bip44Key.derive(0, true);
// m'/44'/0'/0'
const accountKey = bitcoinKey.derive(0, true);
// account extended public key
// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#Serialization_format
const xpub = accountKey.xpubkey(network.type);
console.log('xpub to import:\n', xpub);
// recommended to use hardware wallet to derive keys
// see github.com/bcoin-org/bledger
// create watch only wallet
// the wallet will generate lookahead
// addresses from the account extended public key
// and can find spendable coins in the blockchain state
const wdb = new bcoin.wallet.WalletDB({
network: 'regtest',
memory: true
});
await wdb.open();
// new wallet still generates a master private key, but it will not be used
const wallet = await wdb.create({
name: 'my-watch-only-wallet',
accountKey: xpub,
watchOnly: true
});
// xpub account key placed at Account 0. Address 0 is already derived.
const acct0 = await wallet.getAccount(0);
// create new receive addresses through the deterministic chain
const key1 = await wallet.createReceive(0);
const addr1 = key1.getAddress('string', 'regtest');
const key2 = await wallet.createReceive(0);
const addr2 = key2.getAddress('string', 'regtest');
console.log('Wallet:\n', wallet);
console.log('Account:\n', acct0);
console.log('Address 1:\n', addr1);
console.log('Address 2:\n', addr2);
})();

218
docs/getting-started.md Normal file
View File

@ -0,0 +1,218 @@
# Getting started
## Introduction
Bcoin is an _alternative_ implementation of the bitcoin protocol, written in
node.js. It is a full node which can be used for full blockchain validation
and is aware of all known consensus rules.
## Requirements
- Linux, OSX, or Windows (\*) (\*\*)
- node.js >=v8.14.0
- npm >=v6.4.1
- python2 (for node-gyp)
- gcc/g++ (for leveldb and secp256k1)
- git (optional, see below)
(\*): Note that bcoin works best with unix-like OSes, and has not yet been
thoroughly tested on windows.
(\*\*): The BSDs and Solaris have also not been tested yet, but should work
in theory.
## Build & install
Bcoin is meant to be installed via git for security purposes, as there
are security issues when installing via npm. All tagged commits for
release should be signed by @chjj's [PGP key][keybase]
(`B4B1F62DBAC084E333F3A04A8962AB9DE6666BBD`). Signed copies of node.js
are available from [nodejs.org][node], or from your respective OS's
package repositories.
### Installing via Git
``` bash
$ curl https://keybase.io/chjj/pgp_keys.asc | gpg --import
$ git clone git://github.com/bcoin-org/bcoin.git
$ cd bcoin
```
For a specific release:
```
$ git tag
$ git tag -v <version> # verify signature
$ git checkout <version>
```
Install dependencies:
```
$ npm install
$ npm install -g # link globally
```
**Note:** Dependencies are checked for integrity using `package-lock.json`.
However `npm` _will not_ make these checks with `npm install -g` and it
will link your installation globally so that `bcoin` is in your
path _(e.g. $ bcoin)_.
### Installing via Docker
Check [bcoin-docker](https://github.com/bcoin-org/bcoin-docker)
### Installing on Windows
Install OpenSSL v1.0.2L 64-Bit:
https://slproweb.com/download/Win64OpenSSL-1_0_2L.exe
As Administrator, open `cmd.exe` and run:
```console
C:\Users\bcoin\bcoin>npm install --global --production windows-build-tools
```
to install `VCBuild.exe` and `Python 2.7.x` both required by `node-gyp`
for building native modules.
Then continue [Installing via Git](#installing-via-git)
Note that you need a shell that supports bash scripts, like Git Bash to launch
bcoin.
### Troubleshooting
If the build fails compilation for `bcoin-native` or `secp256k1-node`
__validation will be slow__ (a block verification which should take 1 second
on consumer grade hardware may take up to 15 seconds). Bcoin will throw a
warning on boot if it detects a build failure. If you run into this issue,
please post an issue on the repo.
## Starting up your first bcoin node
If bcoin is installed globally, `$ bcoin` should be in your PATH. If not,
the bcoin bootstrap script resides in `/path/to/bcoin/bin/bcoin`.
``` bash
$ bcoin
```
Will run a bcoin node as the foreground process, displaying all debug logs.
To run as a daemon:
``` bash
$ bcoin --daemon
```
This will start up a full node, complete with: a blockchain, mempool, miner,
p2p server, wallet server, and an HTTP REST+RPC server.
All logs will be written to `~/.bcoin/debug.log` by default.
By default, the http server will only listen on `127.0.0.1:8332`. No auth
will be required if an API key was not passed in. If you listen on any other
host, auth will be required and an API key will be auto-generated if one was
not passed in.
## Listening externally
To listen publicly on the HTTP server, `--http-host=0.0.0.0` (ipv4) or
`--http-host=::` (ipv4 and ipv6) can be passed. Additionally this:
`--http-port=1337` can set the port.
To advertise your node on the P2P network `--public-host=[your-public-ip]`
and `--public-port=[your-public-port]` may be passed.
## Using an API Key
If listening publicly on the HTTP server, an API key is required. One will
be randomly generated if no key was chosen, but not explicitly reported to
the user. An API key can be chosen with the `--api-key` option.
Example:
``` bash
$ bcoin --http-host=0.0.0.0 --api-key hunter2 --daemon
```
API keys are used with HTTP Basic Auth:
``` bash
$ curl http://x:hunter2@localhost:8332/
```
[bclient](https://github.com/bcoin-org/bclient) is the prepackaged tool for
querying both the REST and RPC APIs. If bcoin is installed globally, both
`bcoin-cli` and `bwallet-cli` should be on your path.
``` bash
$ bcoin-cli info --api-key hunter2
$ bcoin-cli rpc getblockchaininfo --api-key hunter2
$ bwallet-cli balance
```
## Using Tor/SOCKS
Bcoin has native support for SOCKS proxies, and will accept a `--proxy` option
in the format of `--proxy=[user]:[pass]@host:port`.
Passing the `--onion` option tells bcoin that the SOCKS proxy is a Tor socks
proxy, and will enable Tor resolution for DNS lookups, as well as try to
connect to `.onion` addresses found on the P2P network.
``` bash
$ bcoin --proxy joe:hunter2@127.0.0.1:9050 --onion
```
### Running bcoin as a tor hidden service
Your hidden service must first be configured with `tor`. Once you have the
`.onion` address, it can be passed into `--public-host` in the form
of `--public-host foo.onion`.
## Target nodes
It's often desirable to run behind several trusted bitcoin nodes. To select
permanent nodes to connect to, the `--nodes` option is available:
``` bash
$ bcoin --nodes foo.example.com:8333,1.2.3.4:8333,5.6.7.8:8333
```
If chosen, bcoin will _always_ try to connect to these nodes as outbound
peers. They are top priority and whitelisted (not susceptible to permanent
bans, only disconnections).
To _only_ connect to these nodes, use `--only`
``` bash
$ bcoin --only foo.example.com,1.2.3.4,5.6.7.8
```
## Disabling listening
To avoid accepting connections on the P2P network altogether,
`--listen=false` can be passed to bcoin.
### Selfish mode
Bcoin also supports a "selfish" mode. In this mode, bcoin still has full
blockchain and mempool validation, but network services are disabled: it
will not relay transactions or serve blocks to anyone.
``` bash
$ bcoin --selfish --listen=false
```
Note: Selfish mode is not recommended. We encourage you to _help_ the network
by relaying transactions and blocks. At the same time, selfish mode does have
its uses if you do not have the bandwidth to spare, or if you're absolutely
worried about potential DoS attacks.
## Further configuration
See [Configuration][configuration].
[keybase]: https://keybase.io/chjj#show-public
[node]: https://nodejs.org
[configuration]: configuration.md

53
docs/wallet-system.md Normal file
View File

@ -0,0 +1,53 @@
# Wallet system
Bcoin maintains a wallet database which contains every wallet. Wallets are
_not usable_ without also using a wallet database. For testing, the wallet
database can be in-memory, but it must be there.
Wallets in bcoin are based on BIP44. They also originally supported BIP45 for
multisig, but support was removed to reduce code complexity, and also because
BIP45 doesn't seem to add any benefit in practice.
The wallet database can contain many wallets, with many accounts, with many
addresses for each account. Bcoin should theoretically be able to scale to
hundreds of thousands of wallets/accounts/addresses.
## Deviation from BIP44
**It's important to backup the wallet database.** There are several deviations
from [BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki)
that break the determinsitic algorithm, and therefore it's recommended to
backup the wallet database any time an account is created, as there are several
possible configurations of an account.
There is a command available via the wallet RPC called `backupwallet` that can
clone the database to a new destination. There are also the RPC calls
`dumpwallet` and `dumpprivkey` for exporting private keys. After shutting down
the wallet process, it's also possible to copy the LevelDB database from the
default location at `~/.bcoin/wallet` for main net or
`~/.bcoin/<network>/wallet` for others. Copying LevelDB while the process is
running can result in a corrupted copy. LevelDB is also prone to
[database corruption](https://en.wikipedia.org/wiki/LevelDB#Bugs_and_reliability).
Each account can be of a different type. You could have a pubkeyhash account,
a multisig account, and a witness pubkeyhash account all in the same wallet.
Accounts can be configured with or without Segregated Witness and both base58
(nested-in-P2SH) and bech32 (native) P2WPKH addresses can be derived from the
same account.
Bcoin adds a third branch to each account for nested SegWit addresses.
Branch `0` and `1` are for `receive` and `change` addresses respectively
(which is BIP44 standard) but branch `2` is used by bcoin to derive
[nested SegWit addresses.](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki#P2WPKH_nested_in_BIP16_P2SH)
Accounts in a bcoin wallet can be configured for multisig and import xpubs
from cosigners. Externally-generated Extended Private Keys (`xpriv`) and non-HD
single address private keys can all be imported into a bcoin wallet. Balances
of those addresses can be watched as well spent from (in the case of a private
key).
Unlike [BIP44](https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki),
bcoin does not limit account depth and a new account can be created
after an empty account. This can create issues with deterministic account
discovery from the master node (seed) as there are `2 ^ 31 - 1` _(worst case)_
possible accounts to search.

View File

@ -1 +0,0 @@
02b9f7499c4166e76d3a64326bbbe92dc02f0e07dc184f94995da61683c311cb0f

View File

@ -1,152 +0,0 @@
[
"ebd41040e4bb3ec742c9e381d31ef2a41a48b6685c96e7cef3c1df6cd4331c99",
"ca42dd41745fd0b81eb902362cf9d8bf719da1bd1b1efc946f5b4c99f42c1b9e",
"eb04cf5eb1f39afa762f2bb120f296cba520c1b97db1589565b81cb9a17b7244",
"6dc47172e01cbcb0bf62580d895fe2b8ac9ad4f873801e0c10b9c837d21eb177",
"16af57a9f676b0ab126095aa5ebadef22ab31119d644ac95cd4b93dbf3f26aeb",
"8c7209279ac04e275e16d07fd3b775e80154b5968046e31f52dd25766324e9a7",
"687fa451382278fff0c8b11f8d43d576671c6eb2bceab413fb83d965d06d2ff2",
"0791ca0749b20782aad3c7d7bd0cdfc9485835843eb2d7996009ce43ab6c6927",
"8095210805db4bbc355e4428d8fd6ec2cde3ab5fb97a9942988eb8f4dcd06016",
"73c176434f1bc6d5adf45b0e76e727287c8de57616c1e6e6141a2b2cbc7d8e4c",
"af8b6762a1e528228161a95d5c559ee266278f75d79e830189a503506abd6b4c",
"ff856a2d251dcd88d36656f450126798cfabaade40799c722de4d2b5db36a73a",
"ca2d82a08677072f8ab6764ff035676cfe3e5e325e012172df3f92096db79b85",
"a0459b9f63b22559f5fa5d4c6db3f9f72ff19342033578f073bf1d1b46cbb912",
"a0234f3bc8527ca5628eec81ad5d69895da5680dc91d1cb8477f33f878b95b0b",
"69fac9bd55fb0ac78d53bbee5cf1d597989fd0aaab20a25151bdf1733ee7d122",
"d8e0febc1db2e38d00940f37d27d41344d993e734b99d5656d9778d4d8143624",
"d7a7a0fb5d7e2731d771e9484ebcdef71d5f0c3e0a2948782bc83ee0ea699ef4",
"bd81ce3b4f6591d11a67b5fc7a47fdef25521bf9aa4e18b9e3df2e34a7803be8",
"3f06e55681d496f5be169eb5389f9f2b8ff61e1708df6881724849cd5d27cb69",
"a45ede3bbbf09c8ae15c72efc07268d693a21c996fd51e67ca079460fd6d8873",
"85a0dd7dd720adb7ff05f83d542b209dc7ff4528f7d677b18389fea5e5c49e86",
"18f1fc7f205df8adddeb7fe007dd57e3af375a9c4d8d73546bf4f1fed1e18d35",
"e75e72ed9f560eec6eb4800073a43fc3ad19195a392282017895974a99026b6c",
"7908b40314c138100b518d0735807ffbfcf8518a0095337105ba386b153dd927",
"6ea54741d004667eed1b4816634aa3a79e6e4b96950f8279dafc8d9bd8812137",
"0c258a12a5674aef25f28ba7dcfaeceea348e541e6f5cc4ee63b71b361606ac3",
"ef3cb417fc8ebf6f97876c9e4ece39de1ea5fe649141d1028b7d11c0b2298ced",
"cecddc905099d8dadfc5b1d209b737cbe2c18cfb2c10c0ff0bcf0d3286fc1aa2",
"c3846bf24b9e93ca64274c0ec67c1ecc5e024ffcacd2d74019350e81fe546ae4",
"1465fa205397b876faa6f0a9958e5590e40fcc7faa4fb7c2c8677521fb5fb658",
"c766a9bef2d4071c863a31aa4920e813b2d198608cb7b7cfe21143b836df09ea",
"7600295eefe85b9e1fd624db76062aaaae59818a54d2774cd4c0b2c01131e1b3",
"21db20123660bb2ed418205da11ee7a85a65e2bc6e55b5af7e7899c8a266d92e",
"3e9099b5015e8f486c00bcea9d111ee721faba355a89bcf1df69561e3dc6325c",
"4348a0e9444c78cb265e058d5e8944b4d84f9662bd26db257f8934a443c70161",
"7431e5f4c3c1ce4690774f0b61e05440883ba9a01ed00ba6abd7806ed3b118cf",
"0f993c8aef97baaf5687140ed59ad1821bb4afacf0aa9a58b5d57a338a3afbcb",
"0687260331a72403d909f105e69bcf0d32e1bd2493ffc6d9206d11bcd6770739",
"767c955a76412c89af688e90a1c70f556cfd6b6025dbea10416d7eb6831f8c40",
"62dd0be9b9f50a163ea0f8e75c053b1eca57ea55c8688f647c6881f2c8357b95",
"be6c4da2bbb9ba59b6f3939768374246c3c005993fa98f020d1dedbed48a81d5",
"37d51006c512eaab626421f1ec8c92013fc5f82ae98ee533eb4619b8deb4d06c",
"8d722f81a9c113c0791df136a2966db26c950a971db46b4199f4ea54b78bfb9f",
"9acfab7e43c8d880d06b262a94deeee4b4659989c3d0caf19baf6405e41ab7df",
"f1c1b50ae5a20dd8030ec9f6bc24823dd367b5255759b4e71b61fce9f7375d73",
"4200f5043ac8590ebb527d209ed1503029fbcbd41ca1b506ec27f15ade7dac69",
"0c2cd63df7806fa399ede809116b575bf87989f06518f9808c860503178baf66",
"15f0ba00a3ac7af3ac884c072b1011a077bd77c097f40164b2f8598abd83860c",
"a71272aeaaa3cfe8727f7fb39f0fb3d1e5426e9060b06ee6f13e9a3c5833cd43",
"1793927a0614549789adce2f8f34f7f0b66d0f3ae3a3b84d21ec15dbba4fadc7",
"b9bea7860a962ea3611dab97ab6da3e21c1068b97d55575ed0e11279c11c8932",
"a22dba681e97376e2d397d728aae3a9b6296b9fdba60bc2e11f647f2c675fb37",
"41c923866ab4cad6b7ad578081582e020797a6cbdf4fff78ce8396b38937d7f5",
"327a3d761abadea034eb998406275cb1a4776efdae2fdf6d0168ea1c4f5567d0",
"e3b6a2db2ed7ce48842f7ac53241c7b71d54144bfb40c11f3f1d0b42f5eea12d",
"b6191a50d0c3977f7da99bcdaac86a227daeb9679ec70ba3b0c9d92271c170d3",
"960adf0063e96356750c2965dd0a0867da0b9cbd6e77714aeafb2349ab393da3",
"c0a6f4dc63a24bfdcf54ef2a6a082a0a72de35803e2ff5ff527ae5d87206dfd5",
"e4c73430d7a5b50925df43370a0d216e9a79b9d6db8373a0c69eb1cc31c7c52a",
"0f4e9cdd264b025550d170806340214fe94434c9b02f697ec710fc5feafb5e38",
"35ae5bddd8f7ae635cffba5682a8f00b95f48462c7108ee9a0e5292b074aafb2",
"eaa962c4fa4a6bafebe415196d351ccd888d4f53f3fa8ae6d7c466a94e6042bb",
"e28393773da845a679f2080cc7fb44a3b7a1c3792cb7eb7729fdcb6a8d99aea7",
"2d47437de17951215a12f3c58e51c729a58026ef1fcc0a5fb3d9dc012f600d19",
"b478b812250df878635c2aa7ec7d155eaa625ee82916e2cd294361886cd1fbd4",
"a4310d50af18a6447190372a86afaf8b951ffb431d837f1e5688b45971ed1557",
"4b03f45807ad70f21bfc2cae71c9fde4604c064cf5ffb686bae5dbaad7fdd34c",
"5edb7ac43b82a06a8761e8d7be4979ebf2611f7dd79bf91c1c6b566a219ed766",
"2399561127a57125de8cefea610ddf2fa078b5c8067f4e828290bfb860e84b3c",
"69ddd7ea90bb57c93e135dc85ea6fcd5480b603239bdc454fc758b2a26cf7f79",
"6c61dac3a2def031506be036d2a6fe401994fbd13df9c8d466599274c446ec98",
"668c83947da63b724bece1743c31a0e6aed0db8ec5b31be377bb784f91b6716f",
"ecc3e9c3407503bee091aa952f41348ff88baa863b2264befac807901574e939",
"f9e67d336c51002ac054c632022d66dda2e7e3fff10ad061ed31d8bbb410cfb2",
"bf0feefb9e3a581ad5f9e9db7589985743d261085c4d314f6f5d7259aa421612",
"03950fb49a531f3e1991942398dfa9e0ea32d7ba1cdd9bc85db57ed9400b434a",
"3c5f81fea5fab82c64bfa2eaecafcde8e077fc8620a7cae537163df36edbf378",
"cbb522d7b7f127ad6a0113865bdf1cd4102e7d0759af635a7cf4720dc963c53b",
"04048028bf1f2864d48f9ad4d83294366a828856553f3b14303f90147f5d40ef",
"2530cc8e98321502bad96f9b1fba1b099e2d299e0f4548bb914f363bc0d4531f",
"063e4afac491dfd332f3089b8542e94617d893d7fe944e10a7937ee29d9693c0",
"136335439334a7698016a0d324de72284e079d7b5220bb8fbd747816eebebaca",
"45140b3247eb9cc8c5b4f0d7b53091f73292089e6e5a63e2749dd3aca9198eda",
"2ce1cb0bf9d2f9e102993fbe215152c3b2dd0cabde1c68e5319b839154dbb7f5",
"568d6905a2c88708a4b3025190edcfedb1974a606a13c6e5290fcb2ae63edab5",
"0376ab1d54c5f9803ce4b2e201a0ee7eef7b57b636e8a93c9b8d4860c96f5fa7",
"0a81ec5a929777f145904af38d5d509f66b5e2c58fcdb531058b0e17f3f0b41b",
"70a73f7f376b60074248904534b11482d5bf0e698ecc498df52577ebf2e93b9a",
"bd71fdf6da97e4cf62d1647add2581b07d79adf8397eb4ecba9c5e8488821423",
"5c58468d55f58e497e743982d2b50010b6d165374acf83a7d4a32db768c4408e",
"fcbfe2886206f72b27593c8b070297e12d769ed10ed7930705a8098effc14d17",
"8c4edfd04348f322969e7e29a4cd4dca004655061c16e1b076422ef342ad630e",
"bfd88fe1101c41ae3e801bf8be56350ee9bad1a6b9bd515edc5c6d5b8711ac44",
"513b2cecb810d4cde5dd85391adfc6c2dd60d87bb736d2b521484aa47a0ebef6",
"88497f01602f3154246ae28c4d5aef10f1d87ebb76626f4ae0b7f95ba7968799",
"bc104f15a48be709dca542a7e1d4b9df6f054527e802eaa92d595444258afe71",
"55926084ec963a64b96e2abe01ce0ba86a64fbfebcc7aab5afc155b37fd76066",
"c1b48299aba5208fe9630ace55ca68a03eda5a519c8802a0d3a673be8f8e557d",
"e17890ee09a3fbf4f48b9c414a17d637b7a50647e9bc752322727fcc1742a911",
"c7ba6567de93a798ae1faa791e712d378fae1f93c4397fea441bb7cbe6fd5995",
"9a114025197c5bb95d94e63d55cd43790847b646b23cdf11ada4a00eff15fb48",
"edf7ebbca27a2a384d387b7d4010c666e2edb4843e4c29b4ae1d5b9332e6b24d",
"fd73dad31c644ff1b43bef0ccdda96710b9cd9875eca7e31707af3e96d522bbd",
"3e84ba4342908516e77573c0992f0979ca084e4685681ff195ccba8a229b8a76",
"978cd966f2faa07ba7aa9500d9c02e9d77f2cdada6ad6ba74af4b91c66593c50",
"49e7a442acf0ea6287050054b52564b650e4f49e42e348d6aa38e039e957b1c1",
"eec5496b988ce98625b934092eec2908bed0b0f316c2d4730c84eaf1f3d34881",
"3cfc3c14d1f684ff17e38c43ca440c00b967ec933e8bfe064ca1d72c90f2adb0",
"1c01c6f4dbb2fefc22558b2bca32563f49844acfc32b7be4b0ff599f9e8c7af7",
"f09b122c7114f4a09bd4ea4f4a99d558b46e4c25cd81140d29c05613914c3841",
"d95fea3ca4eedce74cd76e75fc6d1ff62c441f0fa8bc77f034b19e5db258015d",
"f96f23f4c3e79c077a46988d5af5900676a0f039cb645dd17549b216c82440ce",
"e23d4a036d7b70e9f595b1422079d2b91edfbb1fb651a0633eaa8a9dc5f80703",
"9a6ec012e1a7da9dbe34194d478ad7c0db1822fb071df12981496ed104384113",
"59769007f7685d0fcd50872f9f95d5755a5b2b457d81f3692b610a98672f0e1b",
"dd6936fe21f8f077c123a1a521c12224f72255b73e03a7260693e8a24b0fa389",
"b0bfd52bb0d7d9bd92bf5d4dc13da255c02c542f378365ea893911f55e55f23c",
"91e2f5788d5810eba7ba58737de1548a8ecacd014598bc0b143e041b17052552",
"f356bea244b7a91eb35d53ca9ad7864ace018e2d35d5f8f96ddf68a6f41aa474",
"8a866fd1b276b57e578e921c65828a2bed58e9f2f288054134b7f1f4bfc9cc74",
"8fe4fb0af93a4d0d67db0bebb23e37c71bf325dcbcdd240ea04daf58b47e1840",
"88ef81de202eb018452e43f864725cea5fbd1fc2d9d205730709c5d8b8690f46",
"7d05ebb682339f8c9451ee094eebfefa7953a114edb2f44949452fab7d2fc185",
"7e37cb8b4c47090cab36551ba6f45db840680fba166a952db100717f43053fc2",
"cb3ccbb76031e5e0138f8dd39a23f9de47ffc35e43c1144cea27d46a5ab1cb5f",
"31ad6648f8104138c738f39ea4320133393e3a18cc02296ef97c2ac9ef6731d0",
"552f7bdcf1a7af9e6ce672017f4f12abf77240c78e761ac203d1d9d20ac89988",
"4b22d5a6aec99f3cdb79aa5ec06838479cd5ecba7164f7f22dc1d65f63d85708",
"d6f034bd94aa233f0297eca4245b283973e447aa590f310c77f48fdf83112254",
"52f0e1c4e58ec629291b60317f074671b85d7ea80d5b07273463534b32b40234",
"e793c9b02fd8aa13e21c31228accb08119643b749c898964b1746d46c3d4cbd2",
"4ff460d54b9c86dabfbcfc5712e0400d2bed3fbc4d4fbdaa86e06adcd2a9ad7a",
"bec94911c2955676db6c0a550986d76e3ba005667c442c9762b4fbb773de228c",
"179fbc148a3dd00fd24ea13458cc43bfa7f59c8182d783a513f6ebec100c8924",
"3c4fb0b95ab8b30032f432b86f535fe172c185d0fd39865837cf36187fa6f428",
"4d2491414cfe956746ec4cefa6cf6f72e28a1329432f9d8a907ac4cb5dadc15a",
"5d56499be4d2e08bcfcad08a3e38723d50503bde706948e42f55603019e528ae",
"30d0895a9a448a262091635522d1f52010b5867acae12c78ef958fd4f4389f2f",
"43df5774b03e7fef5fe40d931a7bedf1bb2e6b42738c4e6d3841103d3aa7f339",
"02ed0eb28c14da45165c566791700d6451d7fb56f0b2ab1d3b8eb070e56edff5",
"5cc3d78e4e1d5e45547a04e6873e64f90cf9536d1ccc2ef800f355c4c5fd70fd",
"49351b903444c185ccdc5c693d24d8555cb208d6a8141307699f4af063199d78",
"8de78655e1be7f7847800b93f694d21d368cc06e033e7fab04bb5eb99da6b700",
"2a99f5bc1174b73cbb1d620884e01c34e51ccb3978da125f0e33268883bf4158",
"6b9c08e86eb0f767cfad65cd98b62149e5494a67f5845e7bd1ed019f27b86bd6",
"d487a56f83b07482e85e963394c1ecc2c9e51d0903ee946b02c301581ed99e16",
"8b45da1c06f791eb0cabf26be588f5fb23165c2e614bf885562d0dce50b29b02",
"a1339d33281a0b56e557d3d32b1ce7f9367eb094bd5fa72a7e5004c8ded7cafe",
"b676f2eddae8775cd36cb0f63cd1d4603961f49e6265ba013a2f0307b6d0b804"
]

View File

@ -1 +0,0 @@
node.bcoin.io,52.39.113.206 02b9f7499c4166e76d3a64326bbbe92dc02f0e07dc184f94995da61683c311cb0f

View File

@ -1,64 +1,110 @@
# Sample bcoin config file (~/.bcoin/bcoin.conf)
#
# Options
network: main
use-workers: true
# max-workers: 4
# worker-timeout: 5000
# sigcache-size: 50000
#
# network: main
#
# Node
#
prefix: ~/.bcoin
db: leveldb
max-files: 64
# fast: false
cache-size: 100
#
# Workers
#
workers: true
# workers-size: 4
# workers-timeout: 5000
#
# Logger
#
log-level: debug
log-console: true
log-file: true
#
# Chain
# witness: true
# prune: false
use-checkpoints: true
coin-cache: true
#
prune: false
checkpoints: true
entry-cache: 5000
index-tx: false
index-address: false
#
# Mempool
# limit-free: true
# limit-free-relay: 15
# reject-absurd-fees: true
# replace-by-fee: false
#
mempool-size: 100
limit-free: true
limit-free-relay: 15
reject-absurd-fees: true
replace-by-fee: false
persistent-mempool: false
#
# Pool
# selfish: false
headers: false
#
selfish: false
compact: true
bip151: true
# proxy-server: localhost
# preferred-seed: seed.bitcoin.sipa.be
# ignore-discovery: false
# port: 8333
bip37: false
listen: true
max-peers: 8
max-leeches: 30
bip150: false
identity-key: 74b4147957813b62cc8987f2b711ddb31f8cb46dcbf71502033da66053c8780a
auth-peers: ./authorized-peers
known-peers: ./known-peers
max-outbound: 8
max-inbound: 30
# Proxy Server (browser=websockets, node=socks)
# proxy: foo:bar@127.0.0.1:9050
# onion: true
# upnp: true
# Custom list of DNS seeds
# seeds: seed.bitcoin.sipa.be
# Local Host & Port (to listen on)
host: ::
# port: 8333
# Public Host & Port (to advertise to peers)
# public-host: 1.2.3.4
# public-port: 8444
# Always try to connect to these nodes.
# nodes: 127.0.0.1,127.0.0.2
# Only try to connect to these nodes.
# only: 127.0.0.1,127.0.0.2
#
# Miner
# payout-address: 1111111111111111111114oLvT2
# coinbase-flags: mined by bcoin
#
coinbase-flags: mined by bcoin
# coinbase-address: 1111111111111111111114oLvT2,1111111111111111111114oLvT2
preverify: false
max-block-weight: 4000000
reserved-block-weight: 4000
reserved-block-sigops: 400
#
# HTTP
#
http-host: ::
# http-port: 8332
# ssl: true
# ssl-cert: @/ssl/cert.crt
# ssl-key: @/ssl/priv.key
# http-port: 8332
# http-host: 0.0.0.0
# service-key: bikeshed
api-key: bikeshed
wallet-auth: false
# no-auth: false
# cors: false

28
etc/sample.wallet.conf Normal file
View File

@ -0,0 +1,28 @@
# Sample bcoin wallet config file (~/.bcoin/wallet.conf)
#
# Options
#
# network: main
#
# HTTP
#
http-host: ::
# http-port: 8334
# ssl: true
# ssl-cert: @/ssl/cert.crt
# ssl-key: @/ssl/priv.key
api-key: bikeshed
# no-auth: false
# cors: false
#
# Wallet
#
witness: false
checkpoints: true
wallet-auth: false

View File

@ -16,7 +16,7 @@
"opts": {
"template": "templates/default",
"encoding": "utf8",
"destination": "./docs/",
"destination": "./docs/reference",
"recurse": true,
"private": true,
"pedantic": true

131
lib/bcoin-browser.js Normal file
View File

@ -0,0 +1,131 @@
/*!
* bcoin.js - a javascript bitcoin library.
* Copyright (c) 2014-2015, Fedor Indutny (MIT License).
* Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
/**
* A bcoin "environment" which exposes all
* constructors for primitives, the blockchain,
* mempool, wallet, etc. It also exposes a
* global worker pool.
*
* @exports bcoin
* @type {Object}
*/
const bcoin = exports;
/**
* Set the default network.
* @param {String} network
*/
bcoin.set = function set(network) {
bcoin.Network.set(network);
return bcoin;
};
/*
* Expose
*/
// Blockchain
bcoin.blockchain = require('./blockchain');
bcoin.Chain = require('./blockchain/chain');
bcoin.ChainEntry = require('./blockchain/chainentry');
// BTC
bcoin.btc = require('./btc');
bcoin.Amount = require('./btc/amount');
bcoin.URI = require('./btc/uri');
// Coins
bcoin.coins = require('./coins');
bcoin.Coins = require('./coins/coins');
bcoin.CoinEntry = require('./coins/coinentry');
bcoin.CoinView = require('./coins/coinview');
// HD
bcoin.hd = require('./hd');
bcoin.HDPrivateKey = require('./hd/private');
bcoin.HDPublicKey = require('./hd/public');
bcoin.Mnemonic = require('./hd/mnemonic');
// Index
bcoin.indexer = require('./indexer');
bcoin.Indexer = require('./indexer/indexer');
bcoin.TXIndexer = require('./indexer/txindexer');
bcoin.AddrIndexer = require('./indexer/addrindexer');
// Mempool
bcoin.mempool = require('./mempool');
bcoin.Fees = require('./mempool/fees');
bcoin.Mempool = require('./mempool/mempool');
bcoin.MempoolEntry = require('./mempool/mempoolentry');
// Miner
bcoin.mining = require('./mining');
bcoin.Miner = require('./mining/miner');
// Net
bcoin.net = require('./net');
bcoin.packets = require('./net/packets');
bcoin.Peer = require('./net/peer');
bcoin.Pool = require('./net/pool');
// Node
bcoin.node = require('./node');
bcoin.Node = require('./node/node');
bcoin.FullNode = require('./node/fullnode');
bcoin.SPVNode = require('./node/spvnode');
// Primitives
bcoin.primitives = require('./primitives');
bcoin.Address = require('./primitives/address');
bcoin.Block = require('./primitives/block');
bcoin.Coin = require('./primitives/coin');
bcoin.Headers = require('./primitives/headers');
bcoin.Input = require('./primitives/input');
bcoin.InvItem = require('./primitives/invitem');
bcoin.KeyRing = require('./primitives/keyring');
bcoin.MerkleBlock = require('./primitives/merkleblock');
bcoin.MTX = require('./primitives/mtx');
bcoin.Outpoint = require('./primitives/outpoint');
bcoin.Output = require('./primitives/output');
bcoin.TX = require('./primitives/tx');
// Protocol
bcoin.protocol = require('./protocol');
bcoin.consensus = require('./protocol/consensus');
bcoin.Network = require('./protocol/network');
bcoin.networks = require('./protocol/networks');
bcoin.policy = require('./protocol/policy');
// Script
bcoin.script = require('./script');
bcoin.Opcode = require('./script/opcode');
bcoin.Program = require('./script/program');
bcoin.Script = require('./script/script');
bcoin.ScriptNum = require('./script/scriptnum');
bcoin.SigCache = require('./script/sigcache');
bcoin.Stack = require('./script/stack');
bcoin.Witness = require('./script/witness');
// Utils
bcoin.utils = require('./utils');
bcoin.util = require('./utils/util');
// Wallet
bcoin.wallet = require('./wallet');
bcoin.WalletDB = require('./wallet/walletdb');
// Workers
bcoin.workers = require('./workers');
bcoin.WorkerPool = require('./workers/workerpool');
// Package Info
bcoin.pkg = require('./pkg');

View File

@ -1,25 +1,154 @@
/**
* Javascript bitcoin library. Exposes the global environment.
* @module bcoin
* @see {Environment}
* @license
/*!
* bcoin.js - a javascript bitcoin library.
* Copyright (c) 2014-2015, Fedor Indutny (MIT License).
* Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
* https://github.com/indutny/bcoin
* Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
/* eslint prefer-arrow-callback: "off" */
'use strict';
var env = require('./env');
var utils = require('./utils/utils');
var global = utils.global;
/*
* Expose bcoin globally in the
* browser. Necessary for workers.
/**
* A bcoin "environment" which exposes all
* constructors for primitives, the blockchain,
* mempool, wallet, etc. It also exposes a
* global worker pool.
*
* @exports bcoin
* @type {Object}
*/
if (utils.isBrowser)
global.bcoin = env;
const bcoin = exports;
module.exports = env;
/**
* Define a module for lazy loading.
* @param {String} name
* @param {String} path
*/
bcoin.define = function define(name, path) {
let cache = null;
Object.defineProperty(bcoin, name, {
enumerable: true,
get() {
if (!cache)
cache = require(path);
return cache;
}
});
};
/**
* Set the default network.
* @param {String} network
*/
bcoin.set = function set(network) {
bcoin.Network.set(network);
return bcoin;
};
/*
* Expose
*/
// Blockchain
bcoin.define('blockchain', './blockchain');
bcoin.define('blockstore', './blockstore');
bcoin.define('Chain', './blockchain/chain');
bcoin.define('ChainEntry', './blockchain/chainentry');
// BTC
bcoin.define('btc', './btc');
bcoin.define('Amount', './btc/amount');
bcoin.define('URI', './btc/uri');
// Coins
bcoin.define('coins', './coins');
bcoin.define('Coins', './coins/coins');
bcoin.define('CoinEntry', './coins/coinentry');
bcoin.define('CoinView', './coins/coinview');
// HD
bcoin.define('hd', './hd');
bcoin.define('HDPrivateKey', './hd/private');
bcoin.define('HDPublicKey', './hd/public');
bcoin.define('Mnemonic', './hd/mnemonic');
// Index
bcoin.define('indexer', './indexer');
bcoin.define('Indexer', './indexer/indexer');
bcoin.define('TXIndexer', './indexer/txindexer');
bcoin.define('AddrIndexer', './indexer/addrindexer');
// Mempool
bcoin.define('mempool', './mempool');
bcoin.define('Fees', './mempool/fees');
bcoin.define('Mempool', './mempool/mempool');
bcoin.define('MempoolEntry', './mempool/mempoolentry');
// Miner
bcoin.define('mining', './mining');
bcoin.define('Miner', './mining/miner');
// Net
bcoin.define('net', './net');
bcoin.define('packets', './net/packets');
bcoin.define('Peer', './net/peer');
bcoin.define('Pool', './net/pool');
// Node
bcoin.define('node', './node');
bcoin.define('Node', './node/node');
bcoin.define('FullNode', './node/fullnode');
bcoin.define('SPVNode', './node/spvnode');
// Primitives
bcoin.define('primitives', './primitives');
bcoin.define('Address', './primitives/address');
bcoin.define('Block', './primitives/block');
bcoin.define('Coin', './primitives/coin');
bcoin.define('Headers', './primitives/headers');
bcoin.define('Input', './primitives/input');
bcoin.define('InvItem', './primitives/invitem');
bcoin.define('KeyRing', './primitives/keyring');
bcoin.define('MerkleBlock', './primitives/merkleblock');
bcoin.define('MTX', './primitives/mtx');
bcoin.define('Outpoint', './primitives/outpoint');
bcoin.define('Output', './primitives/output');
bcoin.define('TX', './primitives/tx');
// Protocol
bcoin.define('protocol', './protocol');
bcoin.define('consensus', './protocol/consensus');
bcoin.define('Network', './protocol/network');
bcoin.define('networks', './protocol/networks');
bcoin.define('policy', './protocol/policy');
// Script
bcoin.define('script', './script');
bcoin.define('Opcode', './script/opcode');
bcoin.define('Program', './script/program');
bcoin.define('Script', './script/script');
bcoin.define('ScriptNum', './script/scriptnum');
bcoin.define('SigCache', './script/sigcache');
bcoin.define('Stack', './script/stack');
bcoin.define('Witness', './script/witness');
// Utils
bcoin.define('utils', './utils');
bcoin.define('util', './utils/util');
// Wallet
bcoin.define('wallet', './wallet');
bcoin.define('Path', './wallet/path');
bcoin.define('WalletKey', './wallet/walletkey');
bcoin.define('WalletDB', './wallet/walletdb');
// Workers
bcoin.define('workers', './workers');
bcoin.define('WorkerPool', './workers/workerpool');
// Package Info
bcoin.define('pkg', './pkg');

View File

@ -1,451 +0,0 @@
/*!
* asn1.js - asn1 parsing for bcoin
* Copyright (c) 2016, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*
* Parts of this software are based on asn1.js.
* https://github.com/indutny/asn1.js
*
* Copyright Fedor Indutny, 2013.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*/
'use strict';
var assert = require('assert');
var BufferReader = require('../utils/reader');
var asn1 = exports;
asn1.parseTag = function parseTag(p) {
var tag = p.readU8();
var primitive = (tag & 0x20) === 0;
var oct;
if ((tag & 0x1f) === 0x1f) {
oct = tag;
tag = 0;
while ((oct & 0x80) === 0x80) {
oct = p.readU8();
tag <<= 7;
tag |= oct & 0x7f;
}
} else {
tag &= 0x1f;
}
return {
primitive: primitive,
tag: tag,
len: asn1.parseLen(p, primitive)
};
};
asn1.parseLen = function parseLen(p, primitive) {
var len = p.readU8();
var num, i, j;
// Indefinite form
if (!primitive && len === 0x80)
return null;
// Definite form
if ((len & 0x80) === 0) {
// Short form
return len;
}
// Long form
num = len & 0x7f;
assert(num < 4, 'length octect is too long');
len = 0;
for (i = 0; i < num; i++) {
len <<= 8;
j = p.readU8();
len |= j;
}
return len;
};
asn1.parseCert = function parseCert(data) {
var d = BufferReader(data);
var p;
d.start();
p = BufferReader(asn1.parseSeq(d));
return {
tbs: asn1.parseTBS(p),
sigAlg: asn1.parseAlgIdent(p),
sig: asn1.parseBitstr(p),
raw: d.endData(true)
};
};
asn1.parseTBS = function parseTBS(data) {
var d = BufferReader(data);
var p;
d.start();
p = BufferReader(asn1.parseSeq(d));
return {
version: asn1.parseExplicitInt(p, 0, true),
serial: asn1.parseInt(p),
sig: asn1.parseAlgIdent(p),
issuer: asn1.parseName(p),
validity: asn1.parseValidity(p),
subject: asn1.parseName(p),
pubkey: asn1.parsePubkey(p),
raw: d.endData(true)
};
};
asn1.parseSeq = function parseSeq(data) {
var p = BufferReader(data);
var tag = asn1.parseTag(p);
assert.equal(tag.tag, 0x10); // seq
return p.readBytes(tag.len, true);
};
asn1.parseInt = function parseInt(data, readNum) {
var p = BufferReader(data);
var tag = asn1.parseTag(p);
var num;
assert.equal(tag.tag, 0x02); // int
num = p.readBytes(tag.len, true);
if (readNum)
return num.readUIntBE(0, num.length);
return num;
};
asn1.parseExplicitInt = function parseExplicitInt(data, i, readNum) {
var p = BufferReader(data);
var off = p.offset;
var tag = asn1.parseTag(p);
if (tag.tag !== i) {
p.seek(-(p.offset - off));
return -1;
}
return asn1.parseInt(p, readNum);
};
asn1.parseBitstr = function parseBitstr(data) {
var p = BufferReader(data);
var tag = asn1.parseTag(p);
assert.equal(tag.tag, 0x03); // bitstr
return asn1.alignBitstr(p.readBytes(tag.len, true));
};
asn1.parseString = function parseString(data) {
var p = BufferReader(data);
var tag = asn1.parseTag(p);
switch (tag.tag) {
case 0x03: // bitstr
return asn1.alignBitstr(p.readBytes(tag.len, true));
case 0x04: // octstr
case 0x12: // numstr
case 0x13: // prinstr
case 0x14: // t61str
case 0x15: // videostr
case 0x16: // ia5str
case 0x19: // graphstr
case 0x0c: // utf8str
case 0x1a: // iso646str
case 0x1b: // genstr
case 0x1c: // unistr
case 0x1d: // charstr
case 0x1e: // bmpstr
return p.readString('utf8', tag.len);
default:
assert(false, 'Bad string.');
}
};
asn1.alignBitstr = function(data) {
var padding = data[0];
var bits = (data.length - 1) * 8 - padding;
var buf = data.slice(1);
var shift = 8 - (bits % 8);
var i, out;
if (shift === 8 || buf.length === 0)
return buf;
out = new Buffer(buf.length);
out[0] = buf[0] >>> shift;
for (i = 1; i < buf.length; i++) {
out[i] = buf[i - 1] << (8 - shift);
out[i] |= buf[i] >>> shift;
}
return out;
};
asn1.parsePubkey = function parsePubkey(data) {
var p = BufferReader(data);
p = BufferReader(asn1.parseSeq(p));
return {
alg: asn1.parseAlgIdent(p),
pubkey: asn1.parseBitstr(p)
};
};
asn1.parseName = function parseName(data) {
var p = BufferReader(data);
var values = [];
var tag;
p = BufferReader(asn1.parseSeq(p));
while (p.left()) {
tag = asn1.parseTag(p);
assert.equal(tag.tag, 0x11); // set
tag = asn1.parseTag(p);
assert.equal(tag.tag, 0x10); // seq
values.push({
type: asn1.parseOID(p),
value: asn1.parseString(p)
});
}
return values;
};
asn1.parseValidity = function parseValidity(data) {
var p = BufferReader(data);
p = BufferReader(asn1.parseSeq(p));
return {
notBefore: asn1.parseTime(p),
notAfter: asn1.parseTime(p)
};
};
asn1.parseTime = function parseTime(data) {
var p = BufferReader(data);
var tag = asn1.parseTag(p);
var str = p.readString('ascii', tag.len);
var year, mon, day, hour, min, sec;
switch (tag.tag) {
case 0x17: // utctime
year = str.slice(0, 2) | 0;
mon = str.slice(2, 4) | 0;
day = str.slice(4, 6) | 0;
hour = str.slice(6, 8) | 0;
min = str.slice(8, 10) | 0;
sec = str.slice(10, 12) | 0;
if (year < 70)
year = 2000 + year;
else
year = 1900 + year;
break;
case 0x18: // gentime
year = str.slice(0, 4) | 0;
mon = str.slice(4, 6) | 0;
day = str.slice(6, 8) | 0;
hour = str.slice(8, 10) | 0;
min = str.slice(10, 12) | 0;
sec = str.slice(12, 14) | 0;
break;
default:
assert(false);
break;
}
return Date.UTC(year, mon - 1, day, hour, min, sec, 0) / 1000;
};
asn1.parseOID = function parseOID(data) {
var p = BufferReader(data);
var tag = asn1.parseTag(p);
var ids = [];
var ident = 0;
var subident = 0;
var objid, result, first, second;
assert.equal(tag.tag, 0x06); // objid
objid = p.readBytes(tag.len, true);
p = BufferReader(objid);
while (p.left()) {
subident = p.readU8();
ident <<= 7;
ident |= subident & 0x7f;
if ((subident & 0x80) === 0) {
ids.push(ident);
ident = 0;
}
}
if (subident & 0x80)
ids.push(ident);
first = (ids[0] / 40) | 0;
second = ids[0] % 40;
result = [first, second].concat(ids.slice(1));
return result.join('.');
};
asn1.parseAlgIdent = function parseAlgIdent(data) {
var p = BufferReader(data);
var params = null;
var alg;
p = BufferReader(asn1.parseSeq(p));
alg = asn1.parseOID(p);
if (p.left() > 0) {
params = p.readBytes(asn1.parseTag(p).len, true);
if (params.length === 0)
params = null;
}
return {
alg: alg,
params: params
};
};
asn1.parseRSAPublic = function parseRSAPublic(data) {
var p = BufferReader(data);
p = BufferReader(asn1.parseSeq(p));
return {
modulus: asn1.parseInt(p),
publicExponent: asn1.parseInt(p)
};
};
asn1.parseRSAPrivate = function parseRSAPrivate(data) {
var p = BufferReader(data);
p = BufferReader(asn1.parseSeq(p));
return {
version: asn1.parseInt(p, true),
modulus: asn1.parseInt(p),
publicExponent: asn1.parseInt(p),
privateExponent: asn1.parseInt(p),
prime1: asn1.parseInt(p),
prime2: asn1.parseInt(p),
exponent1: asn1.parseInt(p),
exponent2: asn1.parseInt(p),
coefficient: asn1.parseInt(p)
};
};
asn1.parsePEM = function parsePEM(pem) {
var buf = '';
var chunks = [];
var s, tag, type;
while (pem.length) {
if (s = /^-----BEGIN ([^\-]+)-----/.exec(pem)) {
pem = pem.substring(s[0].length);
tag = s[1];
continue;
}
if (s = /^-----END ([^\-]+)-----/.exec(pem)) {
pem = pem.substring(s[0].length);
assert(tag === s[1], 'Tag mismatch.');
buf = new Buffer(buf, 'base64');
type = tag.split(' ')[0].toLowerCase();
chunks.push({ tag: tag, type: type, data: buf });
buf = '';
tag = null;
continue;
}
if (s = /^[a-zA-Z0-9\+=\/]+/.exec(pem)) {
pem = pem.substring(s[0].length);
buf += s[0];
continue;
}
if (s = /^\s+/.exec(pem)) {
pem = pem.substring(s[0].length);
continue;
}
throw new Error('PEM parse error.');
}
assert(chunks.length !== 0, 'PEM parse error.');
assert(!tag, 'Un-ended tag.');
assert(buf.length === 0, 'Trailing data.');
return chunks;
};
asn1.fromPEM = function fromPEM(pem) {
var chunks = asn1.parsePEM(pem);
var body = chunks[0];
var extra = chunks[1];
var params, alg;
if (extra) {
if (extra.tag.indexOf('PARAMETERS') !== -1)
params = extra.data;
}
switch (body.type) {
case 'dsa':
alg = 'dsa';
break;
case 'rsa':
alg = 'rsa';
break;
case 'ec':
alg = 'ecdsa';
break;
}
return {
type: body.type,
alg: alg,
data: body.data,
params: params
};
};
asn1.toPEM = function toPEM(der, type, suffix) {
var pem = '';
var i;
if (suffix)
type += ' ' + suffix;
type = type.toUpperCase();
der = der.toString('base64');
for (i = 0; i < der.length; i += 64)
pem += der.slice(i, i + 64) + '\r\n';
return ''
+ '-----BEGIN ' + type + '-----\r\n'
+ pem
+ '-----END ' + type + '-----\r\n';
};

View File

@ -1,15 +0,0 @@
/*!
* bip70.js - bip70 for bcoin
* Copyright (c) 2016, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
exports.PaymentRequest = require('./paymentrequest');
exports.PaymentDetails = require('./paymentdetails');
exports.Payment = require('./payment');
exports.PaymentACK = require('./paymentack');
exports.asn1 = require('./asn1');
exports.x509 = require('./x509');
exports.pk = require('./pk');

View File

@ -1,127 +0,0 @@
/*!
* payment.js - bip70 payment for bcoin
* Copyright (c) 2016, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
var assert = require('assert');
var Output = require('../primitives/output');
var TX = require('../primitives/tx');
var Script = require('../script/script');
var protobuf = require('./protobuf');
var PaymentDetails = require('./paymentdetails');
var ProtoReader = protobuf.ProtoReader;
var ProtoWriter = protobuf.ProtoWriter;
function Payment(options) {
if (!(this instanceof Payment))
return new Payment(options);
this.merchantData = null;
this.transactions = [];
this.refundTo = [];
this.memo = null;
if (options)
this.fromOptions(options);
}
Payment.prototype.fromOptions = function fromOptions(options) {
var i, tx, output;
if (options.merchantData)
this.setData(options.merchantData);
if (options.transactions) {
assert(Array.isArray(options.transactions));
for (i = 0; i < options.transactions.length; i++) {
tx = new TX(options.transactions[i]);
this.transactions.push(tx);
}
}
if (options.refundTo) {
assert(Array.isArray(options.refundTo));
for (i = 0; i < options.refundTo.length; i++) {
output = new Output(options.refundTo[i]);
this.refundTo.push(output);
}
}
if (options.memo != null) {
assert(typeof options.memo === 'string');
this.memo = options.memo;
}
return this;
};
Payment.fromOptions = function fromOptions(options) {
return new Payment().fromOptions(options);
};
Payment.prototype.setData = PaymentDetails.prototype.setData;
Payment.prototype.getData = PaymentDetails.prototype.getData;
Payment.prototype.fromRaw = function fromRaw(data) {
var p = new ProtoReader(data);
var tx, op, output;
this.merchantData = p.readFieldBytes(1, true);
while (p.nextTag() === 2) {
tx = TX.fromRaw(p.readFieldBytes(2));
this.transactions.push(tx);
}
while (p.nextTag() === 3) {
op = new ProtoReader(p.readFieldBytes(3));
output = new Output();
output.value = op.readFieldU64(1, true);
output.script = Script.fromRaw(op.readFieldBytes(2, true));
this.refundTo.push(output);
}
this.memo = p.readFieldString(4, true);
return this;
};
Payment.fromRaw = function fromRaw(data, enc) {
if (typeof data === 'string')
data = new Buffer(data, enc);
return new Payment().fromRaw(data);
};
Payment.prototype.toRaw = function toRaw(writer) {
var p = new ProtoWriter(writer);
var i, tx, op, output;
if (this.merchantData)
p.writeFieldBytes(1, this.merchantData);
for (i = 0; i < this.transactions.length; i++) {
tx = this.transactions[i];
this.writeFieldBytes(2, tx.toRaw());
}
for (i = 0; i < this.refundTo.length; i++) {
op = new ProtoWriter();
output = this.refundTo[i];
op.writeFieldU64(1, output.value);
op.writeFieldBytes(2, output.script.toRaw());
p.writeFieldBytes(3, op.render());
}
if (this.memo != null)
p.writeFieldString(4, this.memo);
if (!writer)
p = p.render();
return p;
};
module.exports = Payment;

View File

@ -1,71 +0,0 @@
/*!
* paymentack.js - bip70 paymentack for bcoin
* Copyright (c) 2016, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
var assert = require('assert');
var protobuf = require('./protobuf');
var Payment = require('./payment');
var ProtoReader = protobuf.ProtoReader;
var ProtoWriter = protobuf.ProtoWriter;
function PaymentACK(options) {
if (!(this instanceof PaymentACK))
return new PaymentACK(options);
this.payment = new Payment();
this.memo = null;
if (options)
this.fromOptions(options);
}
PaymentACK.prototype.fromOptions = function fromOptions(options) {
if (options.payment)
this.payment.fromOptions(options.payment);
if (options.memo != null) {
assert(typeof options.memo === 'string');
this.memo = options.memo;
}
return this;
};
PaymentACK.fromOptions = function fromOptions(options) {
return new PaymentACK().fromOptions(options);
};
PaymentACK.prototype.fromRaw = function fromRaw(data) {
var p = new ProtoReader(data);
this.payment.fromRaw(p.readFieldBytes(1));
this.memo = p.readFieldString(2, true);
return this;
};
PaymentACK.fromRaw = function fromRaw(data, enc) {
if (typeof data === 'string')
data = new Buffer(data, enc);
return new PaymentACK().fromRaw(data);
};
PaymentACK.prototype.toRaw = function toRaw(writer) {
var p = new ProtoWriter(writer);
p.writeFieldBytes(1, this.payment.toRaw());
if (this.memo != null)
p.writeFieldString(2, this.memo);
if (!writer)
p = p.render();
return p;
};
module.exports = PaymentACK;

View File

@ -1,185 +0,0 @@
/*!
* paymentdetails.js - bip70 paymentdetails for bcoin
* Copyright (c) 2016, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
var assert = require('assert');
var utils = require('../utils/utils');
var Output = require('../primitives/output');
var protobuf = require('./protobuf');
var ProtoReader = protobuf.ProtoReader;
var ProtoWriter = protobuf.ProtoWriter;
function PaymentDetails(options) {
if (!(this instanceof PaymentDetails))
return new PaymentDetails(options);
this.network = null;
this.outputs = [];
this.time = utils.now();
this.expires = -1;
this.memo = null;
this.paymentUrl = null;
this.merchantData = null;
if (options)
this.fromOptions(options);
}
PaymentDetails.prototype.fromOptions = function fromOptions(options) {
var i, output;
if (options.network != null) {
assert(typeof options.network === 'string');
this.network = options.network;
}
if (options.outputs) {
assert(Array.isArray(options.outputs));
for (i = 0; i < options.outputs.length; i++) {
output = new Output(options.outputs[i]);
this.outputs.push(output);
}
}
if (options.time != null) {
assert(utils.isNumber(options.time));
this.time = options.time;
}
if (options.expires != null) {
assert(utils.isNumber(options.expires));
this.expires = options.expires;
}
if (options.memo != null) {
assert(typeof options.memo === 'string');
this.memo = options.memo;
}
if (options.paymentUrl != null) {
assert(typeof options.paymentUrl === 'string');
this.paymentUrl = options.paymentUrl;
}
if (options.merchantData)
this.setData(options.merchantData);
return this;
};
PaymentDetails.fromOptions = function fromOptions(options) {
return new PaymentDetails().fromOptions(options);
};
PaymentDetails.prototype.isExpired = function isExpired() {
if (this.expires === -1)
return false;
return utils.now() > this.expires;
};
PaymentDetails.prototype.setData = function setData(data, enc) {
if (data == null || Buffer.isBuffer(data)) {
this.merchantData = data;
return;
}
if (typeof data !== 'string') {
assert(!enc || enc === 'json');
this.merchantData = new Buffer(JSON.stringify(data), 'utf8');
return;
}
this.merchantData = new Buffer(data, enc);
};
PaymentDetails.prototype.getData = function getData(enc) {
var data = this.merchantData;
if (!data)
return;
if (!enc)
return data;
if (enc === 'json') {
data = data.toString('utf8');
try {
data = JSON.parse(data);
} catch (e) {
return;
}
return data;
}
return data.toString(enc);
};
PaymentDetails.prototype.fromRaw = function fromRaw(data) {
var p = new ProtoReader(data);
var op, output;
this.network = p.readFieldString(1, true);
while (p.nextTag() === 2) {
op = new ProtoReader(p.readFieldBytes(2));
output = new Output();
output.value = op.readFieldU64(1, true);
output.script.fromRaw(op.readFieldBytes(2, true));
this.outputs.push(output);
}
this.time = p.readFieldU64(3);
this.expires = p.readFieldU64(4, true);
this.memo = p.readFieldString(5, true);
this.paymentUrl = p.readFieldString(6, true);
this.merchantData = p.readFieldBytes(7, true);
return this;
};
PaymentDetails.fromRaw = function fromRaw(data, enc) {
if (typeof data === 'string')
data = new Buffer(data, enc);
return new PaymentDetails().fromRaw(data);
};
PaymentDetails.prototype.toRaw = function toRaw(writer) {
var p = new ProtoWriter(writer);
var i, op, output;
if (this.network != null)
p.writeFieldString(1, this.network);
for (i = 0; i < this.outputs.length; i++) {
output = this.outputs[i];
op = new ProtoWriter();
op.writeFieldU64(1, output.value);
op.writeFieldBytes(2, output.script.toRaw());
p.writeFieldBytes(2, op.render());
}
p.writeFieldU64(3, this.time);
if (this.expires !== -1)
p.writeFieldU64(4, this.expires);
if (this.memo != null)
p.writeFieldString(5, this.memo);
if (this.paymentUrl != null)
p.writeFieldString(6, this.paymentUrl);
if (this.merchantData)
p.writeFieldString(7, this.merchantData);
if (!writer)
p = p.render();
return p;
};
module.exports = PaymentDetails;

View File

@ -1,252 +0,0 @@
/*!
* paymentrequest.js - bip70 paymentrequest for bcoin
* Copyright (c) 2016, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
var assert = require('assert');
var utils = require('../utils/utils');
var crypto = require('../crypto/crypto');
var x509 = require('./x509');
var asn1 = require('./asn1');
var protobuf = require('./protobuf');
var PaymentDetails = require('./paymentdetails');
var ProtoReader = protobuf.ProtoReader;
var ProtoWriter = protobuf.ProtoWriter;
function PaymentRequest(options) {
if (!(this instanceof PaymentRequest))
return new PaymentRequest(options);
this.version = -1;
this.pkiType = null;
this.pkiData = null;
this.paymentDetails = new PaymentDetails();
this.signature = null;
if (options)
this.fromOptions(options);
}
PaymentRequest.prototype.fromOptions = function fromOptions(options) {
if (options.version != null) {
assert(utils.isNumber(options.version));
this.version = options.version;
}
if (options.pkiType != null) {
assert(typeof options.pkiType === 'string');
this.pkiType = options.pkiType;
}
if (options.pkiData) {
assert(Buffer.isBuffer(options.pkiData));
this.pkiData = options.pkiData;
}
if (options.paymentDetails)
this.paymentDetails.fromOptions(options.paymentDetails);
if (options.signature) {
assert(Buffer.isBuffer(options.signature));
this.signature = options.signature;
}
if (options.chain)
this.setChain(options.chain);
return this;
};
PaymentRequest.fromOptions = function fromOptions(options) {
return new PaymentRequest().fromOptions(options);
};
PaymentRequest.prototype.fromRaw = function fromRaw(data) {
var p = new ProtoReader(data);
this.version = p.readFieldU32(1, true);
this.pkiType = p.readFieldString(2, true);
this.pkiData = p.readFieldBytes(3, true);
this.paymentDetails.fromRaw(p.readFieldBytes(4));
this.signature = p.readFieldBytes(5, true);
return this;
};
PaymentRequest.fromRaw = function fromRaw(data, enc) {
if (typeof data === 'string')
data = new Buffer(data, enc);
return new PaymentRequest().fromRaw(data);
};
PaymentRequest.prototype.toRaw = function toRaw(writer) {
var p = new ProtoWriter(writer);
if (this.version !== -1)
p.writeFieldU32(1, this.version);
if (this.pkiType != null)
p.writeFieldString(2, this.pkiType);
if (this.pkiData)
p.writeFieldBytes(3, this.pkiData);
p.writeFieldBytes(4, this.paymentDetails.toRaw());
if (this.signature)
p.writeFieldBytes(5, this.signature);
if (!writer)
p = p.render();
return p;
};
PaymentRequest.prototype.getAlgorithm = function getAlgorithm() {
var parts;
if (!this.pkiType)
return;
parts = this.pkiType.split('+');
if (parts.length !== 2)
return;
if (parts[0] !== 'x509')
return;
if (parts[1] !== 'sha1' && parts[1] !== 'sha256')
return;
return { key: parts[0], hash: parts[1] };
};
PaymentRequest.prototype.signatureData = function signatureData() {
var signature = this.signature;
var data;
this.signature = new Buffer(0);
data = this.toRaw();
this.signature = signature;
return data;
};
PaymentRequest.prototype.signatureHash = function signatureHash() {
var alg = this.getAlgorithm();
assert(alg, 'No hash algorithm available.');
return crypto.hash(alg.hash, this.signatureData());
};
PaymentRequest.prototype.setChain = function setChain(chain) {
var p = new ProtoWriter();
var i, cert, pem;
if (!Array.isArray(chain))
chain = [chain];
for (i = 0; i < chain.length; i++) {
cert = chain[i];
if (typeof cert === 'string') {
pem = asn1.fromPEM(cert);
assert(pem.type === 'certificate', 'Bad certificate PEM.');
cert = pem.data;
}
assert(Buffer.isBuffer(cert), 'Certificates must be PEM or DER.');
p.writeFieldBytes(1, cert);
}
this.pkiData = p.render();
};
PaymentRequest.prototype.getChain = function getChain() {
var chain = [];
var p;
if (!this.pkiData)
return chain;
p = new ProtoReader(this.pkiData);
while (p.nextTag() === 1)
chain.push(p.readFieldBytes(1));
return chain;
};
PaymentRequest.prototype.sign = function sign(key, chain) {
var alg, msg;
if (chain)
this.setChain(chain);
if (!this.pkiType)
this.pkiType = 'x509+sha256';
alg = this.getAlgorithm();
assert(alg, 'No hash algorithm available.');
msg = this.signatureData();
chain = this.getChain();
this.signature = x509.signSubject(alg.hash, msg, key, chain);
};
PaymentRequest.prototype.verify = function verify() {
var alg, msg, sig, chain;
if (!this.pkiType || this.pkiType === 'none')
return true;
if (!this.signature)
return false;
alg = this.getAlgorithm();
if (!alg)
return false;
msg = this.signatureData();
sig = this.signature;
chain = this.getChain();
return x509.verifySubject(alg.hash, msg, sig, chain);
};
PaymentRequest.prototype.verifyChain = function verifyChain() {
if (!this.pkiType || this.pkiType === 'none')
return true;
return x509.verifyChain(this.getChain());
};
PaymentRequest.prototype.getCA = function getCA() {
var chain, root;
if (!this.pkiType || this.pkiType === 'none')
return;
chain = this.getChain();
if (chain.length === 0)
return;
root = x509.parse(chain[chain.length - 1]);
if (!root)
return;
return {
name: x509.getCAName(root),
trusted: x509.isTrusted(root),
cert: root
};
};
module.exports = PaymentRequest;

View File

@ -1,253 +0,0 @@
/*!
* x509.js - x509 handling for bcoin
* Copyright (c) 2016, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
var BN = require('bn.js');
var asn1 = require('./asn1');
var elliptic = require('elliptic');
var crypto = require('../crypto/crypto');
var nativeCrypto;
try {
nativeCrypto = require('crypto');
} catch (e) {
;
}
var pk = exports;
var rsa = {};
var ecdsa = {};
var native = {};
rsa.prefixes = {
md5: new Buffer('3020300c06082a864886f70d020505000410', 'hex'),
sha1: new Buffer('3021300906052b0e03021a05000414', 'hex'),
sha224: new Buffer('302d300d06096086480165030402040500041c', 'hex'),
sha256: new Buffer('3031300d060960864801650304020105000420', 'hex'),
sha384: new Buffer('3041300d060960864801650304020205000430', 'hex'),
sha512: new Buffer('3051300d060960864801650304020305000440', 'hex'),
md5sha1: new Buffer(0),
ripemd160: new Buffer('30203008060628cf060300310414', 'hex')
};
// Ported from:
// https://github.com/golang/go/blob/master/src/crypto/rsa/pkcs1v15.go
rsa.verify = function verify(hashAlg, msg, sig, key) {
var hash = crypto.hash(hashAlg, msg);
var prefix = rsa.prefixes[hashAlg];
var len = prefix.length + hash.length;
var pub = asn1.parseRSAPublic(key);
var N = new BN(pub.modulus);
var e = new BN(pub.publicExponent);
var k = Math.ceil(N.bitLength() / 8);
var m, em, ok, i;
if (k < len + 11)
throw new Error('Message too long.');
m = rsa.encrypt(N, e, sig);
em = leftpad(m, k);
ok = crypto.ceq(em[0], 0x00);
ok &= crypto.ceq(em[1], 0x01);
ok &= crypto.ccmp(em.slice(k - hash.length, k), hash);
ok &= crypto.ccmp(em.slice(k - len, k - hash.length), prefix);
ok &= crypto.ceq(em[k - len - 1], 0x00);
for (i = 2; i < k - len - 1; i++)
ok &= crypto.ceq(em[i], 0xff);
return ok === 1;
};
rsa.sign = function sign(hashAlg, msg, key) {
var hash = crypto.hash(hashAlg, msg);
var prefix = rsa.prefixes[hashAlg];
var len = prefix.length + hash.length;
var priv = asn1.parseRSAPrivate(key);
var N = new BN(priv.modulus);
var D = new BN(priv.privateExponent);
var k = Math.ceil(N.bitLength() / 8);
var i, em;
if (k < len + 11)
throw new Error('Message too long.');
em = new Buffer(k);
em.fill(0);
em[1] = 0x01;
for (i = 2; i < k - len - 1; i++)
em[i] = 0xff;
prefix.copy(em, k - len);
hash.copy(em, k - hash.length);
return rsa.decrypt(N, D, em);
};
rsa.decrypt = function decrypt(N, D, m) {
var c = new BN(m);
if (c.cmp(N) > 0)
throw new Error('Cannot decrypt.');
return c
.toRed(BN.red(N))
.redPow(D)
.fromRed()
.toArrayLike(Buffer, 'be');
};
rsa.encrypt = function encrypt(N, e, m) {
return new BN(m)
.toRed(BN.red(N))
.redPow(e)
.fromRed()
.toArrayLike(Buffer, 'be');
};
ecdsa.verify = function verify(curve, msg, hashAlg, key, sig) {
var hash = crypto.hash(hashAlg, msg);
var ec = elliptic.ec(curve);
return ec.verify(hash, sig, key);
};
ecdsa.sign = function sign(curve, msg, hashAlg, key) {
var hash = crypto.hash(hashAlg, msg);
var ec = elliptic.ec(curve);
return new Buffer(ec.sign(hash, key));
};
native.verify = function verify(alg, hash, msg, sig, key) {
var algo, verify;
if (!nativeCrypto)
return false;
algo = normalizeAlg(alg, hash);
verify = nativeCrypto.createVerify(algo);
verify.update(msg);
return verify.verify(key, sig);
};
native.sign = function _sign(alg, hash, msg, key) {
var algo, sig;
if (!nativeCrypto)
return false;
algo = normalizeAlg(alg, hash);
sig = nativeCrypto.createSign(algo);
sig.update(msg);
return sig.sign(key);
};
pk.pemTag = {
dsa: 'DSA',
rsa: 'RSA',
ecdsa: 'EC'
};
pk.toPEM = function toPEM(key, type) {
var tag = pk.pemTag[key.alg];
var pem = asn1.toPEM(key.data, tag, type);
// Key parameters, usually present
// if selecting an EC curve.
if (key.params)
pem += asn1.toPEM(key.params, tag, 'parameters');
return pem;
};
pk._verify = function verify(hash, msg, sig, key) {
var pem;
switch (key.alg) {
case 'dsa':
pem = pk.toPEM(key, 'public key');
return native.verify(key.alg, hash, msg, sig, pem);
case 'rsa':
if (nativeCrypto) {
pem = pk.toPEM(key, 'public key');
return native.verify(key.alg, hash, msg, sig, pem);
}
return rsa.verify(hash, msg, sig, key.data);
case 'ecdsa':
if (!key.curve)
throw new Error('No curve present.');
return ecdsa.verify(key.curve, hash, msg, sig, key.data);
default:
throw new Error('Unsupported algorithm.');
}
};
pk.verify = function verify(hash, msg, sig, key) {
try {
return pk._verify(hash, msg, sig, key);
} catch (e) {
return false;
}
};
pk.sign = function sign(hash, msg, key) {
var pem;
switch (key.alg) {
case 'dsa':
pem = pk.toPEM(key, 'private key');
return native.sign(key.alg, hash, msg, pem);
case 'rsa':
if (nativeCrypto) {
pem = pk.toPEM(key, 'private key');
return native.sign(key.alg, hash, msg, pem);
}
return rsa.sign(hash, msg, key.data);
case 'ecdsa':
if (!key.curve)
throw new Error('No curve present.');
return ecdsa.sign(key.curve, hash, msg, key.data);
default:
throw new Error('Unsupported algorithm.');
}
};
function leftpad(input, size) {
var n = input.length;
var out;
if (n > size)
n = size;
out = new Buffer(size);
out.fill(0);
input.copy(out, out.length - n);
return out;
}
function normalizeAlg(alg, hash) {
var name = alg.toUpperCase() + '-' + hash.toUpperCase();
switch (name) {
case 'ECDSA-SHA1':
name = 'ecdsa-with-SHA1';
break;
case 'ECDSA-SHA256':
name = 'ecdsa-with-SHA256';
break;
}
return name;
}
pk.rsa = rsa;
pk.ecdsa = ecdsa;
pk.native = native;

View File

@ -1,260 +0,0 @@
/*!
* protobuf.js - protobufs for bcoin
* Copyright (c) 2016, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
var utils = require('../utils/utils');
var assert = require('assert');
var BufferReader = require('../utils/reader');
var BufferWriter = require('../utils/writer');
var wireType = {
VARINT: 0,
FIXED64: 1,
DELIMITED: 2,
START_GROUP: 3,
END_GROUP: 4,
FIXED32: 5
};
function ProtoReader(data, zeroCopy) {
if (data instanceof ProtoReader)
return data;
if (!(this instanceof ProtoReader))
return new ProtoReader(data, zeroCopy);
BufferReader.call(this, data, zeroCopy);
}
utils.inherits(ProtoReader, BufferReader);
ProtoReader.prototype.readVarint = function readVarint() {
var result = exports.readVarint(this.data, this.offset);
this.offset += result.size;
return result.value;
};
ProtoReader.prototype.readFieldValue = function readFieldValue(tag, opt) {
var field = this.readField(tag, opt);
if (!field)
return -1;
assert(field.value != null);
return field.value;
};
ProtoReader.prototype.readFieldU64 = function readFieldU64(tag, opt) {
var field = this.readField(tag, opt);
if (!field)
return -1;
assert(field.type === wireType.VARINT || field.type === wireType.FIXED64);
return field.value;
};
ProtoReader.prototype.readFieldU32 = function readFieldU32(tag, opt) {
var field = this.readField(tag, opt);
if (!field)
return -1;
assert(field.type === wireType.VARINT || field.type === wireType.FIXED32);
return field.value;
};
ProtoReader.prototype.readFieldBytes = function readFieldBytes(tag, opt) {
var field = this.readField(tag, opt);
if (!field)
return null;
assert(field.data);
return field.data;
};
ProtoReader.prototype.readFieldString = function readFieldString(tag, opt, enc) {
var field = this.readField(tag, opt);
if (!field)
return null;
assert(field.data);
return field.data.toString(enc || 'utf8');
};
ProtoReader.prototype.nextTag = function nextTag() {
var field;
if (this.left() === 0)
return -1;
field = this.readField();
this.seek(-field.size);
return field.tag;
};
ProtoReader.prototype.readField = function readField(tag, opt) {
var offset = this.offset;
var header = this.readVarint();
var value, data, group, field;
if (tag != null && (header >>> 3) !== tag) {
assert(opt, 'Non-optional field not present.');
this.offset = offset;
return;
}
switch (header & 7) {
case wireType.VARINT:
value = this.readVarint();
break;
case wireType.FIXED64:
value = this.readU64N();
break;
case wireType.DELIMITED:
data = this.readVarBytes();
break;
case wireType.START_GROUP:
group = [];
for (;;) {
field = this.readField();
if (field.type === wireType.END_GROUP)
break;
group.push(field);
}
break;
case wireType.END_GROUP:
assert(false, 'Unexpected end group.');
break;
case wireType.FIXED32:
value = this.readU32();
break;
default:
assert(false, 'Bad wire type.');
break;
}
return {
size: this.offset - offset,
header: header,
tag: header >>> 3,
type: header & 7,
value: value,
data: data,
group: group
};
};
function ProtoWriter(options) {
if (options instanceof ProtoWriter)
return options;
if (!(this instanceof ProtoWriter))
return new ProtoWriter(options);
BufferWriter.call(this, options);
}
utils.inherits(ProtoWriter, BufferWriter);
ProtoWriter.prototype.writeVarint = function writeVarint(num) {
var size = exports.sizeVarint(num);
var buf = new Buffer(size);
exports.writeVarint(buf, num, 0);
this.writeBytes(buf);
};
ProtoWriter.prototype.writeFieldVarint = function writeFieldVarint(tag, value) {
var header = (tag << 3) | wireType.VARINT;
this.writeVarint(header);
this.writeVarint(value);
};
ProtoWriter.prototype.writeFieldU64 = function writeFieldU64(tag, value) {
assert(utils.isSafeInteger(value));
this.writeFieldVarint(tag, value);
};
ProtoWriter.prototype.writeFieldU32 = function writeFieldU32(tag, value) {
assert(value <= 0xffffffff);
this.writeFieldVarint(tag, value);
};
ProtoWriter.prototype.writeFieldBytes = function writeFieldBytes(tag, data) {
var header = (tag << 3) | wireType.DELIMITED;
this.writeVarint(header);
this.writeVarint(data.length);
this.writeBytes(data);
};
ProtoWriter.prototype.writeFieldString = function writeFieldString(tag, data, enc) {
if (typeof data === 'string')
data = new Buffer(data, enc || 'utf8');
this.writeFieldBytes(tag, data);
};
exports.readVarint = function readVarint(data, off) {
var num = 0;
var ch = 0x80;
var size = 0;
while (ch & 0x80) {
if (off >= data.length) {
num = 0;
break;
}
ch = data[off++];
// Optimization for javascript insanity.
switch (size) {
case 0:
case 1:
case 2:
case 3:
num += (ch & 0x7f) << (7 * size);
break;
case 4:
num += (ch & 0x7f) * (1 << (7 * size));
break;
default:
num += (ch & 0x7f) * Math.pow(2, 7 * size);
break;
}
size++;
}
assert(utils.isSafeInteger(num), 'Number exceeds 2^53-1.');
return { size: size, value: num };
};
exports.writeVarint = function writeVarint(data, num, off) {
var ch;
assert(utils.isSafeInteger(num), 'Number exceeds 2^53-1.');
do {
assert(off < data.length);
ch = num & 0x7f;
num -= num % 0x80;
num /= 0x80;
if (num !== 0)
ch |= 0x80;
data[off] = ch;
off++;
} while (num > 0);
return off;
};
exports.sizeVarint = function sizeVarint(num) {
var size = 0;
assert(utils.isSafeInteger(num), 'Number exceeds 2^53-1.');
do {
num -= num % 0x80;
num /= 0x80;
size++;
} while (num > 0);
return size;
};
exports.ProtoReader = ProtoReader;
exports.ProtoWriter = ProtoWriter;

View File

@ -1,306 +0,0 @@
/*!
* x509.js - x509 handling for bcoin
* Copyright (c) 2016, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
var assert = require('assert');
var asn1 = require('./asn1');
var utils = require('../utils/utils');
var crypto = require('../crypto/crypto');
var pk = require('./pk');
var x509 = exports;
x509.getSubjectOID = function getSubjectOID(cert, oid) {
var subject = cert.tbs.subject;
var i, entry;
for (i = 0; i < subject.length; i++) {
entry = subject[i];
if (entry.type === oid)
return entry.value;
}
};
x509.getCAName = function getCAName(cert) {
// This seems to work the best in practice
// for getting a human-readable and
// descriptive name for the CA.
// See:
// http://oid-info.com/get/2.5.4
// Precedence:
// (3) commonName
// (11) organizationUnitName
// (10) organizationName
return x509.getSubjectOID(cert, '2.5.4.3')
|| x509.getSubjectOID(cert, '2.5.4.11')
|| x509.getSubjectOID(cert, '2.5.4.10')
|| 'Unknown';
};
x509.trusted = {};
x509.allowUntrusted = false;
x509.isTrusted = function isTrusted(cert) {
var fingerprint = crypto.sha256(cert.raw);
var hash = fingerprint.toString('hex');
return x509.trusted[hash] === true;
};
x509.setTrust = function setTrust(certs) {
var i, cert, pem, hash;
if (!Array.isArray(certs))
certs = [certs];
for (i = 0; i < certs.length; i++) {
cert = certs[i];
if (isHash(cert)) {
if (!Buffer.isBuffer(cert))
cert = new Buffer(cert, 'hex');
hash = cert.toString('hex');
x509.trusted[hash] = true;
continue;
}
if (typeof cert === 'string') {
pem = asn1.fromPEM(cert);
assert(pem.type === 'certificate', 'Must add certificates to trust.');
cert = pem.data;
}
assert(Buffer.isBuffer(cert), 'Certificates must be PEM or DER.');
cert = x509.parse(cert);
assert(cert, 'Could not parse certificate.');
hash = crypto.sha256(cert.raw).toString('hex');
x509.trusted[hash] = true;
}
};
/*
* https://www.ietf.org/rfc/rfc2459.txt
* https://tools.ietf.org/html/rfc3279
* http://oid-info.com/get/1.2.840.10040.4
* http://oid-info.com/get/1.2.840.113549.1.1
* http://oid-info.com/get/1.2.840.10045.4.3
*/
x509.oid = {
'1.2.840.10040.4.1' : { key: 'dsa', hash: null },
'1.2.840.10040.4.2' : { key: 'dsa', hash: null },
'1.2.840.10040.4.3' : { key: 'dsa', hash: 'sha1' },
'1.2.840.113549.1.1.1' : { key: 'rsa', hash: null },
'1.2.840.113549.1.1.2' : { key: 'rsa', hash: 'md2' },
'1.2.840.113549.1.1.3' : { key: 'rsa', hash: 'md4' },
'1.2.840.113549.1.1.4' : { key: 'rsa', hash: 'md5' },
'1.2.840.113549.1.1.5' : { key: 'rsa', hash: 'sha1' },
'1.2.840.113549.1.1.11': { key: 'rsa', hash: 'sha256' },
'1.2.840.113549.1.1.12': { key: 'rsa', hash: 'sha384' },
'1.2.840.113549.1.1.13': { key: 'rsa', hash: 'sha512' },
'1.2.840.113549.1.1.14': { key: 'rsa', hash: 'sha224' },
'1.2.840.10045.2.1' : { key: 'ecdsa', hash: null },
'1.2.840.10045.4.1' : { key: 'ecdsa', hash: 'sha1' },
'1.2.840.10045.4.3.1' : { key: 'ecdsa', hash: 'sha224' },
'1.2.840.10045.4.3.2' : { key: 'ecdsa', hash: 'sha256' },
'1.2.840.10045.4.3.3' : { key: 'ecdsa', hash: 'sha384' },
'1.2.840.10045.4.3.4' : { key: 'ecdsa', hash: 'sha512' }
};
x509.curves = {
'1.3.132.0.33': 'p224',
'1.2.840.10045.3.1.7': 'p256',
'1.3.132.0.34': 'p384',
'1.3.132.0.35': 'p521'
};
x509.getKeyAlgorithm = function getKeyAlgorithm(cert) {
var alg = cert.tbs.pubkey.alg.alg;
return x509.oid[alg];
};
x509.getSigAlgorithm = function getSigAlgorithm(cert) {
var alg = cert.sigAlg.alg;
return x509.oid[alg];
};
x509.getCurve = function getCurve(params) {
var oid;
if (!params)
return;
try {
oid = asn1.parseOID(params);
} catch (e) {
return;
}
return x509.curves[oid];
};
x509.parse = function parse(der) {
try {
return asn1.parseCert(der);
} catch (e) {
;
}
};
x509.getPublicKey = function getPublicKey(cert) {
var alg = x509.getKeyAlgorithm(cert);
var key, params, curve;
if (!alg)
return;
key = cert.tbs.pubkey.pubkey;
params = cert.tbs.pubkey.alg.params;
if (alg.key === 'ecdsa')
curve = x509.getCurve(params);
return {
alg: alg.key,
data: key,
params: params,
curve: curve
};
};
x509.verifyTime = function verifyTime(cert) {
var time = cert.tbs.validity;
var now = Math.floor(Date.now() / 1000);
return now > time.notBefore && now < time.notAfter;
};
x509.signSubject = function signSubject(hash, msg, key, chain) {
var cert, pub, curve;
assert(chain.length !== 0, 'No chain available.');
cert = x509.parse(chain[0]);
assert(cert, 'Could not parse certificate.');
if (typeof key === 'string') {
key = asn1.fromPEM(key);
if (key.alg === 'ecdsa')
curve = x509.getCurve(key.params);
key = {
alg: key.alg,
data: key.data,
params: key.params,
curve: curve
};
} else {
pub = x509.getPublicKey(cert);
assert(pub, 'Certificate uses an unknown algorithm.');
key = {
alg: pub.alg,
data: key,
params: pub.params,
curve: pub.curve
};
}
return pk.sign(hash, msg, key);
};
x509.verifySubject = function verifySubject(hash, msg, sig, chain) {
var cert, key;
if (chain.length === 0)
return false;
cert = x509.parse(chain[0]);
if (!cert)
return false;
key = x509.getPublicKey(cert);
if (!key)
return false;
return pk.verify(hash, msg, sig, key);
};
x509.verifyChain = function verifyChain(chain) {
var i, child, parent, alg, key, sig, msg;
chain = chain.slice();
// Parse certificates and
// check validity time.
for (i = 0; i < chain.length; i++) {
child = x509.parse(chain[i]);
if (!child)
return false;
chain[i] = child;
if (!x509.verifyTime(child))
return false;
}
// Verify signatures.
for (i = 1; i < chain.length; i++) {
child = chain[i - 1];
parent = chain[i];
alg = x509.getSigAlgorithm(child);
msg = child.tbs.raw;
sig = child.sig;
key = x509.getPublicKey(parent);
if (!alg || !alg.hash)
return false;
if (!key)
return false;
if (!pk.verify(alg.hash, msg, sig, key))
return false;
}
// If trust hasn't been
// setup, just return.
if (x509.allowUntrusted)
return true;
// Make sure we trust one
// of the certs in the chain.
for (i = 0; i < chain.length; i++) {
child = chain[i];
// If any certificate in the chain
// is trusted, assume we also trust
// the parent.
if (x509.isTrusted(child))
return true;
}
// No trusted certs present.
return false;
};
x509.asn1 = asn1;
function isHash(data) {
if (typeof data === 'string')
return utils.isHex(data) && data.length === 64;
if (Buffer.isBuffer(data))
return data.length === 32;
return false;
}
x509.setTrust(require('../../etc/certs.json'));

2992
lib/blockchain/chain.js Normal file

File diff suppressed because it is too large Load Diff

1956
lib/blockchain/chaindb.js Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,381 @@
/*!
* chainentry.js - chainentry object for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
* Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
const assert = require('bsert');
const bio = require('bufio');
const BN = require('bcrypto/lib/bn.js');
const consensus = require('../protocol/consensus');
const hash256 = require('bcrypto/lib/hash256');
const util = require('../utils/util');
const Headers = require('../primitives/headers');
const InvItem = require('../primitives/invitem');
const {inspectSymbol} = require('../utils');
/*
* Constants
*/
const ZERO = new BN(0);
/**
* Chain Entry
* Represents an entry in the chain. Unlike
* other bitcoin fullnodes, we store the
* chainwork _with_ the entry in order to
* avoid reading the entire chain index on
* boot and recalculating the chainworks.
* @alias module:blockchain.ChainEntry
* @property {Hash} hash
* @property {Number} version
* @property {Hash} prevBlock
* @property {Hash} merkleRoot
* @property {Number} time
* @property {Number} bits
* @property {Number} nonce
* @property {Number} height
* @property {BN} chainwork
* @property {Hash} rhash
*/
class ChainEntry {
/**
* Create a chain entry.
* @constructor
* @param {Object?} options
*/
constructor(options) {
this.hash = consensus.ZERO_HASH;
this.version = 1;
this.prevBlock = consensus.ZERO_HASH;
this.merkleRoot = consensus.ZERO_HASH;
this.time = 0;
this.bits = 0;
this.nonce = 0;
this.height = 0;
this.chainwork = ZERO;
if (options)
this.fromOptions(options);
}
/**
* Inject properties from options.
* @private
* @param {Object} options
*/
fromOptions(options) {
assert(options, 'Block data is required.');
assert(Buffer.isBuffer(options.hash));
assert((options.version >>> 0) === options.version);
assert(Buffer.isBuffer(options.prevBlock));
assert(Buffer.isBuffer(options.merkleRoot));
assert((options.time >>> 0) === options.time);
assert((options.bits >>> 0) === options.bits);
assert((options.nonce >>> 0) === options.nonce);
assert((options.height >>> 0) === options.height);
assert(!options.chainwork || BN.isBN(options.chainwork));
this.hash = options.hash;
this.version = options.version;
this.prevBlock = options.prevBlock;
this.merkleRoot = options.merkleRoot;
this.time = options.time;
this.bits = options.bits;
this.nonce = options.nonce;
this.height = options.height;
this.chainwork = options.chainwork || ZERO;
return this;
}
/**
* Instantiate chainentry from options.
* @param {Object} options
* @param {ChainEntry} prev - Previous entry.
* @returns {ChainEntry}
*/
static fromOptions(options, prev) {
return new this().fromOptions(options, prev);
}
/**
* Calculate the proof: (1 << 256) / (target + 1)
* @returns {BN} proof
*/
getProof() {
const target = consensus.fromCompact(this.bits);
if (target.isNeg() || target.isZero())
return new BN(0);
return ChainEntry.MAX_CHAINWORK.div(target.iaddn(1));
}
/**
* Calculate the chainwork by
* adding proof to previous chainwork.
* @returns {BN} chainwork
*/
getChainwork(prev) {
const proof = this.getProof();
if (!prev)
return proof;
return proof.iadd(prev.chainwork);
}
/**
* Test against the genesis block.
* @returns {Boolean}
*/
isGenesis() {
return this.height === 0;
}
/**
* Test whether the entry contains an unknown version bit.
* @param {Network} network
* @returns {Boolean}
*/
hasUnknown(network) {
const TOP_MASK = consensus.VERSION_TOP_MASK;
const TOP_BITS = consensus.VERSION_TOP_BITS;
const bits = (this.version & TOP_MASK) >>> 0;
if (bits !== TOP_BITS)
return false;
return (this.version & network.unknownBits) !== 0;
}
/**
* Test whether the entry contains a version bit.
* @param {Number} bit
* @returns {Boolean}
*/
hasBit(bit) {
return consensus.hasBit(this.version, bit);
}
/**
* Get little-endian block hash.
* @returns {Hash}
*/
rhash() {
return util.revHex(this.hash);
}
/**
* Inject properties from block.
* @private
* @param {Block|MerkleBlock} block
* @param {ChainEntry} prev - Previous entry.
*/
fromBlock(block, prev) {
this.hash = block.hash();
this.version = block.version;
this.prevBlock = block.prevBlock;
this.merkleRoot = block.merkleRoot;
this.time = block.time;
this.bits = block.bits;
this.nonce = block.nonce;
this.height = prev ? prev.height + 1: 0;
this.chainwork = this.getChainwork(prev);
return this;
}
/**
* Instantiate chainentry from block.
* @param {Block|MerkleBlock} block
* @param {ChainEntry} prev - Previous entry.
* @returns {ChainEntry}
*/
static fromBlock(block, prev) {
return new this().fromBlock(block, prev);
}
/**
* Serialize the entry to internal database format.
* @returns {Buffer}
*/
toRaw() {
const bw = bio.write(116);
bw.writeU32(this.version);
bw.writeHash(this.prevBlock);
bw.writeHash(this.merkleRoot);
bw.writeU32(this.time);
bw.writeU32(this.bits);
bw.writeU32(this.nonce);
bw.writeU32(this.height);
bw.writeBytes(this.chainwork.toArrayLike(Buffer, 'le', 32));
return bw.render();
}
/**
* Inject properties from serialized data.
* @private
* @param {Buffer} data
*/
fromRaw(data) {
const br = bio.read(data, true);
const hash = hash256.digest(br.readBytes(80));
br.seek(-80);
this.hash = hash;
this.version = br.readU32();
this.prevBlock = br.readHash();
this.merkleRoot = br.readHash();
this.time = br.readU32();
this.bits = br.readU32();
this.nonce = br.readU32();
this.height = br.readU32();
this.chainwork = new BN(br.readBytes(32), 'le');
return this;
}
/**
* Deserialize the entry.
* @param {Buffer} data
* @returns {ChainEntry}
*/
static fromRaw(data) {
return new this().fromRaw(data);
}
/**
* Serialize the entry to an object more
* suitable for JSON serialization.
* @returns {Object}
*/
toJSON() {
return {
hash: util.revHex(this.hash),
version: this.version,
prevBlock: util.revHex(this.prevBlock),
merkleRoot: util.revHex(this.merkleRoot),
time: this.time,
bits: this.bits,
nonce: this.nonce,
height: this.height,
chainwork: this.chainwork.toString('hex', 64)
};
}
/**
* Inject properties from json object.
* @private
* @param {Object} json
*/
fromJSON(json) {
assert(json, 'Block data is required.');
assert(typeof json.hash === 'string');
assert((json.version >>> 0) === json.version);
assert(typeof json.prevBlock === 'string');
assert(typeof json.merkleRoot === 'string');
assert((json.time >>> 0) === json.time);
assert((json.bits >>> 0) === json.bits);
assert((json.nonce >>> 0) === json.nonce);
assert(typeof json.chainwork === 'string');
this.hash = util.fromRev(json.hash);
this.version = json.version;
this.prevBlock = util.fromRev(json.prevBlock);
this.merkleRoot = util.fromRev(json.merkleRoot);
this.time = json.time;
this.bits = json.bits;
this.nonce = json.nonce;
this.height = json.height;
this.chainwork = new BN(json.chainwork, 'hex');
return this;
}
/**
* Instantiate block from jsonified object.
* @param {Object} json
* @returns {ChainEntry}
*/
static fromJSON(json) {
return new this().fromJSON(json);
}
/**
* Convert the entry to a headers object.
* @returns {Headers}
*/
toHeaders() {
return Headers.fromEntry(this);
}
/**
* Convert the entry to an inv item.
* @returns {InvItem}
*/
toInv() {
return new InvItem(InvItem.types.BLOCK, this.hash);
}
/**
* Return a more user-friendly object.
* @returns {Object}
*/
[inspectSymbol]() {
const json = this.toJSON();
json.version = json.version.toString(16);
return json;
}
/**
* Test whether an object is a {@link ChainEntry}.
* @param {Object} obj
* @returns {Boolean}
*/
static isChainEntry(obj) {
return obj instanceof ChainEntry;
}
}
/**
* The max chainwork (1 << 256).
* @const {BN}
*/
ChainEntry.MAX_CHAINWORK = new BN(1).ushln(256);
/*
* Expose
*/
module.exports = ChainEntry;

76
lib/blockchain/common.js Normal file
View File

@ -0,0 +1,76 @@
/*!
* common.js - bitcoin constants for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
* Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
/**
* @module blockchain/common
*/
/**
* Locktime flags.
* @enum {Number}
*/
exports.lockFlags = {
VERIFY_SEQUENCE: 1 << 0,
MEDIAN_TIME_PAST: 1 << 1
};
/**
* Consensus locktime flags (used for block validation).
* @const {LockFlags}
* @default
*/
exports.lockFlags.MANDATORY_LOCKTIME_FLAGS = 0;
/**
* Standard locktime flags (used for mempool validation).
* @const {LockFlags}
* @default
*/
exports.lockFlags.STANDARD_LOCKTIME_FLAGS = 0
| exports.lockFlags.VERIFY_SEQUENCE
| exports.lockFlags.MEDIAN_TIME_PAST;
/**
* Threshold states for versionbits
* @enum {Number}
* @default
*/
exports.thresholdStates = {
DEFINED: 0,
STARTED: 1,
LOCKED_IN: 2,
ACTIVE: 3,
FAILED: 4
};
/**
* Verify flags for blocks.
* @enum {Number}
* @default
*/
exports.flags = {
VERIFY_NONE: 0,
VERIFY_POW: 1 << 0,
VERIFY_BODY: 1 << 1
};
/**
* Default block verify flags.
* @const {Number}
* @default
*/
exports.flags.DEFAULT_FLAGS = 0
| exports.flags.VERIFY_POW
| exports.flags.VERIFY_BODY;

17
lib/blockchain/index.js Normal file
View File

@ -0,0 +1,17 @@
/*!
* blockchain/index.js - blockchain for bcoin
* Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
/**
* @module blockchain
*/
exports.ChainDB = require('./chaindb');
exports.ChainEntry = require('./chainentry');
exports.Chain = require('./chain');
exports.common = require('./common');
exports.layout = require('./layout');

54
lib/blockchain/layout.js Normal file
View File

@ -0,0 +1,54 @@
/*!
* layout.js - blockchain data layout for bcoin
* Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
const bdb = require('bdb');
/*
* Database Layout:
* V -> db version
* O -> chain options
* R -> tip hash
* D -> versionbits deployments
* e[hash] -> entry
* h[hash] -> height
* H[height] -> hash
* n[hash] -> next hash
* p[hash] -> tip index
* b[hash] -> block (deprecated)
* t[hash] -> extended tx (deprecated)
* c[hash] -> coins
* u[hash] -> undo coins (deprecated)
* v[bit][hash] -> versionbits state
* T[addr-hash][hash] -> dummy (tx by address) (deprecated)
* C[addr-hash][hash][index] -> dummy (coin by address) (deprecated)
*/
const layout = {
V: bdb.key('V'),
O: bdb.key('O'),
R: bdb.key('R'),
D: bdb.key('D'),
e: bdb.key('e', ['hash256']),
h: bdb.key('h', ['hash256']),
H: bdb.key('H', ['uint32']),
n: bdb.key('n', ['hash256']),
p: bdb.key('p', ['hash256']),
b: bdb.key('b', ['hash256']),
t: bdb.key('t', ['hash256']),
c: bdb.key('c', ['hash256', 'uint32']),
u: bdb.key('u', ['hash256']),
v: bdb.key('v', ['uint8', 'hash256']),
T: bdb.key('T', ['hash', 'hash256']),
C: bdb.key('C', ['hash', 'hash256', 'uint32'])
};
/*
* Expose
*/
module.exports = layout;

148
lib/blockstore/README.md Normal file
View File

@ -0,0 +1,148 @@
# BlockStore
BlockStore `lib/blockstore` is a bcoin module intended to be used as a backend
for storing block and undo coin data. It includes a backend that uses flat
files for storage. Its key benefit is performance improvements across the
board in disk I/O, which is the major bottleneck for the initial block sync.
Blocks are stored in wire format directly to the disk, while some additional
metadata is stored in a key-value store, i.e. LevelDB, to help with the data
management. Both the flat files and the metadata db, are exposed through a
unified interace so that the users can simply read and write blocks without
having to worry about managing data layout on the disk.
In addition to blocks, undo coin data, which is used to revert the changes
applied by a block (in case of a re-org), is also stored on disk, in a similar
fashion.
## Interface
The `AbstractBlockStore` interface defines the following abstract methods to be
defined by concrete implementations:
### Basic housekeeping
* `ensure()`
* `open()`
* `close()`
### Block I/O
* `read(hash, offset, size)`
* `write(hash, data)`
* `prune(hash)`
* `has(hash)`
### Undo Coins I/O
* `readUndo(hash)`
* `writeUndo(hash, data)`
* `pruneUndo(hash)`
* `hasUndo(hash)`
The interface is implemented by `FileBlockStore` and `LevelBlockStore`, backed
by flat files and LevelDB respectively. We will focus here on the
`FileBlockStore`, which is the backend that implements a flat file based
storage.
## FileBlockStore
`FileBlockStore` implements the flat file backend for `AbstractBlockStore`. As
the name suggests, it uses flat files for block/undo data and LevelDB for
metadata.
Let's create a file blockstore, write a block and walk-through the disk storage:
```js
// nodejs
const store = blockstore.create({
network: 'regtest',
prefix: '/tmp/blockstore'
});
await store.ensure();
await store.open();
await store.write(hash, block);
```
```sh
// shell
tree /tmp/blockstore/
/tmp/blockstore/
└── blocks
├── blk00000.dat
└── index
├── LOG
...
```
As we can see, the store writes to the file `blk00000.dat` in
`/tmp/blockstore/blocks/`, and the metadata is written to
`/tmp/blockstore/index`.
Raw blocks are written to the disk in flat files named `blkXXXXX.dat`, where
`XXXXX` is the number of file being currently written, starting at
`blk00000.dat`. We store the file number as an integer in the metadata db,
expanding the digits to five places.
The metadata db key `layout.F` tracks the last file used for writing. Each
file in turn tracks the number of blocks in it, the number of bytes used and
its max length. This data is stored in the db key `layout.f`.
f['block'][0] => [1, 5, 128] // blk00000.dat: 1 block written, 5 bytes used, 128 bytes length
F['block'] => 0 // writing to file blk00000.dat
Each raw block data is preceded by a magic marker defined as follows, to help
identify data written by us:
magic (8 bytes) = network.magic (4 bytes) + block data length (4 bytes)
For raw undo block data, the hash of the block is also included:
magic (40 bytes) = network.magic (4 bytes) + length (4 bytes) + hash (32 bytes)
But a marker alone is not sufficient to track the data we write to the files.
For each block we write, we need to store a pointer to the position in the file
where to start reading, and the size of the data we need to seek. This data is
stored in the metadata db using the key `layout.b`:
b['block']['hash'] => [0, 8, 285] // 'hash' points to file blk00000.dat, position 8, size 285
Using this we know that our block is in `blk00000.dat`, bytes 8 through 293 and its size
is 285 bytes.
Note that the position indicates that the block data is preceded by 8 bytes of
the magic marker.
Examples:
> `store.write('hash', 'block')`
blk00000:
0xfabfb5da05000000 block
index:
b['block']['hash'] => [0, 8, 5]
f['block'][0] => [1, 13, 128]
F['block'] => 0
> `store.write('hash1', 'block1')`
blk00000:
0xfabfb5da05000000 block 0xfabfb5da06000000 block1
index:
b['block']['hash'] => [0, 8, 5]
b['block']['hash1'] => [0, 13, 6]
f['block'][0] => [2, 19, 128]
F['block'] => 0
> `store.prune('hash1', 'block1')`
blk00000:
0xfabfb5da05000000 block 0xfabfb5da06000000 block1
index:
b['block']['hash'] => [0, 8, 5]
f['block'][0] => [1, 19, 128]
F['block'] => 0

142
lib/blockstore/abstract.js Normal file
View File

@ -0,0 +1,142 @@
/*!
* blockstore/abstract.js - abstract blockstore for bcoin
* Copyright (c) 2019, Braydon Fuller (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
const Logger = require('blgr');
/**
* Abstract Block Store
*
* @alias module:blockstore.AbstractBlockStore
* @abstract
*/
class AbstractBlockStore {
/**
* Create an abstract blockstore.
* @constructor
*/
constructor(options) {
this.options = options || {};
if (this.options.logger != null)
this.logger = this.options.logger.context('blockstore');
else
this.logger = Logger.global.context('blockstore');
}
/**
* This method ensures that resources are available
* before opening.
* @returns {Promise}
*/
async ensure() {
throw new Error('Abstract method.');
}
/**
* This method opens any necessary resources and
* initializes the store to be ready to be queried.
* @returns {Promise}
*/
async open() {
throw new Error('Abstract method.');
}
/**
* This method closes resources and prepares
* the store to be closed.
* @returns {Promise}
*/
async close() {
throw new Error('Abstract method.');
}
/**
* This method stores block undo coin data.
* @returns {Promise}
*/
async writeUndo(hash, data) {
throw new Error('Abstract method.');
}
/**
* This method stores block data.
* @returns {Promise}
*/
async write(hash, data) {
throw new Error('Abstract method.');
}
/**
* This method will retrieve block undo coin data.
* @returns {Promise}
*/
async readUndo(hash) {
throw new Error('Abstract method.');
}
/**
* This method will retrieve block data. Smaller portions of
* the block can be read by using the offset and size arguments.
* @returns {Promise}
*/
async read(hash, offset, size) {
throw new Error('Abstract method.');
}
/**
* This will free resources for storing the block undo coin data.
* @returns {Promise}
*/
async pruneUndo(hash) {
throw new Error('Abstract method.');
}
/**
* This will free resources for storing the block data.
* @returns {Promise}
*/
async prune(hash) {
throw new Error('Abstract method.');
}
/**
* This will check if a block undo coin data has been stored
* and is available.
* @returns {Promise}
*/
async hasUndo(hash) {
throw new Error('Abstract method.');
}
/**
* This will check if a block has been stored and is available.
* @returns {Promise}
*/
async has(hash) {
throw new Error('Abstract method.');
}
}
/*
* Expose
*/
module.exports = AbstractBlockStore;

31
lib/blockstore/common.js Normal file
View File

@ -0,0 +1,31 @@
/*!
* common.js - blockstore constants for bcoin
* Copyright (c) 2019, Braydon Fuller (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
/**
* @module blockstore/common
*/
/**
* Block data types.
* @enum {Number}
*/
exports.types = {
BLOCK: 1,
UNDO: 2
};
/**
* File prefixes for block data types.
* @enum {String}
*/
exports.prefixes = {
1: 'blk',
2: 'blu'
};

590
lib/blockstore/file.js Normal file
View File

@ -0,0 +1,590 @@
/*!
* blockstore/file.js - file blockstore for bcoin
* Copyright (c) 2019, Braydon Fuller (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
const {isAbsolute, resolve, join} = require('path');
const bdb = require('bdb');
const assert = require('bsert');
const fs = require('bfile');
const bio = require('bufio');
const hash256 = require('bcrypto/lib/hash256');
const Network = require('../protocol/network');
const AbstractBlockStore = require('./abstract');
const {BlockRecord, FileRecord} = require('./records');
const layout = require('./layout');
const {types, prefixes} = require('./common');
/**
* File Block Store
*
* @alias module:blockstore:FileBlockStore
* @abstract
*/
class FileBlockStore extends AbstractBlockStore {
/**
* Create a blockstore that stores blocks in files.
* @constructor
*/
constructor(options) {
super(options);
assert(isAbsolute(options.location), 'Location not absolute.');
this.location = options.location;
this.indexLocation = resolve(this.location, './index');
this.db = bdb.create({
location: this.indexLocation,
cacheSize: options.cacheSize,
compression: false
});
this.maxFileLength = options.maxFileLength || 128 * 1024 * 1024;
assert(Number.isSafeInteger(this.maxFileLength),
'Invalid max file length.');
this.network = Network.primary;
if (options.network != null)
this.network = Network.get(options.network);
this.writing = false;
}
/**
* Compares the number of files in the directory
* with the recorded number of files.
* @param {Number} type - The type of block data
* @private
* @returns {Promise}
*/
async check(type) {
const prefix = prefixes[type];
const regexp = new RegExp(`^${prefix}(\\d{5})\\.dat$`);
const all = await fs.readdir(this.location);
const dats = all.filter(f => regexp.test(f));
const filenos = dats.map(f => parseInt(f.match(regexp)[1]));
let missing = false;
for (const fileno of filenos) {
const rec = await this.db.get(layout.f.encode(type, fileno));
if (!rec) {
missing = true;
break;
}
}
return {missing, filenos};
}
/**
* Creates indexes from files for a block type. Reads the hash of
* the block data from the magic prefix, except for a block which
* the hash is read from the block header.
* @private
* @param {Number} type - The type of block data
* @returns {Promise}
*/
async _index(type) {
const {missing, filenos} = await this.check(type);
if (!missing)
return;
this.logger.info('Indexing block type %d...', type);
for (const fileno of filenos) {
const b = this.db.batch();
const filepath = this.filepath(type, fileno);
const data = await fs.readFile(filepath);
const reader = bio.read(data);
let magic = null;
let blocks = 0;
while (reader.left() >= 4) {
magic = reader.readU32();
// Move forward a byte from the last read
// if the magic doesn't match.
if (magic !== this.network.magic) {
reader.seek(-3);
continue;
}
let hash = null;
let position = 0;
let length = 0;
try {
length = reader.readU32();
if (type === types.BLOCK) {
position = reader.offset;
hash = hash256.digest(reader.readBytes(80, true));
reader.seek(length - 80);
} else {
hash = reader.readHash();
position = reader.offset;
reader.seek(length);
}
} catch (err) {
this.logger.warning(
'Unknown block in file: %s, reason: %s',
filepath, err.message);
continue;
}
const blockrecord = new BlockRecord({
file: fileno,
position: position,
length: length
});
blocks += 1;
b.put(layout.b.encode(type, hash), blockrecord.toRaw());
}
const filerecord = new FileRecord({
blocks: blocks,
used: reader.offset,
length: this.maxFileLength
});
b.put(layout.f.encode(type, fileno), filerecord.toRaw());
await b.write();
this.logger.info('Indexed %d blocks (file=%s).', blocks, filepath);
}
}
/**
* Compares the number of files in the directory
* with the recorded number of files. If there are any
* inconsistencies it will reindex all blocks.
* @private
* @returns {Promise}
*/
async index() {
await this._index(types.BLOCK);
await this._index(types.UNDO);
}
/**
* This method ensures that both the block storage directory
* and index directory exist.
* before opening.
* @returns {Promise}
*/
async ensure() {
return fs.mkdirp(this.indexLocation);
}
/**
* Opens the file block store. It will regenerate necessary block
* indexing if the index is missing or inconsistent.
* @returns {Promise}
*/
async open() {
this.logger.info('Opening FileBlockStore...');
await this.db.open();
await this.db.verify(layout.V.encode(), 'fileblockstore', 0);
await this.index();
}
/**
* This closes the file block store and underlying
* indexing databases.
*/
async close() {
this.logger.info('Closing FileBlockStore...');
await this.db.close();
}
/**
* This method will determine the file path based on the file number
* and the current block data location.
* @private
* @param {Number} type - The type of block data
* @param {Number} fileno - The number of the file.
* @returns {Promise}
*/
filepath(type, fileno) {
const pad = 5;
let num = fileno.toString(10);
if (num.length > pad)
throw new Error('File number too large.');
while (num.length < pad)
num = `0${num}`;
let filepath = null;
const prefix = prefixes[type];
if (!prefix)
throw new Error('Unknown file prefix.');
filepath = join(this.location, `${prefix}${num}.dat`);
return filepath;
}
/**
* This method will select and potentially allocate a file to
* write a block based on the size and type.
* @private
* @param {Number} type - The type of block data
* @param {Number} length - The number of bytes
* @returns {Promise}
*/
async allocate(type, length) {
if (length > this.maxFileLength)
throw new Error('Block length above max file length.');
let fileno = 0;
let filerecord = null;
let filepath = null;
const last = await this.db.get(layout.F.encode(type));
if (last)
fileno = bio.readU32(last, 0);
filepath = this.filepath(type, fileno);
const rec = await this.db.get(layout.f.encode(type, fileno));
let touch = false;
if (rec) {
filerecord = FileRecord.fromRaw(rec);
} else {
touch = true;
filerecord = new FileRecord({
blocks: 0,
used: 0,
length: this.maxFileLength
});
}
if (filerecord.used + length > filerecord.length) {
fileno += 1;
filepath = this.filepath(type, fileno);
touch = true;
filerecord = new FileRecord({
blocks: 0,
used: 0,
length: this.maxFileLength
});
}
if (touch) {
const fd = await fs.open(filepath, 'w');
await fs.close(fd);
}
return {fileno, filerecord, filepath};
}
/**
* This method stores block undo coin data in files.
* @param {Buffer} hash - The block hash
* @param {Buffer} data - The block data
* @returns {Promise}
*/
async writeUndo(hash, data) {
return this._write(types.UNDO, hash, data);
}
/**
* This method stores block data in files.
* @param {Buffer} hash - The block hash
* @param {Buffer} data - The block data
* @returns {Promise}
*/
async write(hash, data) {
return this._write(types.BLOCK, hash, data);
}
/**
* This method stores block data in files with by appending
* data to the last written file and updating indexes to point
* to the file and position.
* @private
* @param {Number} type - The type of block data
* @param {Buffer} hash - The block hash
* @param {Buffer} data - The block data
* @returns {Promise}
*/
async _write(type, hash, data) {
if (this.writing)
throw new Error('Already writing.');
this.writing = true;
if (await this.db.has(layout.b.encode(type, hash))) {
this.writing = false;
return false;
}
let mlength = 8;
// Hash for a block is not stored with
// the magic prefix as it's read from the header
// of the block data.
if (type !== types.BLOCK)
mlength += 32;
const blength = data.length;
const length = data.length + mlength;
const bwm = bio.write(mlength);
bwm.writeU32(this.network.magic);
bwm.writeU32(blength);
if (type !== types.BLOCK)
bwm.writeHash(hash);
const magic = bwm.render();
const {
fileno,
filerecord,
filepath
} = await this.allocate(type, length);
const mposition = filerecord.used;
const bposition = filerecord.used + mlength;
const fd = await fs.open(filepath, 'r+');
let mwritten = 0;
let bwritten = 0;
try {
mwritten = await fs.write(fd, magic, 0, mlength, mposition);
bwritten = await fs.write(fd, data, 0, blength, bposition);
} finally {
await fs.close(fd);
}
if (mwritten !== mlength) {
this.writing = false;
throw new Error('Could not write block magic.');
}
if (bwritten !== blength) {
this.writing = false;
throw new Error('Could not write block.');
}
filerecord.blocks += 1;
filerecord.used += length;
const b = this.db.batch();
const blockrecord = new BlockRecord({
file: fileno,
position: bposition,
length: blength
});
b.put(layout.b.encode(type, hash), blockrecord.toRaw());
b.put(layout.f.encode(type, fileno), filerecord.toRaw());
const last = bio.write(4).writeU32(fileno).render();
b.put(layout.F.encode(type), last);
await b.write();
this.writing = false;
return true;
}
/**
* This method will retrieve block undo coin data.
* @param {Buffer} hash - The block hash
* @returns {Promise}
*/
async readUndo(hash) {
return this._read(types.UNDO, hash);
}
/**
* This method will retrieve block data. Smaller portions of the
* block (e.g. transactions) can be read by using the offset and
* length arguments.
* @param {Buffer} hash - The block hash
* @param {Number} offset - The offset within the block
* @param {Number} length - The number of bytes of the data
* @returns {Promise}
*/
async read(hash, offset, length) {
return this._read(types.BLOCK, hash, offset, length);
}
/**
* This methods reads data from disk by retrieving the index of
* the data and reading from the corresponding file and location.
* @private
* @param {Number} type - The type of block data
* @param {Buffer} hash - The block hash
* @param {Number} offset - The offset within the block
* @param {Number} length - The number of bytes of the data
* @returns {Promise}
*/
async _read(type, hash, offset, length) {
const raw = await this.db.get(layout.b.encode(type, hash));
if (!raw)
return null;
const blockrecord = BlockRecord.fromRaw(raw);
const filepath = this.filepath(type, blockrecord.file);
let position = blockrecord.position;
if (offset)
position += offset;
if (!length)
length = blockrecord.length;
if (offset + length > blockrecord.length)
throw new Error('Out-of-bounds read.');
const data = Buffer.alloc(length);
const fd = await fs.open(filepath, 'r');
let bytes = 0;
try {
bytes = await fs.read(fd, data, 0, length, position);
} finally {
await fs.close(fd);
}
if (bytes !== length)
throw new Error('Wrong number of bytes read.');
return data;
}
/**
* This will free resources for storing the block undo coin data.
* @param {Buffer} hash - The block hash
* @returns {Promise}
*/
async pruneUndo(hash) {
return this._prune(types.UNDO, hash);
}
/**
* This will free resources for storing the block data.
* @param {Buffer} hash - The block hash
* @returns {Promise}
*/
async prune(hash) {
return this._prune(types.BLOCK, hash);
}
/**
* This will free resources for storing the block data. The block
* data may not be deleted from disk immediately, the index for the
* block is removed and will not be able to be read. The underlying
* file is unlinked when all blocks in a file have been pruned.
* @private
* @param {Buffer} hash - The block hash
* @returns {Promise}
*/
async _prune(type, hash) {
const braw = await this.db.get(layout.b.encode(type, hash));
if (!braw)
return false;
const blockrecord = BlockRecord.fromRaw(braw);
const fraw = await this.db.get(layout.f.encode(type, blockrecord.file));
if (!fraw)
return false;
const filerecord = FileRecord.fromRaw(fraw);
filerecord.blocks -= 1;
const b = this.db.batch();
if (filerecord.blocks === 0)
b.del(layout.f.encode(type, blockrecord.file));
else
b.put(layout.f.encode(type, blockrecord.file), filerecord.toRaw());
b.del(layout.b.encode(type, hash));
await b.write();
if (filerecord.blocks === 0)
await fs.unlink(this.filepath(type, blockrecord.file));
return true;
}
/**
* This will check if a block undo coin has been stored
* and is available.
* @param {Buffer} hash - The block hash
* @returns {Promise}
*/
async hasUndo(hash) {
return await this.db.has(layout.b.encode(types.UNDO, hash));
}
/**
* This will check if a block has been stored and is available.
* @param {Buffer} hash - The block hash
* @returns {Promise}
*/
async has(hash) {
return await this.db.has(layout.b.encode(types.BLOCK, hash));
}
}
/*
* Expose
*/
module.exports = FileBlockStore;

42
lib/blockstore/index.js Normal file
View File

@ -0,0 +1,42 @@
/*!
* blockstore/index.js - bitcoin blockstore for bcoin
* Copyright (c) 2019, Braydon Fuller (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
const {join} = require('path');
const AbstractBlockStore = require('./abstract');
const LevelBlockStore = require('./level');
const FileBlockStore = require('./file');
/**
* @module blockstore
*/
exports.create = (options) => {
const location = join(options.prefix, 'blocks');
if (options.memory) {
return new LevelBlockStore({
network: options.network,
logger: options.logger,
location: location,
cacheSize: options.cacheSize,
memory: options.memory
});
}
return new FileBlockStore({
network: options.network,
logger: options.logger,
location: location,
cacheSize: options.cacheSize
});
};
exports.AbstractBlockStore = AbstractBlockStore;
exports.FileBlockStore = FileBlockStore;
exports.LevelBlockStore = LevelBlockStore;

30
lib/blockstore/layout.js Normal file
View File

@ -0,0 +1,30 @@
/*!
* blockstore/layout.js - file blockstore data layout for bcoin
* Copyright (c) 2019, Braydon Fuller (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
const bdb = require('bdb');
/*
* Database Layout:
* V -> db version
* F[type] -> last file record by type
* f[type][fileno] -> file record by type and file number
* b[type][hash] -> block record by type and block hash
*/
const layout = {
V: bdb.key('V'),
F: bdb.key('F', ['uint32']),
f: bdb.key('f', ['uint32', 'uint32']),
b: bdb.key('b', ['uint32', 'hash256'])
};
/*
* Expose
*/
module.exports = layout;

189
lib/blockstore/level.js Normal file
View File

@ -0,0 +1,189 @@
/*!
* blockstore/level.js - leveldb blockstore for bcoin
* Copyright (c) 2019, Braydon Fuller (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
const bdb = require('bdb');
const fs = require('bfile');
const AbstractBlockStore = require('./abstract');
const layout = require('./layout');
const {types} = require('./common');
/**
* LevelDB Block Store
*
* @alias module:blockstore:LevelBlockStore
* @abstract
*/
class LevelBlockStore extends AbstractBlockStore {
/**
* Create a blockstore that stores blocks in LevelDB.
* @constructor
*/
constructor(options) {
super(options);
this.location = options.location;
this.db = bdb.create({
location: this.location,
cacheSize: options.cacheSize,
compression: false,
memory: options.memory
});
}
/**
* This method ensures that the storage directory exists
* before opening.
* @returns {Promise}
*/
async ensure() {
return fs.mkdirp(this.location);
}
/**
* Opens the block storage.
* @returns {Promise}
*/
async open() {
this.logger.info('Opening LevelBlockStore...');
await this.db.open();
await this.db.verify(layout.V.encode(), 'levelblockstore', 0);
}
/**
* Closes the block storage.
*/
async close() {
this.logger.info('Closing LevelBlockStore...');
await this.db.close();
}
/**
* This method stores block undo coin data in LevelDB.
* @param {Buffer} hash - The block hash
* @param {Buffer} data - The block data
* @returns {Promise}
*/
async writeUndo(hash, data) {
return this.db.put(layout.b.encode(types.UNDO, hash), data);
}
/**
* This method stores block data in LevelDB.
* @param {Buffer} hash - The block hash
* @param {Buffer} data - The block data
* @returns {Promise}
*/
async write(hash, data) {
return this.db.put(layout.b.encode(types.BLOCK, hash), data);
}
/**
* This method will retrieve block undo coin data.
* @param {Buffer} hash - The block hash
* @returns {Promise}
*/
async readUndo(hash) {
return this.db.get(layout.b.encode(types.UNDO, hash));
}
/**
* This method will retrieve block data. Smaller portions of the
* block (e.g. transactions) can be returned using the offset and
* length arguments. However, the entire block will be read as the
* data is stored in a key/value database.
* @param {Buffer} hash - The block hash
* @param {Number} offset - The offset within the block
* @param {Number} length - The number of bytes of the data
* @returns {Promise}
*/
async read(hash, offset, length) {
let raw = await this.db.get(layout.b.encode(types.BLOCK, hash));
if (offset) {
if (offset + length > raw.length)
throw new Error('Out-of-bounds read.');
raw = raw.slice(offset, offset + length);
}
return raw;
}
/**
* This will free resources for storing the block undo coin data.
* The block data may not be immediately removed from disk, and will
* be reclaimed during LevelDB compaction.
* @param {Buffer} hash - The block hash
* @returns {Promise}
*/
async pruneUndo(hash) {
if (!await this.hasUndo(hash))
return false;
await this.db.del(layout.b.encode(types.UNDO, hash));
return true;
}
/**
* This will free resources for storing the block data. The block
* data may not be immediately removed from disk, and will be reclaimed
* during LevelDB compaction.
* @param {Buffer} hash - The block hash
* @returns {Promise}
*/
async prune(hash) {
if (!await this.has(hash))
return false;
await this.db.del(layout.b.encode(types.BLOCK, hash));
return true;
}
/**
* This will check if a block undo coin data has been stored
* and is available.
* @param {Buffer} hash - The block hash
* @returns {Promise}
*/
async hasUndo(hash) {
return this.db.has(layout.b.encode(types.UNDO, hash));
}
/**
* This will check if a block has been stored and is available.
* @param {Buffer} hash - The block hash
* @returns {Promise}
*/
async has(hash) {
return this.db.has(layout.b.encode(types.BLOCK, hash));
}
}
/*
* Expose
*/
module.exports = LevelBlockStore;

149
lib/blockstore/records.js Normal file
View File

@ -0,0 +1,149 @@
/*!
* blockstore/records.js - blockstore records
* Copyright (c) 2019, Braydon Fuller (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
const assert = require('bsert');
const bio = require('bufio');
/**
* @module blockstore/records
*/
/**
* Block Record
*/
class BlockRecord {
/**
* Create a block record.
* @constructor
*/
constructor(options = {}) {
this.file = options.file || 0;
this.position = options.position || 0;
this.length = options.length || 0;
assert((this.file >>> 0) === this.file);
assert((this.position >>> 0) === this.position);
assert((this.length >>> 0) === this.length);
}
/**
* Inject properties from serialized data.
* @private
* @param {Buffer} data
*/
fromRaw(data) {
const br = bio.read(data);
this.file = br.readU32();
this.position = br.readU32();
this.length = br.readU32();
return this;
}
/**
* Instantiate block record from serialized data.
* @param {Hash} hash
* @param {Buffer} data
* @returns {BlockRecord}
*/
static fromRaw(data) {
return new this().fromRaw(data);
}
/**
* Serialize the block record.
* @returns {Buffer}
*/
toRaw() {
const bw = bio.write(12);
bw.writeU32(this.file);
bw.writeU32(this.position);
bw.writeU32(this.length);
return bw.render();
}
}
/**
* File Record
*/
class FileRecord {
/**
* Create a file record.
* @constructor
*/
constructor(options = {}) {
this.blocks = options.blocks || 0;
this.used = options.used || 0;
this.length = options.length || 0;
assert((this.blocks >>> 0) === this.blocks);
assert((this.used >>> 0) === this.used);
assert((this.length >>> 0) === this.length);
}
/**
* Inject properties from serialized data.
* @private
* @param {Buffer} data
*/
fromRaw(data) {
const br = bio.read(data);
this.blocks = br.readU32();
this.used = br.readU32();
this.length = br.readU32();
return this;
}
/**
* Instantiate file record from serialized data.
* @param {Hash} hash
* @param {Buffer} data
* @returns {ChainState}
*/
static fromRaw(data) {
return new this().fromRaw(data);
}
/**
* Serialize the file record.
* @returns {Buffer}
*/
toRaw() {
const bw = bio.write(12);
bw.writeU32(this.blocks);
bw.writeU32(this.used);
bw.writeU32(this.length);
return bw.render();
}
}
/*
* Expose
*/
exports.BlockRecord = BlockRecord;
exports.FileRecord = FileRecord;
module.exports = exports;

366
lib/btc/amount.js Normal file
View File

@ -0,0 +1,366 @@
/*!
* amount.js - amount object for bcoin
* Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
const assert = require('bsert');
const fixed = require('../utils/fixed');
const {inspectSymbol} = require('../utils');
/**
* Amount
* Represents a bitcoin amount (satoshis internally).
* @alias module:btc.Amount
* @property {Amount} value
*/
class Amount {
/**
* Create an amount.
* @constructor
* @param {(String|Number)?} value
* @param {String?} unit
*/
constructor(value, unit) {
this.value = 0;
if (value != null)
this.fromOptions(value, unit);
}
/**
* Inject properties from options.
* @private
* @param {(String|Number)?} value
* @param {String?} unit
* @returns {Amount}
*/
fromOptions(value, unit) {
if (typeof unit === 'string')
return this.from(unit, value);
if (typeof value === 'number')
return this.fromValue(value);
return this.fromBTC(value);
}
/**
* Get satoshi value.
* @returns {Amount}
*/
toValue() {
return this.value;
}
/**
* Get satoshi string or value.
* @param {Boolean?} num
* @returns {String|Amount}
*/
toSatoshis(num) {
if (num)
return this.value;
return this.value.toString(10);
}
/**
* Get bits string or value.
* @param {Boolean?} num
* @returns {String|Amount}
*/
toBits(num) {
return Amount.encode(this.value, 2, num);
}
/**
* Get mbtc string or value.
* @param {Boolean?} num
* @returns {String|Amount}
*/
toMBTC(num) {
return Amount.encode(this.value, 5, num);
}
/**
* Get btc string or value.
* @param {Boolean?} num
* @returns {String|Amount}
*/
toBTC(num) {
return Amount.encode(this.value, 8, num);
}
/**
* Get unit string or value.
* @param {String} unit - Can be `sat`,
* `ubtc`, `bits`, `mbtc`, or `btc`.
* @param {Boolean?} num
* @returns {String|Amount}
*/
to(unit, num) {
switch (unit) {
case 'sat':
return this.toSatoshis(num);
case 'ubtc':
case 'bits':
return this.toBits(num);
case 'mbtc':
return this.toMBTC(num);
case 'btc':
return this.toBTC(num);
}
throw new Error(`Unknown unit "${unit}".`);
}
/**
* Convert amount to bitcoin string.
* @returns {String}
*/
toString() {
return this.toBTC();
}
/**
* Inject properties from value.
* @private
* @param {Amount} value
* @returns {Amount}
*/
fromValue(value) {
assert(Number.isSafeInteger(value) && value >= 0,
'Value must be an int64.');
this.value = value;
return this;
}
/**
* Inject properties from satoshis.
* @private
* @param {Number|String} value
* @returns {Amount}
*/
fromSatoshis(value) {
this.value = Amount.decode(value, 0);
return this;
}
/**
* Inject properties from bits.
* @private
* @param {Number|String} value
* @returns {Amount}
*/
fromBits(value) {
this.value = Amount.decode(value, 2);
return this;
}
/**
* Inject properties from mbtc.
* @private
* @param {Number|String} value
* @returns {Amount}
*/
fromMBTC(value) {
this.value = Amount.decode(value, 5);
return this;
}
/**
* Inject properties from btc.
* @private
* @param {Number|String} value
* @returns {Amount}
*/
fromBTC(value) {
this.value = Amount.decode(value, 8);
return this;
}
/**
* Inject properties from unit.
* @private
* @param {String} unit
* @param {Number|String} value
* @returns {Amount}
*/
from(unit, value) {
switch (unit) {
case 'sat':
return this.fromSatoshis(value);
case 'ubtc':
case 'bits':
return this.fromBits(value);
case 'mbtc':
return this.fromMBTC(value);
case 'btc':
return this.fromBTC(value);
}
throw new Error(`Unknown unit "${unit}".`);
}
/**
* Instantiate amount from options.
* @param {(String|Number)?} value
* @param {String?} unit
* @returns {Amount}
*/
static fromOptions(value, unit) {
return new this().fromOptions(value, unit);
}
/**
* Instantiate amount from value.
* @private
* @param {Amount} value
* @returns {Amount}
*/
static fromValue(value) {
return new this().fromValue(value);
}
/**
* Instantiate amount from satoshis.
* @param {Number|String} value
* @returns {Amount}
*/
static fromSatoshis(value) {
return new this().fromSatoshis(value);
}
/**
* Instantiate amount from bits.
* @param {Number|String} value
* @returns {Amount}
*/
static fromBits(value) {
return new this().fromBits(value);
}
/**
* Instantiate amount from mbtc.
* @param {Number|String} value
* @returns {Amount}
*/
static fromMBTC(value) {
return new this().fromMBTC(value);
}
/**
* Instantiate amount from btc.
* @param {Number|String} value
* @returns {Amount}
*/
static fromBTC(value) {
return new this().fromBTC(value);
}
/**
* Instantiate amount from unit.
* @param {String} unit
* @param {Number|String} value
* @returns {Amount}
*/
static from(unit, value) {
return new this().from(unit, value);
}
/**
* Inspect amount.
* @returns {String}
*/
[inspectSymbol]() {
return `<Amount: ${this.toString()}>`;
}
/**
* Safely convert satoshis to a BTC string.
* This function explicitly avoids any
* floating point arithmetic.
* @param {Amount} value - Satoshis.
* @returns {String} BTC string.
*/
static btc(value, num) {
if (typeof value === 'string')
return value;
return Amount.encode(value, 8, num);
}
/**
* Safely convert a BTC string to satoshis.
* @param {String} str - BTC
* @returns {Amount} Satoshis.
* @throws on parse error
*/
static value(str) {
if (typeof str === 'number')
return str;
return Amount.decode(str, 8);
}
/**
* Safely convert satoshis to a BTC string.
* @param {Amount} value
* @param {Number} exp - Exponent.
* @param {Boolean} num - Return a number.
* @returns {String|Number}
*/
static encode(value, exp, num) {
if (num)
return fixed.toFloat(value, exp);
return fixed.encode(value, exp);
}
/**
* Safely convert a BTC string to satoshis.
* @param {String|Number} value - BTC
* @param {Number} exp - Exponent.
* @returns {Amount} Satoshis.
* @throws on parse error
*/
static decode(value, exp) {
if (typeof value === 'number')
return fixed.fromFloat(value, exp);
return fixed.decode(value, exp);
}
}
/*
* Expose
*/
module.exports = Amount;

14
lib/btc/index.js Normal file
View File

@ -0,0 +1,14 @@
/*!
* btc/index.js - high-level btc objects for bcoin
* Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
/**
* @module btc
*/
exports.Amount = require('./amount');
exports.URI = require('./uri');

286
lib/btc/uri.js Normal file
View File

@ -0,0 +1,286 @@
/**
* uri.js - bitcoin uri parsing for bcoin
* Copyright (c) 2014-2017, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
const assert = require('bsert');
const Address = require('../primitives/address');
const Amount = require('./amount');
const {inspectSymbol} = require('../utils');
/**
* URI
* Represents a bitcoin URI.
* @alias module:btc.URI
* @property {Address} address
* @property {Amount} amount
* @property {String|null} label
* @property {String|null} message
* @property {String|null} request
*/
class URI {
/**
* Create a bitcoin URI.
* @alias module:btc.URI
* @constructor
* @param {Object|String} options
*/
constructor(options) {
this.address = new Address();
this.amount = -1;
this.label = null;
this.message = null;
this.request = null;
if (options)
this.fromOptions(options);
}
/**
* Inject properties from options object.
* @private
* @param {Object|String} options
* @returns {URI}
*/
fromOptions(options) {
if (typeof options === 'string')
return this.fromString(options);
if (options.address)
this.address.fromOptions(options.address);
if (options.amount != null) {
assert(Number.isSafeInteger(options.amount) && options.amount >= 0,
'Amount must be a uint64.');
this.amount = options.amount;
}
if (options.label) {
assert(typeof options.label === 'string', 'Label must be a string.');
this.label = options.label;
}
if (options.message) {
assert(typeof options.message === 'string', 'Message must be a string.');
this.message = options.message;
}
if (options.request) {
assert(typeof options.request === 'string', 'Request must be a string.');
this.request = options.request;
}
return this;
}
/**
* Instantiate URI from options.
* @param {Object|String} options
* @returns {URI}
*/
static fromOptions(options) {
return new this().fromOptions(options);
}
/**
* Parse and inject properties from string.
* @private
* @param {String} str
* @param {Network?} network
* @returns {URI}
*/
fromString(str, network) {
assert(typeof str === 'string');
assert(str.length > 8, 'Not a bitcoin URI.');
const prefix = str.substring(0, 8);
str = str.substring(8);
const index = str.indexOf('?');
let addr, qs;
if (index === -1) {
addr = str;
} else {
addr = str.substring(0, index);
qs = str.substring(index + 1);
}
this.address.fromString(addr, network);
if (!qs)
return this;
const query = parsePairs(qs);
if (query.amount) {
assert(query.amount.length > 0, 'Value is empty.');
assert(query.amount[0] !== '-', 'Value is negative.');
this.amount = Amount.value(query.amount);
}
if (query.label)
this.label = query.label;
if (query.message)
this.message = query.message;
if (query.r)
this.request = query.r;
return this;
}
/**
* Instantiate uri from string.
* @param {String} str
* @param {Network?} network
* @returns {URI}
*/
static fromString(str, network) {
return new this().fromString(str, network);
}
/**
* Serialize uri to a string.
* @returns {String}
*/
toString() {
let str = 'flo:';
str += this.address.toString();
const query = [];
if (this.amount !== -1)
query.push(`amount=${Amount.btc(this.amount)}`);
if (this.label)
query.push(`label=${escape(this.label)}`);
if (this.message)
query.push(`message=${escape(this.message)}`);
if (this.request)
query.push(`r=${escape(this.request)}`);
if (query.length > 0)
str += '?' + query.join('&');
return str;
}
/**
* Inspect bitcoin uri.
* @returns {String}
*/
[inspectSymbol]() {
return `<URI: ${this.toString()}>`;
}
}
/*
* Helpers
*/
class BitcoinQuery {
constructor() {
this.amount = null;
this.label = null;
this.message = null;
this.r = null;
}
}
function parsePairs(str) {
const parts = str.split('&');
const data = new BitcoinQuery();
let size = 0;
for (const pair of parts) {
const index = pair.indexOf('=');
let key, value;
if (index === -1) {
key = pair;
value = '';
} else {
key = pair.substring(0, index);
value = pair.substring(index + 1);
}
if (key.length === 0) {
assert(value.length === 0, 'Empty key in querystring.');
continue;
}
assert(size < 4, 'Too many keys in querystring.');
switch (key) {
case 'amount':
assert(data.amount == null, 'Duplicate key in querystring (amount).');
data.amount = unescape(value);
break;
case 'label':
assert(data.label == null, 'Duplicate key in querystring (label).');
data.label = unescape(value);
break;
case 'message':
assert(data.message == null, 'Duplicate key in querystring (message).');
data.message = unescape(value);
break;
case 'r':
assert(data.r == null, 'Duplicate key in querystring (r).');
data.r = unescape(value);
break;
default:
assert(false, `Unknown querystring key: ${value}.`);
break;
}
size += 1;
}
return data;
}
function unescape(str) {
try {
str = decodeURIComponent(str);
str = str.replace(/\+/g, ' ');
} catch (e) {
throw new Error('Malformed URI.');
}
if (str.indexOf('\0') !== -1)
throw new Error('Malformed URI.');
return str;
}
function escape(str) {
str = encodeURIComponent(str);
str = str.replace(/%20/g, '+');
return str;
}
/*
* Expose
*/
module.exports = URI;

View File

@ -1,63 +0,0 @@
/*!
* blockdb.js - blockchain data management for bcoin
* Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
/**
* BlockDB
* @constructor
*/
function BlockDB(chaindb) {
this.chaindb = chaindb;
this.db = chaindb.db;
this.layout = chaindb.layout;
}
BlockDB.prototype.open = function open() {
return Promise.resolve();
};
BlockDB.prototype.close = function close() {
return Promise.resolve();
};
BlockDB.prototype.sync = function sync() {
return Promise.resolve();
};
BlockDB.prototype.saveBlock = function saveBlock(block) {
this.chaindb.put(this.layout.b(block.hash()), block.toRaw());
return Promise.resolve();
};
BlockDB.prototype.readBlock = function readBlock(hash) {
return this.db.get(this.layout.b(hash));
};
BlockDB.prototype.readBlockEntry = function readBlockEntry(entry) {
return this.readBlock(entry.hash);
};
BlockDB.prototype.removeBlock = function removeBlock(hash) {
this.chaindb.del(this.layout.b(hash));
return Promise.resolve();
};
BlockDB.prototype.pruneBlock = function pruneBlock(hash) {
this.chaindb.del(this.layout.b(hash));
return Promise.resolve();
};
BlockDB.prototype.pruneBlockEntry = function pruneBlockEntry(entry) {
return this.pruneBlock(entry.hash);
};
/*
* Expose
*/
module.exports = BlockDB;

View File

@ -1,196 +0,0 @@
/*!
* blockdb.js - blockchain data management for bcoin
* Copyright (c) 2014-2015, Fedor Indutny (MIT License)
* Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
var assert = require('assert');
var co = require('../utils/co');
var Flat = require('../db/flat');
var LRU = require('../utils/lru');
var FileEntry = Flat.FileEntry;
/**
* BlockDB
* @constructor
*/
function BlockDB(chaindb) {
this.chaindb = chaindb;
this.db = chaindb.db;
this.layout = chaindb.layout;
this.flat = new Flat(this.db);
this.cache = new LRU(8192);
}
BlockDB.prototype.open = function open() {
return this.flat.open();
};
BlockDB.prototype.close = function close() {
return this.flat.close();
};
BlockDB.prototype.sync = co(function* sync() {
var entry = yield this.chaindb.getTip();
var block, rollback;
assert(entry);
for (;;) {
try {
block = yield this.readBlock(entry.hash);
} catch (e) {
if (e.type !== 'ChecksumMismatch')
throw e;
block = null;
}
if (block)
break;
this.cache.remove(entry.hash);
entry = yield entry.getPrevious();
assert(entry);
rollback = true;
}
if (!rollback)
return;
yield this.chaindb.reset(entry.hash, true);
});
BlockDB.prototype.getEntry = co(function* getEntry(hash) {
var key = hash;
var entry, data;
if (typeof key !== 'string')
key = key.toString('hex');
entry = this.cache.get(key);
if (entry)
return entry;
data = yield this.db.get(this.layout.b(hash));
if (!data)
return;
entry = FileEntry.fromRaw(data);
this.cache.set(key, entry);
return entry;
});
BlockDB.prototype.saveBlock = co(function* saveBlock(block) {
var hash = block.hash();
var hex = block.hash('hex');
var entry = yield this.flat.write(block.toRaw());
if (block.height === 0)
yield this.flat.sync();
this.cache.set(hex, entry);
this.chaindb.put(this.layout.b(hash), entry.toRaw());
});
BlockDB.prototype.readBlock = co(function* readBlock(hash) {
var entry = yield this.getEntry(hash);
if (!entry)
return;
return yield this.readBlockEntry(entry);
});
BlockDB.prototype.readBlockEntry = function readBlockEntry(entry) {
return this.flat.read(entry.index, entry.pos);
};
BlockDB.prototype.removeBlock = co(function* removeBlock(hash) {
var entry = yield this.getEntry(hash);
if (!entry)
return;
this.chaindb.del(this.layout.b(hash));
if (entry.pos === 0)
yield this.flat.remove(entry.index);
});
BlockDB.prototype.pruneBlock = co(function* pruneBlock(hash) {
var entry = yield this.getEntry(hash);
if (!entry)
return;
return yield this.pruneBlockEntry(hash, entry);
});
BlockDB.prototype.pruneBlockEntry = function pruneBlockEntry(hash, entry) {
var index = entry.index;
if (index === this.current.index)
index -= 1;
this.chaindb.del(this.layout.b(hash));
return this.flat.remove(index);
};
/**
* Batch
* @constructor
*/
function Batch(ffdb) {
this.ffdb = ffdb;
this.ops = [];
}
Batch.prototype.put = function put(block) {
this.ops.push(new BatchOp(0, block));
};
Batch.prototype.del = function del(hash) {
this.ops.push(new BatchOp(1, hash));
};
Batch.prototype.write = co(function* write() {
var i, op;
for (i = 0; i < this.ops.length; i++) {
op = this.ops[i];
switch (op.type) {
case 0:
yield this.ffdb.saveBlock(op.data);
break;
case 1:
yield this.ffdb.removeBlock(op.data);
break;
default:
assert(false);
}
}
});
/**
* BatchOp
* @constructor
*/
function BatchOp(type, data) {
this.type = type;
this.data = data;
}
/*
* Expose
*/
module.exports = BlockDB;

View File

@ -1,95 +0,0 @@
/*!
* layout-browser.js - chaindb layout for browser.
* Copyright (c) 2014-2016, Christopher Jeffrey (MIT License).
* https://github.com/bcoin-org/bcoin
*/
'use strict';
var utils = require('../utils/utils');
var pad32 = utils.pad32;
var layout = {
R: 'R',
O: 'O',
e: function e(hash) {
return 'e' + hex(hash);
},
h: function h(hash) {
return 'h' + hex(hash);
},
H: function H(height) {
return 'H' + pad32(height);
},
n: function n(hash) {
return 'n' + hex(hash);
},
p: function p(hash) {
return 'p' + hex(hash);
},
b: function b(hash) {
return 'b' + hex(hash);
},
t: function t(hash) {
return 't' + hex(hash);
},
c: function c(hash) {
return 'c' + hex(hash);
},
u: function u(hash) {
return 'u' + hex(hash);
},
T: function T(address, hash) {
address = hex(address);
if (address.length === 64)
return 'W' + address + hex(hash);
return 'T' + address + hex(hash);
},
C: function C(address, hash, index) {
address = hex(address);
if (address.length === 64)
return 'X' + address + hex(hash) + pad32(index);
return 'C' + address + hex(hash) + pad32(index);
},
pp: function aa(key) {
return key.slice(1, 65);
},
Cc: function Cc(key) {
var hash, index;
if (key.length === 139) {
hash = key.slice(65, 129);
index = +key.slice(129);
} else {
hash = key.slice(41, 105);
index = +key.slice(105);
}
return [hash, index];
},
Tt: function Tt(key) {
return key.length === 129
? key.slice(64)
: key.slice(41);
}
};
/*
* Helpers
*/
function hex(hash) {
if (typeof hash !== 'string')
hash = hash.toString('hex');
return hash;
}
/*
* Expose
*/
module.exports = layout;

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More