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 2022-07-13 17:17:56 -07:00 committed by GitHub
commit af47943f52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 52 deletions

View File

@ -70,7 +70,11 @@
* [The HtlcSwitch now waits for a ChannelLink to stop before replacing it. This fixes a race
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

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
// 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()
args := nodeArgsForCommitType(lnrpc.CommitmentType_ANCHORS)
@ -1019,8 +1019,6 @@ func runSignPsbtSegWitV1ScriptSpend(t *harnessTest,
func runFundAndSignPsbt(t *harnessTest, net *lntest.NetworkHarness,
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()
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
defer cancel()
@ -1042,6 +1040,8 @@ func runFundAndSignPsbt(t *harnessTest, net *lntest.NetworkHarness,
}
for _, addrType := range spendAddrTypes {
ctxt, cancel := context.WithTimeout(ctxb, defaultTimeout)
// 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.
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
// type.
assertPsbtFundSignSpend(ctxt, t, net, alice, fundOutputs, true)
cancel()
}
}

View File

@ -70,6 +70,14 @@ var (
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
// requested for the default imported account within the wallet.
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
// created correctly for new wallets. Existing wallets don't
// 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)
if waddrmgr.IsError(err, waddrmgr.ErrScopeNotFound) {
// The default scope wasn't found, that probably means
@ -615,29 +623,16 @@ func (b *BtcWallet) ListAccounts(name string,
if name == lnwallet.DefaultAccountName ||
name == waddrmgr.ImportedAddrAccountName {
a1, err := b.wallet.AccountPropertiesByName(
waddrmgr.KeyScopeBIP0049Plus, name,
)
if err != nil {
return nil, err
for _, defaultScope := range LndDefaultKeyScopes {
a, err := b.wallet.AccountPropertiesByName(
defaultScope, name,
)
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
}
@ -668,34 +663,18 @@ func (b *BtcWallet) ListAccounts(name string,
// Neither of the filters were provided, so return all accounts for our
// supported key scopes.
case name == "" && keyScope == nil:
accounts, err := b.wallet.Accounts(waddrmgr.KeyScopeBIP0049Plus)
if err != nil {
return nil, err
}
for _, account := range accounts.Accounts {
account := account
res = append(res, &account.AccountProperties)
for _, defaultScope := range LndDefaultKeyScopes {
accounts, err := b.wallet.Accounts(defaultScope)
if err != nil {
return nil, err
}
for _, account := range accounts.Accounts {
account := account
res = append(res, &account.AccountProperties)
}
}
accounts, err = b.wallet.Accounts(waddrmgr.KeyScopeBIP0084)
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{
accounts, err := b.wallet.Accounts(waddrmgr.KeyScope{
Purpose: keychain.BIP0043Purpose,
Coin: b.cfg.CoinType,
})