Commit graph

1385 commits

Author SHA1 Message Date
Wilmer Paulino
3fed46822c
chain: refactor BitcoindConn init params into config struct 2021-04-02 17:28:06 -07:00
Wilmer Paulino
178d124b76
chain: add PrunedBlockDispatcher implementation
To minimally support wallets connected to pruned nodes, we add a new
subsystem that can be integrated with chain clients to request blocks
that the server has already pruned. This is done by connecting to the
server's full node peers and querying them directly. Ideally, this is a
capability supported by the server, though this is not yet possible with
bitcoind.
2021-04-02 17:28:05 -07:00
Wilmer Paulino
e3523abe7b
build: update btcd dependency
This exposes the new AllowSelfConns config option allowing external
testing of peer.Peer.
2021-04-02 17:28:03 -07:00
Olaoluwa Osuntokun
e0607006dc
Merge pull request #733 from wpaulino/watch-only-account-utils
waddrmgr+wallet: support transaction creation and signing for watch-only accounts
2021-03-29 16:32:42 -07:00
Wilmer Paulino
02fedd6780
build: remove goveralls 2021-03-29 16:01:27 -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
Olaoluwa Osuntokun
07d4cc155e
Merge pull request #738 from guggero/build-improvement
Add Makefile, use golangci-lint
2021-03-29 15:55:46 -07:00
Oliver Gugger
371f7a583d
appveyor: remove appveyor configuration
This configuration to run the checks on appveyor looks very old and
unused since it still refers to glide for dependency management. We
remove the file as it no longer serves a purpose.
2021-03-24 14:44:33 +01:00
Oliver Gugger
8d9d0b9001
Travis: use make commands instead of goclean.sh
Now that we have a Makefile with all tasks previously executed in
goclean.sh, we no longer need to use that file.
2021-03-24 14:44:33 +01:00
Oliver Gugger
3a5d9f84b0
multi: fix linter issues 2021-03-24 14:44:32 +01:00
Oliver Gugger
ac3ec4fa03
lint: add new linter configuration
We use the golangci-lint in lnd and it has quite a few more detections
enabled than what's in the current gotest.sh script.
We don't start with a given base commit on purpose but instead fix
everything the linter finds in the following commits.
2021-03-24 14:44:32 +01:00
Oliver Gugger
40414fde37
rpc: run make fmt to format all code 2021-03-24 13:45:11 +01:00
Oliver Gugger
41e12c16c5
make: add Makefile
As a preparation to get rid of the clunky to handle goclean.sh, we add a
Makefile that behaves in mostly the same way as does lnd's Makefile.
2021-03-24 13:44:16 +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
f1b329f680
waddrmgr: add TODO to determine proper address type of imported key
For key scopes which have an address schema where the external and
internal branches differ, we always assume that imported keys use the
external address type defined in the scope's address schema. This may
not always be the case however, and should be handled correctly.
Ideally, we generate two addresses per imported key (only if the
external and internal address types differ) and scan for both in the
chain.
2021-03-15 19:27: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
9d909110f9
waddrmgr: use proper version for account key of non-watch-only accounts 2021-03-15 19:27:11 -07:00
Wilmer Paulino
adb3d77c86
waddrmgr: extend AccountProperties with watch-only account properties 2021-03-15 19:27:10 -07:00
Wilmer Paulino
283f914b95
waddrmgr: return err when priv key is requested for watch-only addr 2021-03-15 19:27:09 -07:00
Wilmer Paulino
0b5eca1835
wallet: move ImportPrivateKey to import.go 2021-03-15 19:27:08 -07:00
Wilmer Paulino
e2d54f001b
waddrmgr: derive account addresses with schema override
This change was motivated by the need to support importing BIP-0049 keys
that use the standard address derivation scheme, where nested witness
pubkeys are used for both the external and internal branches. Our
BIP-0049 key scope is slightly different, in that addresses derived from
the internal branch use the witness pubkey address type. By having the
option of overriding the address schema for a particular account, we can
support importing standard BIP-0049 keys.
2021-03-15 19:27:07 -07:00
Wilmer Paulino
89e1671f0c
waddrmgr: extend watch-only account init with new parameters
The master fingerprint corresponds to the fingerprint of the root master
public key (otherwise known as m/). This is required by some hardware
wallets for proper identification and signing.

The address schema is an optional field that allows an account to
override its corresponding address schema with a custom one.
2021-03-15 19:27:06 -07:00
Wilmer Paulino
198b0b8dae
waddrmgr: store watch-only accounts under new account type
Watch-only accounts are usually backed by an external signer as they do
not contain any private key information. Some external signers require a
root key fingerprint for identification and signing purposes. In order
to guarantee compatibility with external signers, we need to persist the
root key fingerprint within the database.

Before this change, watch-only accounts used the default account
database structure. In this commit, we introduce a new account type to
store different information for watch-only accounts only. This isn't a
breaking change as watch-only accounts have yet to be supported by the
primary user of the wallet (lnd). With this new account type, we can
avoid the empty private key fields, which are irrelevant to watch-only
accounts, and we can store the root key fingerprint.
2021-03-15 19:27:05 -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
Wilmer Paulino
dead1a89d9
waddrmgr: add ImportPublicKey 2021-03-15 19:27:03 -07:00
Wilmer Paulino
ee9a1fb0ce
waddrmgr: refactor code from ImportPrivateKey into methods 2021-03-15 19:27:03 -07:00
Wilmer Paulino
02c4a1a54f
build: update btcutil dependency 2021-03-15 19:27:02 -07:00
Wilmer Paulino
967f663f84
travis: bump go version to 1.15.x 2021-03-15 19:27:01 -07:00
Wilmer Paulino
742d879352
multi: fix linter 2021-03-15 19:27:00 -07:00
Wilmer Paulino
6ff982ccdc
wtxmgr: prevent race condition by using local vars 2021-03-15 19:08:06 -07:00
Olaoluwa Osuntokun
4ec908df93
Merge pull request #736 from bottlepay/wtxmgr-leases
wallet: list leases and parameterize duration
2021-03-12 15:29:44 -08: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
39cbb7bdd9
Merge pull request #731 from wpaulino/wtxmgr-migration-delete-bucket-fix
wtxmgr: ignore ErrBucketNotFound error upon locked outputs bucket deletion
2021-02-17 15:06:27 -08:00
Wilmer Paulino
690a12fa8b
wtxmgr: ignore ErrBucketNotFound error upon locked outputs bucket deletion
This error would be seen when an old wallet that has yet to update is
performing the latest wtxmgr migration. It's possible for the locked
outputs bucket to not exist if outputs haven't been locked before, so we
should its deletion correctly.
2021-02-15 14:40:34 -08:00
Olaoluwa Osuntokun
415f37ff11
Merge pull request #726 from wpaulino/wallet-db-go-mod-updates
wtxmgr+btcwallet: update to latest walletdb version
2020-12-07 15:33:35 -08:00
Olaoluwa Osuntokun
12a2c88b26
btcwallet: update to walletdb v1.3.4 2020-12-01 19:13:04 -08:00
Olaoluwa Osuntokun
526c9a6103
wtxmgr: update to walletdb v1.3.4 2020-12-01 19:12:58 -08: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
Olaoluwa Osuntokun
5ee84d89ca
Merge pull request #724 from guggero/namespace-fix
wallet: fix incorrect namespace name
2020-11-18 11:51:56 -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