Commit graph

348 commits

Author SHA1 Message Date
Oliver Gugger 4a75796117 wallet+waddrmgr: refactor to use extended key instead of seed
To allow a wallet to be created directly from an extended master root
key (xprv), we move the derivation from seed to extended key to the
loader instead of the address manager itself.
2022-05-24 03:09:33 -07:00
eugene 3cb2c46b02
mod+wallet: use btcd/mempool IsDust for calculating mempool dust
We can now get rid of our incorrect dust calculation which did not
give exact values for segwit outputs as it was based on spending a
P2PKH output instead.
2021-08-03 16:42:20 -04:00
Oliver Gugger f07fdfb6b9
wallet: refactor txToOutputs to use walletdb.Update
To make sure we don't create any manual DB transactions, we refactor the
txToOutputs method to use walletdb.Update and the new
walletdb.ErrDryRunRollBack error for making sure a rollback is issued.
2021-07-23 12:49:38 +02:00
Oliver Gugger 178152bcd0
wallet: refactor ImportAccountDryRun to use walletdb.Update
To make sure we don't create any manual DB transactions, we refactor the
ImportAccountDryRun method to use walletdb.Update and the new
walletdb.ErrDryRunRollBack error for making sure a rollback is issued.
2021-07-23 12:49:37 +02:00
Oliver Gugger 33a0a065f9
wallet: use walletdb.Update in FundPsbt
To make sure we don't create any manual DB transactions, we refactor
FundPsbt to use walletdb.Update instead.
2021-07-23 12:49:37 +02:00
Olaoluwa Osuntokun 5649a66307
Merge pull request #751 from LN-Zap/fix-2398
Prevent duplicate notifications for (un)confirmed transactions
2021-07-13 16:05:48 -07:00
Bjarne Magnussen 419381b749
wallet: call InsertTxCheckIfExists to add a relevant tx
Let the method `addRelevantTx` use `InsertTxCheckIfExists` to insert a relevant 
transaction. If the transaction has already been recorded, the method call 
`addRelevantTx` will return early and not proceed with duplicating work of 
checking every output and duplicating the tx notification to the notification 
server.
2021-07-13 09:24:53 +02:00
Joost Jager 9f1d73d6d3
wallet: allow zero output psbt funding
To support the cpfp fee bump use case where no external outputs are
required.
2021-06-28 12:06:36 +02:00
Joost Jager 4d2665ee3a
wallet: add random coin selection 2021-05-19 08:34:55 +02:00
Wilmer Paulino 5053325946
wallet: add dry run implementation of ImportAccount
This method returns the first N external and internal addresses, which
can be presented to users to confirm whether the account has been
imported correctly.
2021-05-06 16:32:58 -07:00
Olaoluwa Osuntokun a7a9234968
Merge pull request #734 from bhandras/external_db
wallet: allow using external wallet db
2021-04-29 15:48:04 -07:00
Andras Banki-Horvath 98ba16748e
loader: add txn callback when wallet is created 2021-04-28 17:44:11 +02:00
Andras Banki-Horvath a795db6b12
wallet: support for external wallet DB 2021-04-28 17:44:10 +02:00
Oliver Gugger 1f1ffb56b5
multi: add signet params
With this commit we add the signet test network parameters to all switch
cases where we distinguish between the different networks.
2021-04-27 09:59:14 +02:00
Wilmer Paulino e1dfc4d1b7
waddrmgr+wallet: allow account import for simnet wallets
Simnet was previously left out as it didn't have defined HD versions for
some of our key scopes. To allow testing importing accounts into simnet
wallets, we fall back to use the mainnet HD versions.

This commit also addresses an issue with simnet wallets that would arise
whenever ScopedKeyManager.AccountProperties was invoked:

`failed to retrieve account public key: unsupported net SimNet`
2021-04-14 17:21:07 -07:00
Wilmer Paulino b9b4d4efe1
wallet: include redeem script for NP2WKH inputs in PSBT generation
This allows external signers to properly sign NP2WKH inputs.

Co-authored-by: Oliver Gugger <gugger@gmail.com>
2021-03-29 16:00:53 -07:00
Wilmer Paulino b318e99f4f
wallet: extend ChangeSource to support all key scopes 2021-03-29 16:00:53 -07:00
Wilmer Paulino ddbe5ecee4
wallet: expose AccountPropertiesByName 2021-03-29 16:00:52 -07:00
Wilmer Paulino bbd7f8f887
waddrmgr+wallet: expose LookupAccount
This exposes a mapping of account name to its corresponding key scope
and internal account number to facilitate the use of external APIs by
users.
2021-03-29 16:00:51 -07:00
Wilmer Paulino a180b0fcaa
wallet: allow filtering of transactions by account 2021-03-29 16:00:50 -07:00
Wilmer Paulino f5845dfb42
wallet: prevent input signing for transactions on watch-only accounts
Watch-only accounts don't have any type of private key information
stored, so we avoid populating input signatures in those cases.
2021-03-29 16:00:49 -07:00
Wilmer Paulino 2301069644
wallet: require key scope of account for transaction creation methods
Now that we're able to fund transactions from multiple accounts within
different key scopes, we extend our transaction creation methods to
accept a key scope parameter as well, to determine the correct account
to select inputs from.
2021-03-29 16:00:48 -07:00
Wilmer Paulino 7fa80abc44
waddrmgr: include master key fingerprint in derivation path
Following the previous commit, some external hardware signers require a
master key fingerprint to be present within the PSBT input derivation
paths so that the signer can recognize which inputs are relevant and
must be signed.
2021-03-29 16:00:47 -07:00
Wilmer Paulino 35b4b237c9
wallet: include BIP 32 derivation paths for inputs in PSBTs
Watch-only accounts are usually backed by an external hardware signer,
some of which require derivation paths to be populated for each relevant
input to sign.
2021-03-29 16:00:46 -07:00
Oliver Gugger 3a5d9f84b0
multi: fix linter issues 2021-03-24 14:44:32 +01:00
Olaoluwa Osuntokun 5c08d49e19
Merge pull request #732 from wpaulino/import-account-or-pubkey
wallet: support derived public key import
2021-03-23 18:39:13 -07:00
Wilmer Paulino b0a4956231
wallet: add derived public key import
Co-authored-by: Oliver Gugger <gugger@gmail.com>
2021-03-15 19:27:12 -07:00
Wilmer Paulino 0b5eca1835
wallet: move ImportPrivateKey to import.go 2021-03-15 19:27:08 -07:00
Wilmer Paulino 0492cb4507
waddrmgr: use correct DerivationPath for watch-only accounts
Previously, addresses that belong to a watch-only account would have a
derivation path using the internal account number used to identify
accounts within the databse, rather than the actual account number based
on the account's master public key child index. This wasn't an issue
before as only one account would exist within the wallet, the 0 account,
which is also the default. To ensure users of the DerivationPath struct
can arrive at addresses correctly, we introduce a new field
InternalAccount to denote the internal account number and repurpose the
existing Account field to its actual meaning.
2021-03-15 19:27:04 -07:00
Joost Jager 8932811695 wallet: parameterize lock duration
Allow arbitrary lock durations instead of a hard-coded ten minute
period.
2021-03-12 12:51:15 +01:00
Joost Jager ff2577a0e7 wtxmgr: add ListLeases 2021-03-12 12:51:15 +01:00
Olaoluwa Osuntokun 664f77ded1
Merge pull request #714 from yyforyongyu/add-bdb-timeout
bdb: Add timeout options for bbolt
2020-11-18 18:28:10 -08:00
Oliver Gugger be57c71c9c
wallet: fix incorrect namespace name
This commit fixes a panic introduced with #718 that was caused by
looking up addresses in the wrong namespace.
2020-11-18 19:42:12 +01:00
yyforyongyu e34b43b938
multi: unify WalletDBName and DefaultDBTimeout in loader 2020-11-07 22:01:51 +08:00
yyforyongyu 86bc349c6e
wallet: use db timeout in loader 2020-11-07 22:01:35 +08:00
Olaoluwa Osuntokun 9bd6d26f83
Merge pull request #718 from wpaulino/relevant-addr-spend
wallet: only request spend notification for our outputs
2020-11-05 16:52:34 -08:00
Oliver Gugger 38fbfe36c5
wallet: add DropTransactionHistory function
We create a more generic copy of the dropwtxmgr command's functionality
and export it as the DropTransactionHistory function.
It removes all transaction history from the given wallet to force a
full chain rescan. Optionally the user-defined transaction labels can be
preserved.
2020-10-24 16:39:41 +02:00
Oliver Gugger 3252f9fc11
psbt: don't add scriptSig to txIn
Because of an incorrect test, it wasn't discovered that the scriptSig
field was being set on the unsigned TX inputs for a nested SegWit input.
This commit fixes the bug and also refactors the test so it would have
caught this specific bug.
2020-10-05 11:33:51 +02:00
Oliver Gugger 98e779a102
wallet: use constant input source for change calculation
To fix a bug where specifying multiple UTXOs that are by themselves
large enough to satisfy the output amount would lead to the rest of them
being added to fees, we need to provide the transaction author with a
constant list of UTXOs. If we didn't, the author would only consider one
input and calculate the change based on that alone. But since we'd add
all inputs to the PSBT, the rest of the amounts would go to fees.
2020-10-01 15:19:13 +02:00
Oliver Gugger 34bfc5efb9
wallet: return change index from FundPsbt
To make it easy to show the user what change output was created (if any)
during the funding process, we return its index (or -1 if no change
output was created).
2020-10-01 14:57:05 +02:00
Oliver Gugger c4c2a9052e
wallet: add PSBT funding+finalizing methods 2020-08-27 21:15:00 +02:00
Oliver Gugger 78d8c81e0a
wallet: add ComputeInputScript 2020-08-27 21:14:59 +02:00
Oliver Gugger 1f2ed87055
wallet: add FetchInputInfo 2020-08-27 21:14:57 +02:00
Oliver Gugger 4aa36af74c
wallet: extract addrMgrWithChangeSource 2020-08-27 21:14:56 +02:00
Oliver Gugger 314cd98152
wallet: extract addUtxo in create TX test 2020-08-27 21:14:55 +02:00
Wilmer Paulino 682bd8d33e
wallet: only request spend notification for our outputs
We would previously request spend notifications for all transaction
outputs, leading to irrelevant transactions being found in the wallet's
transaction store.
2020-08-25 11:35:49 -07:00
Olaoluwa Osuntokun 1d31f4ea6f
Merge pull request #717 from cfromknecht/fix-dust-calc
wallet/txauthor: fix bug in dust calculation
2020-08-13 17:14:39 -07:00
Olaoluwa Osuntokun cde4b5dca4
wallet/txauthor: rename relayFeePerKb to feeRatePerKb
The new name more accurately reflects the usage of the value. This is
the target fee rate that the constructed transaction should aim to meet.
2020-08-13 16:57:32 -07:00
Olaoluwa Osuntokun fbb3bc184d
wallet/txauthor: fix bug in dust calculation
In this commit, we fix a 3 year old bug in dust calculation. Before this
commit, the target fee of the transaction to be crafted would be used to
determine dust. If the target fee is very high, then this would cause
over all higher fees, as we'd base that dust computation off of that fee
rate, rather than the min relay fee.

To fix this, we always use the min relay fee at all times when computing
dust.
2020-08-13 16:43:00 -07:00
Oliver Gugger f8cc233758
wallet: add mutex for locked outpoints 2020-08-13 20:33:31 +02:00