Skip to content

Commit 2d40071

Browse files
committed
sweeptimelockmanual: add new test case with latest lnd
1 parent bb9494a commit 2d40071

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

cmd/chantools/sweeptimelockmanual.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -534,15 +534,6 @@ func tryKey(baseKey *hdkeychain.ExtendedKey, remoteRevPoint *btcec.PublicKey,
534534
}
535535

536536
// Now we try the same with the new revocation producer format.
537-
multiSigPath = []uint32{
538-
lnd.HardenedKey(uint32(keychain.KeyFamilyMultiSig)),
539-
0, idx,
540-
}
541-
multiSigPrivKey, err = lnd.PrivKeyFromPath(baseKey, multiSigPath)
542-
if err != nil {
543-
return 0, nil, nil, nil, nil, err
544-
}
545-
546537
revRoot3, err := lnd.ShaChainFromPath(
547538
baseKey, revPath3, multiSigPrivKey.PubKey(),
548539
)

cmd/chantools/sweeptimelockmanual_test.go

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313

1414
var sweepTimeLockManualCases = []struct {
1515
baseKey string
16+
rootKey string
17+
basePath []uint32
1618
keyIndex uint32
1719
timeLockAddr string
1820
remoteRevPubKey string
@@ -58,7 +60,7 @@ var sweepTimeLockManualCases = []struct {
5860
// when already the old format was present, this leads to the situation
5961
// where the idx for the shachain root (revocation root) is equal to
6062
// the delay basepoint index. Normally when starting a node after
61-
// lnd with the version v0.13.0-beta onwords, the index is always
63+
// lnd with the version v0.13.0-beta onwards, the index is always
6264
// +1 compared to the delay basepoint index.
6365
baseKey: "tprv8e3Mee42NcUd2MbwxBCJyEEhvKa8KqjiDR76M7ym4DJSfZ" +
6466
"kfDyA46XZeA4kTj8YKktWrjGBDThxxcL4HBF89jDKseu24XtugVMNsm3GhHwK",
@@ -67,6 +69,16 @@ var sweepTimeLockManualCases = []struct {
6769
"rhetju2srseqrh",
6870
remoteRevPubKey: "0341692a025ad552c62689a630ff24d9439e3752d8e0ac5cb4" +
6971
"1b5e71ab2bd46d0f",
72+
}, {
73+
// Anchor channel with lnd 0.18.x-beta.
74+
rootKey: "tprv8ZgxMBicQKsPdRiEUwMA71fkU9XoiPakhuSAEGCfcpgZxraB" +
75+
"eXKCfJSVo2SMAAEENrZU6x4V5gu5at6cpnasaf9oSrUh72zXaEdWDgSFVEf",
76+
basePath: []uint32{lnd.HardenedKey(1017), lnd.HardenedKey(1)},
77+
keyIndex: 3,
78+
timeLockAddr: "bcrt1qqm2u8pyqjc8akatdyap5qsjh7z4fuytwaehsjndt93e50l0" +
79+
"sup4qa2384v",
80+
remoteRevPubKey: "028a2199d9c64f21b59c01a5d5429fbe78b8709f0270deaf91" +
81+
"578f682b87a12796",
7082
}}
7183

7284
func TestSweepTimeLockManual(t *testing.T) {
@@ -79,8 +91,17 @@ func TestSweepTimeLockManual(t *testing.T) {
7991
)
8092
require.NoError(t, err)
8193

82-
baseKey, err := hdkeychain.NewKeyFromString(tc.baseKey)
83-
require.NoError(t, err)
94+
var baseKey *hdkeychain.ExtendedKey
95+
if tc.baseKey != "" {
96+
baseKey, err = hdkeychain.NewKeyFromString(tc.baseKey)
97+
require.NoError(t, err)
98+
} else {
99+
rootKey, err := hdkeychain.NewKeyFromString(tc.rootKey)
100+
require.NoError(t, err)
101+
102+
baseKey, err = lnd.DeriveChildren(rootKey, tc.basePath)
103+
require.NoError(t, err)
104+
}
84105

85106
revPubKeyBytes, _ := hex.DecodeString(tc.remoteRevPubKey)
86107
revPubKey, _ := btcec.ParsePubKey(revPubKeyBytes)

0 commit comments

Comments
 (0)