diff --git a/breacharbiter_test.go b/breacharbiter_test.go index 1f407289..dcdb0f8d 100644 --- a/breacharbiter_test.go +++ b/breacharbiter_test.go @@ -1391,8 +1391,8 @@ func createInitChannels(revocationWindow int) (*lnwallet.LightningChannel, *lnwa ChanReserve: 0, MinHTLC: 0, MaxAcceptedHtlcs: uint16(rand.Int31()), + CsvDelay: uint16(csvTimeoutAlice), }, - CsvDelay: uint16(csvTimeoutAlice), MultiSigKey: keychain.KeyDescriptor{ PubKey: aliceKeyPub, }, @@ -1416,8 +1416,8 @@ func createInitChannels(revocationWindow int) (*lnwallet.LightningChannel, *lnwa ChanReserve: 0, MinHTLC: 0, MaxAcceptedHtlcs: uint16(rand.Int31()), + CsvDelay: uint16(csvTimeoutBob), }, - CsvDelay: uint16(csvTimeoutBob), MultiSigKey: keychain.KeyDescriptor{ PubKey: bobKeyPub, }, diff --git a/channeldb/channel.go b/channeldb/channel.go index 6a86bda2..5d59f9dc 100644 --- a/channeldb/channel.go +++ b/channeldb/channel.go @@ -161,6 +161,13 @@ type ChannelConstraints struct { // acted upon in the case of a unilateral channel closure or a contract // breach. MaxAcceptedHtlcs uint16 + + // CsvDelay is the relative time lock delay expressed in blocks. Any + // settled outputs that pay to the owner of this channel configuration + // MUST ensure that the delay branch uses this value as the relative + // time lock. Similarly, any HTLC's offered by this node should use + // this value as well. + CsvDelay uint16 } // ChannelConfig is a struct that houses the various configuration opens for @@ -176,13 +183,6 @@ type ChannelConfig struct { // by a participant. ChannelConstraints - // CsvDelay is the relative time lock delay expressed in blocks. Any - // settled outputs that pay to the owner of this channel configuration - // MUST ensure that the delay branch uses this value as the relative - // time lock. Similarly, any HTLC's offered by this node should use - // this value as well. - CsvDelay uint16 - // MultiSigKey is the key to be used within the 2-of-2 output script // for the owner of this channel config. MultiSigKey keychain.KeyDescriptor diff --git a/channeldb/channel_test.go b/channeldb/channel_test.go index b2e56f83..4bc11624 100644 --- a/channeldb/channel_test.go +++ b/channeldb/channel_test.go @@ -136,8 +136,8 @@ func createTestChannelState(cdb *DB) (*OpenChannel, error) { ChanReserve: btcutil.Amount(rand.Int63()), MinHTLC: lnwire.MilliSatoshi(rand.Int63()), MaxAcceptedHtlcs: uint16(rand.Int31()), + CsvDelay: uint16(rand.Int31()), }, - CsvDelay: uint16(rand.Int31()), MultiSigKey: keychain.KeyDescriptor{ PubKey: privKey.PubKey(), }, @@ -161,8 +161,8 @@ func createTestChannelState(cdb *DB) (*OpenChannel, error) { ChanReserve: btcutil.Amount(rand.Int63()), MinHTLC: lnwire.MilliSatoshi(rand.Int63()), MaxAcceptedHtlcs: uint16(rand.Int31()), + CsvDelay: uint16(rand.Int31()), }, - CsvDelay: uint16(rand.Int31()), MultiSigKey: keychain.KeyDescriptor{ PubKey: privKey.PubKey(), KeyLocator: keychain.KeyLocator{ diff --git a/fundingmanager.go b/fundingmanager.go index c799139c..9dc14d2a 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -1136,8 +1136,8 @@ func (f *fundingManager) handleFundingOpen(fmsg *fundingOpenMsg) { ChanReserve: chanReserve, MinHTLC: minHtlc, MaxAcceptedHtlcs: maxHtlcs, + CsvDelay: remoteCsvDelay, }, - CsvDelay: remoteCsvDelay, MultiSigKey: keychain.KeyDescriptor{ PubKey: copyPubKey(msg.FundingKey), }, @@ -1259,8 +1259,8 @@ func (f *fundingManager) handleFundingAccept(fmsg *fundingAcceptMsg) { ChanReserve: chanReserve, MinHTLC: resCtx.remoteMinHtlc, MaxAcceptedHtlcs: maxHtlcs, + CsvDelay: resCtx.remoteCsvDelay, }, - CsvDelay: resCtx.remoteCsvDelay, MultiSigKey: keychain.KeyDescriptor{ PubKey: copyPubKey(msg.FundingKey), }, diff --git a/htlcswitch/test_utils.go b/htlcswitch/test_utils.go index ab15aa8b..f2e44a73 100644 --- a/htlcswitch/test_utils.go +++ b/htlcswitch/test_utils.go @@ -169,6 +169,7 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte, ChanReserve: aliceReserve, MinHTLC: 0, MaxAcceptedHtlcs: lnwallet.MaxHTLCNumber / 2, + CsvDelay: uint16(csvTimeoutAlice), } bobConstraints := &channeldb.ChannelConstraints{ @@ -178,6 +179,7 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte, ChanReserve: bobReserve, MinHTLC: 0, MaxAcceptedHtlcs: lnwallet.MaxHTLCNumber / 2, + CsvDelay: uint16(csvTimeoutBob), } var hash [sha256.Size]byte @@ -195,7 +197,6 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte, aliceCfg := channeldb.ChannelConfig{ ChannelConstraints: *aliceConstraints, - CsvDelay: uint16(csvTimeoutAlice), MultiSigKey: keychain.KeyDescriptor{ PubKey: aliceKeyPub, }, @@ -214,7 +215,6 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte, } bobCfg := channeldb.ChannelConfig{ ChannelConstraints: *bobConstraints, - CsvDelay: uint16(csvTimeoutBob), MultiSigKey: keychain.KeyDescriptor{ PubKey: bobKeyPub, }, diff --git a/lnwallet/test_utils.go b/lnwallet/test_utils.go index db2cbb10..ca275d3d 100644 --- a/lnwallet/test_utils.go +++ b/lnwallet/test_utils.go @@ -144,8 +144,8 @@ func CreateTestChannels() (*LightningChannel, *LightningChannel, func(), error) ChanReserve: channelCapacity / 100, MinHTLC: 0, MaxAcceptedHtlcs: MaxHTLCNumber / 2, + CsvDelay: uint16(csvTimeoutAlice), }, - CsvDelay: uint16(csvTimeoutAlice), MultiSigKey: keychain.KeyDescriptor{ PubKey: aliceKeys[0].PubKey(), }, @@ -169,8 +169,8 @@ func CreateTestChannels() (*LightningChannel, *LightningChannel, func(), error) ChanReserve: channelCapacity / 100, MinHTLC: 0, MaxAcceptedHtlcs: MaxHTLCNumber / 2, + CsvDelay: uint16(csvTimeoutBob), }, - CsvDelay: uint16(csvTimeoutBob), MultiSigKey: keychain.KeyDescriptor{ PubKey: bobKeys[0].PubKey(), }, diff --git a/lnwallet/transactions_test.go b/lnwallet/transactions_test.go index c3b50b04..2960b4d1 100644 --- a/lnwallet/transactions_test.go +++ b/lnwallet/transactions_test.go @@ -379,8 +379,8 @@ func TestCommitmentAndHTLCTransactions(t *testing.T) { DustLimit: tc.dustLimit, MaxPendingAmount: lnwire.NewMSatFromSatoshis(tc.fundingAmount), MaxAcceptedHtlcs: MaxHTLCNumber, + CsvDelay: tc.localCsvDelay, }, - CsvDelay: tc.localCsvDelay, MultiSigKey: keychain.KeyDescriptor{ PubKey: tc.localFundingPubKey, }, diff --git a/test_utils.go b/test_utils.go index eb6b3dc2..e9ae411c 100644 --- a/test_utils.go +++ b/test_utils.go @@ -117,8 +117,8 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, ChanReserve: btcutil.Amount(rand.Int63()), MinHTLC: lnwire.MilliSatoshi(rand.Int63()), MaxAcceptedHtlcs: uint16(rand.Int31()), + CsvDelay: uint16(csvTimeoutAlice), }, - CsvDelay: uint16(csvTimeoutAlice), MultiSigKey: keychain.KeyDescriptor{ PubKey: aliceKeyPub, }, @@ -142,8 +142,8 @@ func createTestPeer(notifier chainntnfs.ChainNotifier, ChanReserve: btcutil.Amount(rand.Int63()), MinHTLC: lnwire.MilliSatoshi(rand.Int63()), MaxAcceptedHtlcs: uint16(rand.Int31()), + CsvDelay: uint16(csvTimeoutBob), }, - CsvDelay: uint16(csvTimeoutBob), MultiSigKey: keychain.KeyDescriptor{ PubKey: bobKeyPub, },