Commit graph

1096 commits

Author SHA1 Message Date
Olaoluwa Osuntokun
6f6abef1d6 waddrmgr: introduce concept of scopes for key managers
In this commit, we introduce the concept of scopes for individual key
managers. Each scope will lock down a key manager to a particular
purpose and coin type within the BIP0043 hierarchy. Each scope will
also have a set address type schema. This schema will be consulted when
creating addresses for a particular scoped key manager.

Finally, we introduce 3 new default scopes:
   * BIP 44
   * BIP 84
   * BIP 49++ (BIP49 but uses p2wkh for change addresses)
2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
f4ef7cdd29 waddrmgr: store block timestamp in BlockStamp 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
ab4ccacbb9 wallet: extend PublishTransaction to be a general reliable broadcaster
In this commit, we extend the PublishTransction method to be a more
general semi reliable transaction broadcast mechanism. We do this by
removing the special casing for neutrino. With this change, we’ll
_always_ write any transactions to be broadcast to disk. A side effect
of this, is that if the transaction doesn’t *directly* involve any
outputs we control, then it’ll linger around until a restart, when we
try to rebroadcast, and observe that it has bene rejected.
2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
54b31c1a35 wallet: remove conflicting double spend transactions on start up 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
50acc9cdf5 wtxmgr: add new method to allow callers to remove conflicted unmined txns
In this commit, we add a new method to the Store object that allows
callers to *manually* remove any conflicting transactions. At times,
it’s the case that while we were offline another transaction was
broadcast that double spends our own, or with the existence of RBF,
another replacement transaction was generated. In this case, when we
come back online, the tx will be rejected. Currently, we have no way of
removing such transaction sot avoid the retransmit-then-reject-dance.
This commit fixes that by adding RemoveUnminedTx.
2018-05-23 19:38:56 -07:00
Johan T. Halseth
8bcd56fc27 wallet/size test: add vsize test for non-segwit tx 2018-05-23 19:38:56 -07:00
Johan T. Halseth
d626036401 wallet/author: use vsize when estimating fees
This commit makes use of the recently added EstimateVirtualSize
method to estimated the size of a transaction when calculating
fees. This makes fee estimation more accurate when we are spending
segwit outputs, as before we wouldn't account for the witness
descount, resulting in overshooting fee estimates.
2018-05-23 19:38:56 -07:00
Johan T. Halseth
2caa8878b4 wallet/size test: add TestEstimateVirtualSize
This commit adds a test for EstimateVirtualSize. Currently three
test transactions are added:
    - 1 P2WPKH inputs + 2 P2PKH outputs
    - 1 P2SH-P2WPKH inputs + 2 P2PKH outputs
    - 1 P2WPKH inputs + 1 P2PKH output + 1 P2WPKH change output
2018-05-23 19:38:56 -07:00
Johan T. Halseth
f782f9dc68 wallet/size: add EstimateVirtualSize
This commit adds a new method EstimateVirtualSize that calculates
the worst case estimate vsize for a transaction with a given set
of inputs and outputs. This method is aware of P2PKH, P2WPKH and
P2SH-P2WPKH inputs, and caulculates the transaction vsize with
the witness data included.
2018-05-23 19:38:56 -07:00
Conner Fromknecht
2bd4130581 chain/bitcoind: connect to zmq in Start() to return error 2018-05-23 19:38:56 -07:00
Alex
2c34216319 build: update glide to latest btcd, neutrino, and gozmq 2018-05-23 19:38:56 -07:00
Alex
30d84da3e5 build+chain: replace pebbe/zmq4 with lightninglabs/gozmq (native Go) 2018-05-23 19:38:56 -07:00
Alex
a16bfd7775 chain/neutrino: fix data races due to not using pointer for rescan 2018-05-23 19:38:56 -07:00
Alex
78a69b4802 chain/neutrino: fix deadlock 2018-05-23 19:38:56 -07:00
Alex
73dbcf3943 multi: add bitcoind back-end (only for API use for now) 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
b963eb3ba4 wallet: pass in fee-per-kb into CreateSimpleTx 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
1cbee7c506 build: update to latest btcd and neutrino 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
aa42e17e2f rpc/legacyrpc: update method to use default fee rate 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
7b9d880fee wallet: remove internal relayFee in favor of passing in fee rate when sending
In this commit, we do away with the internal relayFee all together.
Instead, we’ll pass in the fee rate when we’re crafting any
transactions. This allows the caller to manually dictate their desired
fee rate.
2018-05-23 19:38:56 -07:00
Alex
60b23c144e dropwtxmgr: re-create namespace and set sync info to rescan for lnd 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
9988a4d500 build: update to latest btcd+btcutil+neutrino 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
f4d3cc9351 build: update glide files for latest btcutil, btcd, and neutrino 2018-05-23 19:38:56 -07:00
Johan T. Halseth
255f23679f wallet: close db on Open() failure.
This commit makes sure the wallet db is closed if the call to
open the wallet fails, as subsequent calls to OpenExistingWallet
would fail to open the already open database.
2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
d59a767ab8 build: update glide files to point to latest neutrino+btcutil 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
ee841b07cf wallet: for ineutrino back-end insert all broadcast transactions into txstore 2018-05-23 19:38:56 -07:00
Alex
436aa312d2 build: update glide for new neutrino version 2018-05-23 19:38:56 -07:00
Alex
d7ad221ee0 chain: ensure clientMtx is never locked while waiting on channel 2018-05-23 19:38:56 -07:00
Alex
5c69110f47 wallet: ensure rescan is launched with all addresses
During the time of initial block hash catch-up, it is possible to
request an address be generated. This commit updates the active
addresses by calling `w.activeData` after the catch-up is complete.
2018-05-23 19:38:56 -07:00
Alex
5113a64617 wallet: fix nil dereference in rescanprogress ntfn handler 2018-05-23 19:38:56 -07:00
Alex
8e2c741f88 wallet: move DB access from rescan ntfns into correct goroutine 2018-05-23 19:38:56 -07:00
Alex
81a9bb67c1 wallet: set wallet birthday properly in rescans and manager 2018-05-23 19:38:56 -07:00
Alex
1b6d7a7ee3 chain: add GetBlockHeader support
This commit allows neutrino to simulate the GetBlockHeader RPC, and
allows chain client code to use the call with both btcd/RPC back end
and the neutrino back end.
2018-05-23 19:38:56 -07:00
Alex
e06434ed75 chain: add StartTime support to neutrino client
This commit adds support for using StartTime in a rescan in
neutrino. The NeutrinoClient instance can have a birthday set
such that all underlying neutrino rescans are called with that
start time.
2018-05-23 19:38:56 -07:00
Alex
555bd5d583 waddrmgr: add support for wallet birthday for creating new wallet
TODO: support for wallet upgrades and key imports
2018-05-23 19:38:56 -07:00
Alex
44f94c4ca5 build: use neutrino with StartTime rescan option 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
1897fa6517 build: update glides files to point to latest neutrino
In this commit we update the glide files to point to the latest version
of neutrino, as recently many bug fixes in the syncing logic have been
fixed.
2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
8d052d2844 build: update glide files to point to latest btcd+neutrino 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
33b2be6798 build: update glide files to point to latest btcsuite/btcd commits 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
a0abd3632c multi: update to new upstream btcsuite/btcd API's 2018-05-23 19:38:56 -07:00
Alex
2a277a8994 build: update neutrino version 2018-05-23 19:38:56 -07:00
Alex
e8b5091725 log: update to new logging API 2018-05-23 19:38:56 -07:00
Alex
081f7b0dce chain: fix issue where mutex can be unlocked twice 2018-05-23 19:38:56 -07:00
Alex
58f303b957 wallet: make initial sync play nicer with neutrino+bdb backends 2018-05-23 19:38:56 -07:00
Alex
fbde9a97c8 wallet: eliminate some unneeded database transaction opens/commits 2018-05-23 19:38:56 -07:00
Alex
4fb78bca18 wallet: add logging when catching up block hashes on startup/rescan 2018-05-23 19:38:56 -07:00
Alex
3eb28d2d37 wallet: batch initial block hash catch-up process every 10K blocks 2018-05-23 19:38:56 -07:00
Alex Akselrod
c85893de1a chain+waddrmgr+wallet: store all hashes for better reorg handling (#5) 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
4ac75773d7 chain: wait for rescan exit before re-creating, ensure thread safety 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
dcc7bbc14d build: update to latest build of neutrino 2018-05-23 19:38:56 -07:00
Olaoluwa Osuntokun
3567ae87f4 wallet: avoid double-writing block stamps in onFilteredBlockConnected 2018-05-23 19:38:56 -07:00