Commit graph

339 commits

Author SHA1 Message Date
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
Wilmer Paulino
2bd41b9dd1
wallet: handle new error string for missing/spent input in bitcoind 0.20
The error string was updated in:

3004d5a12d
2020-06-09 12:46:36 -07:00
Wilmer Paulino
0f2b15bb4d
wallet: expose persistent output leases 2020-05-28 17:53:50 -07:00
Wilmer Paulino
ce888ed941
wallet: use GetBlockHeaderVerbose to retrieve block heights in GetTransactions
There's no need to retrieve the full block as we're only interesting in
retrieve its corresponding height, which can be done with
GetBlockHeaderVerbose.
2020-05-14 15:43:03 -07:00
carla
212575f7d1
wallet: add label transaction function
Add function which allows you to retrospectively label a transaction,
optionally overwriting the existing label.
2020-05-11 15:19:42 +02:00
carla
3465d2ecc6
wallet/test: extract testWallet generation into separate function 2020-05-11 15:18:38 +02:00
carla
3809a6d553
wallet: add transaction label to transaction summary 2020-05-11 15:18:34 +02:00
carla
9e2f2ce157
wallet: add label parameter to SendOutputs 2020-05-11 15:17:55 +02:00
carla
d2f9185f6a
wallet: add label to PublishTransaction
All label parameter to PublishTransaction. Pass in an empty string
in rpc call as a placeholder for follow up PR which will add a label
parameter to the PublishTransaction request.
2020-05-11 15:16:22 +02:00
Dev Random
4c5bc1b15d
waddrmgr: create watch-only address managers and accounts
This PR allows the creation of managers and accounts that are watch-only. The state of the database after creation would be identical to the state after calling 

Manager.ConvertToWatchingOnly, assuming accounts with the right xpubs were created in the former case.

Co-authored-by: Ken Sedgwick <ken@bonsai.com>
2020-04-24 17:44:21 -07:00