Merge pull request #6714 from guggero/remote-signer-fix

lnwallet: don't create BIP044 key scope by default
This commit is contained in:
Olaoluwa Osuntokun authored and GitHub committed 2022-07-13 17:17:56 -07:00
commit af47943f52
3 files changed
+37 -52

No files matched your search

+5 -1
View File
@@ -70,7 +70,11 @@
* [The HtlcSwitch now waits for a ChannelLink to stop before replacing it. This fixes a race * [The HtlcSwitch now waits for a ChannelLink to stop before replacing it. This fixes a race
condition.](https://github.com/lightningnetwork/lnd/pull/6642) condition.](https://github.com/lightningnetwork/lnd/pull/6642)
* [Integration tests now always run with nodes never deleting failed payments](https://github.com/lightningnetwork/lnd/pull/6712). * [Integration tests now always run with nodes never deleting failed
payments](https://github.com/lightningnetwork/lnd/pull/6712).
* [Fixes a key scope issue preventing new remote signing setups to be created
with `v0.15.0-beta`](https://github.com/lightningnetwork/lnd/pull/6714).
## Code Health ## Code Health
+5 -3
View File
@@ -468,7 +468,7 @@ func testPsbtChanFundingSingleStep(net *lntest.NetworkHarness, t *harnessTest) {
// Everything we do here should be done within a second or two, so we // Everything we do here should be done within a second or two, so we
// can just keep a single timeout context around for all calls. // can just keep a single timeout context around for all calls.
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout) ctxt, cancel := context.WithTimeout(ctxb, 2*defaultTimeout)
defer cancel() defer cancel()
args := nodeArgsForCommitType(lnrpc.CommitmentType_ANCHORS) args := nodeArgsForCommitType(lnrpc.CommitmentType_ANCHORS)
@@ -1019,8 +1019,6 @@ func runSignPsbtSegWitV1ScriptSpend(t *harnessTest,
func runFundAndSignPsbt(t *harnessTest, net *lntest.NetworkHarness, func runFundAndSignPsbt(t *harnessTest, net *lntest.NetworkHarness,
alice *lntest.HarnessNode) { alice *lntest.HarnessNode) {
// Everything we do here should be done within a second or two, so we
// can just keep a single timeout context around for all calls.
ctxb := context.Background() ctxb := context.Background()
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout) ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
defer cancel() defer cancel()
@@ -1042,6 +1040,8 @@ func runFundAndSignPsbt(t *harnessTest, net *lntest.NetworkHarness,
} }
for _, addrType := range spendAddrTypes { for _, addrType := range spendAddrTypes {
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
// First, spend all the coins in the wallet to an address of the // First, spend all the coins in the wallet to an address of the
// given type so that UTXO will be picked when funding a PSBT. // given type so that UTXO will be picked when funding a PSBT.
sendAllCoinsToAddrType(ctxt, t, net, alice, addrType) sendAllCoinsToAddrType(ctxt, t, net, alice, addrType)
@@ -1057,6 +1057,8 @@ func runFundAndSignPsbt(t *harnessTest, net *lntest.NetworkHarness,
// is calling FinalizePsbt directly, also works for this address // is calling FinalizePsbt directly, also works for this address
// type. // type.
assertPsbtFundSignSpend(ctxt, t, net, alice, fundOutputs, true) assertPsbtFundSignSpend(ctxt, t, net, alice, fundOutputs, true)
cancel()
} }
} }
+27 -48
View File
@@ -70,6 +70,14 @@ var (
InternalAddrType: waddrmgr.WitnessPubKey, InternalAddrType: waddrmgr.WitnessPubKey,
} }
// LndDefaultKeyScopes is the list of default key scopes that lnd adds
// to its wallet.
LndDefaultKeyScopes = []waddrmgr.KeyScope{
waddrmgr.KeyScopeBIP0049Plus,
waddrmgr.KeyScopeBIP0084,
waddrmgr.KeyScopeBIP0086,
}
// errNoImportedAddrGen is an error returned when a new address is // errNoImportedAddrGen is an error returned when a new address is
// requested for the default imported account within the wallet. // requested for the default imported account within the wallet.
errNoImportedAddrGen = errors.New("addresses cannot be generated for " + errNoImportedAddrGen = errors.New("addresses cannot be generated for " +
@@ -333,7 +341,7 @@ func (b *BtcWallet) Start() error {
// Because we might add new "default" key scopes over time, they are // Because we might add new "default" key scopes over time, they are
// created correctly for new wallets. Existing wallets don't // created correctly for new wallets. Existing wallets don't
// automatically add them, we need to do that manually now. // automatically add them, we need to do that manually now.
for _, scope := range waddrmgr.DefaultKeyScopes { for _, scope := range LndDefaultKeyScopes {
_, err := b.wallet.Manager.FetchScopedKeyManager(scope) _, err := b.wallet.Manager.FetchScopedKeyManager(scope)
if waddrmgr.IsError(err, waddrmgr.ErrScopeNotFound) { if waddrmgr.IsError(err, waddrmgr.ErrScopeNotFound) {
// The default scope wasn't found, that probably means // The default scope wasn't found, that probably means
@@ -615,29 +623,16 @@ func (b *BtcWallet) ListAccounts(name string,
if name == lnwallet.DefaultAccountName || if name == lnwallet.DefaultAccountName ||
name == waddrmgr.ImportedAddrAccountName { name == waddrmgr.ImportedAddrAccountName {
a1, err := b.wallet.AccountPropertiesByName( for _, defaultScope := range LndDefaultKeyScopes {
waddrmgr.KeyScopeBIP0049Plus, name, a, err := b.wallet.AccountPropertiesByName(
) defaultScope, name,
if err != nil { )
return nil, err if err != nil {
return nil, err
}
res = append(res, a)
} }
res = append(res, a1)
a2, err := b.wallet.AccountPropertiesByName(
waddrmgr.KeyScopeBIP0084, name,
)
if err != nil {
return nil, err
}
res = append(res, a2)
a3, err := b.wallet.AccountPropertiesByName(
waddrmgr.KeyScopeBIP0086, name,
)
if err != nil {
return nil, err
}
res = append(res, a3)
break break
} }
@@ -668,34 +663,18 @@ func (b *BtcWallet) ListAccounts(name string,
// Neither of the filters were provided, so return all accounts for our // Neither of the filters were provided, so return all accounts for our
// supported key scopes. // supported key scopes.
case name == "" && keyScope == nil: case name == "" && keyScope == nil:
accounts, err := b.wallet.Accounts(waddrmgr.KeyScopeBIP0049Plus) for _, defaultScope := range LndDefaultKeyScopes {
if err != nil { accounts, err := b.wallet.Accounts(defaultScope)
return nil, err if err != nil {
} return nil, err
for _, account := range accounts.Accounts { }
account := account for _, account := range accounts.Accounts {
res = append(res, &account.AccountProperties) account := account
res = append(res, &account.AccountProperties)
}
} }
accounts, err = b.wallet.Accounts(waddrmgr.KeyScopeBIP0084) accounts, err := b.wallet.Accounts(waddrmgr.KeyScope{
if err != nil {
return nil, err
}
for _, account := range accounts.Accounts {
account := account
res = append(res, &account.AccountProperties)
}
accounts, err = b.wallet.Accounts(waddrmgr.KeyScopeBIP0086)
if err != nil {
return nil, err
}
for _, account := range accounts.Accounts {
account := account
res = append(res, &account.AccountProperties)
}
accounts, err = b.wallet.Accounts(waddrmgr.KeyScope{
Purpose: keychain.BIP0043Purpose, Purpose: keychain.BIP0043Purpose,
Coin: b.cfg.CoinType, Coin: b.cfg.CoinType,
}) })