lnwallet/btcwallet: fix bug in non-recognition of self-funds in chan force close
This commit fixes a bug which would cause the node on the _receiving_ side of a channel force close to be blind of their immediately funds on-chain. The root of the issue was that within the btcwallet implementation of the WalletController method ‘NewRawKey’, the wallet wouldn’t request notifications for the new address, as the direct function from the waddrmgr was used which skips registration of the new address. To fix, this, we now ensure that btcwallet will receive notifications for keys used within the raw p2wkh commitment output. This ensures that the wallet is aware of funds that are made available as a result of a channel force closure by the channel counter party.
This commit is contained in:
parent
a9078562ac
commit
1da054625b
@ -235,18 +235,21 @@ func (b *BtcWallet) GetPrivKey(a btcutil.Address) (*btcec.PrivateKey, error) {
|
||||
//
|
||||
// This is a part of the WalletController interface.
|
||||
func (b *BtcWallet) NewRawKey() (*btcec.PublicKey, error) {
|
||||
nextAddr, err := b.wallet.Manager.NextExternalAddresses(defaultAccount,
|
||||
1, waddrmgr.WitnessPubKey)
|
||||
addr, err := b.wallet.NewAddress(defaultAccount,
|
||||
waddrmgr.WitnessPubKey)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pkAddr := nextAddr[0].(waddrmgr.ManagedPubKeyAddress)
|
||||
pkAddr, err := b.wallet.Manager.Address(addr)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return pkAddr.PubKey(), nil
|
||||
return pkAddr.(waddrmgr.ManagedPubKeyAddress).PubKey(), nil
|
||||
}
|
||||
|
||||
// FetchRootKey returns a root key which is meanted to be used as an initial
|
||||
// FetchRootKey returns a root key which is intended to be used as an initial
|
||||
// seed/salt to generate any Lightning specific secrets.
|
||||
//
|
||||
// This is a part of the WalletController interface.
|
||||
|
@ -131,6 +131,9 @@ type WalletController interface {
|
||||
// NewRawKey returns a raw private key controlled by the wallet. These
|
||||
// keys are used for the 2-of-2 multi-sig outputs for funding
|
||||
// transactions, as well as the pub key used for commitment transactions.
|
||||
//
|
||||
// NOTE: The wallet MUST watch for on-chain outputs created to a p2wpkh
|
||||
// script using keys returned by this function.
|
||||
NewRawKey() (*btcec.PublicKey, error)
|
||||
|
||||
// FetchRootKey returns a root key which will be used by the
|
||||
|
Loading…
Reference in New Issue
Block a user