Skip to content

Commit 906fa0b

Browse files
committed
Merge branch '0-18-4-branch-rc1-9223' into 0-18-4-branch-rc1
2 parents 615f3d6 + 593afee commit 906fa0b

File tree

2 files changed

+50
-6
lines changed

2 files changed

+50
-6
lines changed

itest/lnd_coop_close_external_delivery_test.go

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,44 @@ import (
1010
)
1111

1212
func testCoopCloseWithExternalDelivery(ht *lntest.HarnessTest) {
13-
ht.Run("set delivery address at open", func(t *testing.T) {
13+
ok := ht.Run("set P2WPKH delivery address at open", func(t *testing.T) {
1414
tt := ht.Subtest(t)
15-
testCoopCloseWithExternalDeliveryImpl(tt, true)
15+
testCoopCloseWithExternalDeliveryImpl(
16+
tt, true, lnrpc.AddressType_UNUSED_WITNESS_PUBKEY_HASH,
17+
)
1618
})
17-
ht.Run("set delivery address at close", func(t *testing.T) {
19+
// Abort the test if failed.
20+
if !ok {
21+
return
22+
}
23+
24+
ok = ht.Run("set P2WPKH delivery address at close", func(t *testing.T) {
25+
tt := ht.Subtest(t)
26+
testCoopCloseWithExternalDeliveryImpl(
27+
tt, false, lnrpc.AddressType_UNUSED_WITNESS_PUBKEY_HASH,
28+
)
29+
})
30+
// Abort the test if failed.
31+
if !ok {
32+
return
33+
}
34+
35+
ok = ht.Run("set P2TR delivery address at open", func(t *testing.T) {
36+
tt := ht.Subtest(t)
37+
testCoopCloseWithExternalDeliveryImpl(
38+
tt, true, lnrpc.AddressType_UNUSED_TAPROOT_PUBKEY,
39+
)
40+
})
41+
// Abort the test if failed.
42+
if !ok {
43+
return
44+
}
45+
46+
ht.Run("set P2TR delivery address at close", func(t *testing.T) {
1847
tt := ht.Subtest(t)
19-
testCoopCloseWithExternalDeliveryImpl(tt, false)
48+
testCoopCloseWithExternalDeliveryImpl(
49+
tt, false, lnrpc.AddressType_UNUSED_TAPROOT_PUBKEY,
50+
)
2051
})
2152
}
2253

@@ -25,7 +56,7 @@ func testCoopCloseWithExternalDelivery(ht *lntest.HarnessTest) {
2556
// not. Some users set this value to be an address in a different wallet and
2657
// this should not affect our ability to accurately report the settled balance.
2758
func testCoopCloseWithExternalDeliveryImpl(ht *lntest.HarnessTest,
28-
upfrontShutdown bool) {
59+
upfrontShutdown bool, deliveryAddressType lnrpc.AddressType) {
2960

3061
alice, bob := ht.Alice, ht.Bob
3162
ht.ConnectNodes(alice, bob)
@@ -35,7 +66,7 @@ func testCoopCloseWithExternalDeliveryImpl(ht *lntest.HarnessTest,
3566
// wallet. We already correctly track settled balances when the address
3667
// is in the LND wallet.
3768
addr := bob.RPC.NewAddress(&lnrpc.NewAddressRequest{
38-
Type: lnrpc.AddressType_UNUSED_WITNESS_PUBKEY_HASH,
69+
Type: deliveryAddressType,
3970
})
4071

4172
// Prepare for channel open.

lnwallet/interface.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,19 @@ func InternalKeyForAddr(wallet WalletController, netParams *chaincfg.Params,
632632

633633
walletAddr, err := wallet.AddressInfo(addr)
634634
if err != nil {
635+
// If the error is that the address can't be found, it is not
636+
// an error. This happens when any channel which is not a custom
637+
// taproot channel is cooperatively closed to an external P2TR
638+
// address. In this case there is no internal key associated
639+
// with the address. Callers can use the .Option() method to get
640+
// an option value.
641+
var managerErr waddrmgr.ManagerError
642+
if errors.As(err, &managerErr) &&
643+
managerErr.ErrorCode == waddrmgr.ErrAddressNotFound {
644+
645+
return none, nil
646+
}
647+
635648
return none, err
636649
}
637650

0 commit comments

Comments
 (0)