lnwallet: pass chan cfgs to CreateCommitTx

Instead of passing delays and dustlimits separately, we pass the correct
channel config to CreateCommitTx from the POV of the local party that
owns the commit tx.

To make it more clear which commitment we are actually creating, we
rename variables to denote local and remote, to prepare for the case
when both outputs might be delayed.
This commit is contained in:
Johan T. Halseth committed 2020-01-06 11:42:03 +01:00
1 parent 1a4f81ed90
commit fff9dbe6f3
3 files changed
+70 -43

No files matched your search

+17 -3
View File
@@ -1015,7 +1015,7 @@ func testSpendValidation(t *testing.T, tweakless bool) {
fakeFundingTxIn := wire.NewTxIn(fundingOut, nil, nil)
const channelBalance = btcutil.Amount(1 * 10e8)
const csvTimeout = uint32(5)
const csvTimeout = 5
// We also set up set some resources for the commitment transaction.
// Each side currently has 1 BTC within the channel, with a total
@@ -1050,6 +1050,20 @@ func testSpendValidation(t *testing.T, tweakless bool) {
Privkeys: []*btcec.PrivateKey{aliceKeyPriv},
}
aliceChanCfg := &channeldb.ChannelConfig{
ChannelConstraints: channeldb.ChannelConstraints{
DustLimit: DefaultDustLimit(),
CsvDelay: csvTimeout,
},
}
bobChanCfg := &channeldb.ChannelConfig{
ChannelConstraints: channeldb.ChannelConstraints{
DustLimit: DefaultDustLimit(),
CsvDelay: csvTimeout,
},
}
// With all the test data set up, we create the commitment transaction.
// We only focus on a single party's transactions, as the scripts are
// identical with the roles reversed.
@@ -1063,8 +1077,8 @@ func testSpendValidation(t *testing.T, tweakless bool) {
NoDelayKey: bobPayKey,
}
commitmentTx, err := CreateCommitTx(
*fakeFundingTxIn, keyRing, csvTimeout, channelBalance,
channelBalance, DefaultDustLimit(),
*fakeFundingTxIn, keyRing, aliceChanCfg, bobChanCfg,
channelBalance, channelBalance,
)
if err != nil {
t.Fatalf("unable to create commitment transaction: %v", nil)