multi: move CsvDelay into ChannelConstraints

This commit is contained in:
Wilmer Paulino 2018-12-10 13:56:41 -08:00
parent 5be8f08b16
commit b951f06456
No known key found for this signature in database
GPG Key ID: 6DF57B9F9514972F
8 changed files with 20 additions and 20 deletions

@ -1391,8 +1391,8 @@ func createInitChannels(revocationWindow int) (*lnwallet.LightningChannel, *lnwa
ChanReserve: 0, ChanReserve: 0,
MinHTLC: 0, MinHTLC: 0,
MaxAcceptedHtlcs: uint16(rand.Int31()), MaxAcceptedHtlcs: uint16(rand.Int31()),
CsvDelay: uint16(csvTimeoutAlice),
}, },
CsvDelay: uint16(csvTimeoutAlice),
MultiSigKey: keychain.KeyDescriptor{ MultiSigKey: keychain.KeyDescriptor{
PubKey: aliceKeyPub, PubKey: aliceKeyPub,
}, },
@ -1416,8 +1416,8 @@ func createInitChannels(revocationWindow int) (*lnwallet.LightningChannel, *lnwa
ChanReserve: 0, ChanReserve: 0,
MinHTLC: 0, MinHTLC: 0,
MaxAcceptedHtlcs: uint16(rand.Int31()), MaxAcceptedHtlcs: uint16(rand.Int31()),
CsvDelay: uint16(csvTimeoutBob),
}, },
CsvDelay: uint16(csvTimeoutBob),
MultiSigKey: keychain.KeyDescriptor{ MultiSigKey: keychain.KeyDescriptor{
PubKey: bobKeyPub, PubKey: bobKeyPub,
}, },

@ -161,6 +161,13 @@ type ChannelConstraints struct {
// acted upon in the case of a unilateral channel closure or a contract // acted upon in the case of a unilateral channel closure or a contract
// breach. // breach.
MaxAcceptedHtlcs uint16 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 // ChannelConfig is a struct that houses the various configuration opens for
@ -176,13 +183,6 @@ type ChannelConfig struct {
// by a participant. // by a participant.
ChannelConstraints 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 // MultiSigKey is the key to be used within the 2-of-2 output script
// for the owner of this channel config. // for the owner of this channel config.
MultiSigKey keychain.KeyDescriptor MultiSigKey keychain.KeyDescriptor

@ -136,8 +136,8 @@ func createTestChannelState(cdb *DB) (*OpenChannel, error) {
ChanReserve: btcutil.Amount(rand.Int63()), ChanReserve: btcutil.Amount(rand.Int63()),
MinHTLC: lnwire.MilliSatoshi(rand.Int63()), MinHTLC: lnwire.MilliSatoshi(rand.Int63()),
MaxAcceptedHtlcs: uint16(rand.Int31()), MaxAcceptedHtlcs: uint16(rand.Int31()),
CsvDelay: uint16(rand.Int31()),
}, },
CsvDelay: uint16(rand.Int31()),
MultiSigKey: keychain.KeyDescriptor{ MultiSigKey: keychain.KeyDescriptor{
PubKey: privKey.PubKey(), PubKey: privKey.PubKey(),
}, },
@ -161,8 +161,8 @@ func createTestChannelState(cdb *DB) (*OpenChannel, error) {
ChanReserve: btcutil.Amount(rand.Int63()), ChanReserve: btcutil.Amount(rand.Int63()),
MinHTLC: lnwire.MilliSatoshi(rand.Int63()), MinHTLC: lnwire.MilliSatoshi(rand.Int63()),
MaxAcceptedHtlcs: uint16(rand.Int31()), MaxAcceptedHtlcs: uint16(rand.Int31()),
CsvDelay: uint16(rand.Int31()),
}, },
CsvDelay: uint16(rand.Int31()),
MultiSigKey: keychain.KeyDescriptor{ MultiSigKey: keychain.KeyDescriptor{
PubKey: privKey.PubKey(), PubKey: privKey.PubKey(),
KeyLocator: keychain.KeyLocator{ KeyLocator: keychain.KeyLocator{

@ -1136,8 +1136,8 @@ func (f *fundingManager) handleFundingOpen(fmsg *fundingOpenMsg) {
ChanReserve: chanReserve, ChanReserve: chanReserve,
MinHTLC: minHtlc, MinHTLC: minHtlc,
MaxAcceptedHtlcs: maxHtlcs, MaxAcceptedHtlcs: maxHtlcs,
CsvDelay: remoteCsvDelay,
}, },
CsvDelay: remoteCsvDelay,
MultiSigKey: keychain.KeyDescriptor{ MultiSigKey: keychain.KeyDescriptor{
PubKey: copyPubKey(msg.FundingKey), PubKey: copyPubKey(msg.FundingKey),
}, },
@ -1259,8 +1259,8 @@ func (f *fundingManager) handleFundingAccept(fmsg *fundingAcceptMsg) {
ChanReserve: chanReserve, ChanReserve: chanReserve,
MinHTLC: resCtx.remoteMinHtlc, MinHTLC: resCtx.remoteMinHtlc,
MaxAcceptedHtlcs: maxHtlcs, MaxAcceptedHtlcs: maxHtlcs,
CsvDelay: resCtx.remoteCsvDelay,
}, },
CsvDelay: resCtx.remoteCsvDelay,
MultiSigKey: keychain.KeyDescriptor{ MultiSigKey: keychain.KeyDescriptor{
PubKey: copyPubKey(msg.FundingKey), PubKey: copyPubKey(msg.FundingKey),
}, },

@ -169,6 +169,7 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
ChanReserve: aliceReserve, ChanReserve: aliceReserve,
MinHTLC: 0, MinHTLC: 0,
MaxAcceptedHtlcs: lnwallet.MaxHTLCNumber / 2, MaxAcceptedHtlcs: lnwallet.MaxHTLCNumber / 2,
CsvDelay: uint16(csvTimeoutAlice),
} }
bobConstraints := &channeldb.ChannelConstraints{ bobConstraints := &channeldb.ChannelConstraints{
@ -178,6 +179,7 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
ChanReserve: bobReserve, ChanReserve: bobReserve,
MinHTLC: 0, MinHTLC: 0,
MaxAcceptedHtlcs: lnwallet.MaxHTLCNumber / 2, MaxAcceptedHtlcs: lnwallet.MaxHTLCNumber / 2,
CsvDelay: uint16(csvTimeoutBob),
} }
var hash [sha256.Size]byte var hash [sha256.Size]byte
@ -195,7 +197,6 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
aliceCfg := channeldb.ChannelConfig{ aliceCfg := channeldb.ChannelConfig{
ChannelConstraints: *aliceConstraints, ChannelConstraints: *aliceConstraints,
CsvDelay: uint16(csvTimeoutAlice),
MultiSigKey: keychain.KeyDescriptor{ MultiSigKey: keychain.KeyDescriptor{
PubKey: aliceKeyPub, PubKey: aliceKeyPub,
}, },
@ -214,7 +215,6 @@ func createTestChannel(alicePrivKey, bobPrivKey []byte,
} }
bobCfg := channeldb.ChannelConfig{ bobCfg := channeldb.ChannelConfig{
ChannelConstraints: *bobConstraints, ChannelConstraints: *bobConstraints,
CsvDelay: uint16(csvTimeoutBob),
MultiSigKey: keychain.KeyDescriptor{ MultiSigKey: keychain.KeyDescriptor{
PubKey: bobKeyPub, PubKey: bobKeyPub,
}, },

@ -144,8 +144,8 @@ func CreateTestChannels() (*LightningChannel, *LightningChannel, func(), error)
ChanReserve: channelCapacity / 100, ChanReserve: channelCapacity / 100,
MinHTLC: 0, MinHTLC: 0,
MaxAcceptedHtlcs: MaxHTLCNumber / 2, MaxAcceptedHtlcs: MaxHTLCNumber / 2,
CsvDelay: uint16(csvTimeoutAlice),
}, },
CsvDelay: uint16(csvTimeoutAlice),
MultiSigKey: keychain.KeyDescriptor{ MultiSigKey: keychain.KeyDescriptor{
PubKey: aliceKeys[0].PubKey(), PubKey: aliceKeys[0].PubKey(),
}, },
@ -169,8 +169,8 @@ func CreateTestChannels() (*LightningChannel, *LightningChannel, func(), error)
ChanReserve: channelCapacity / 100, ChanReserve: channelCapacity / 100,
MinHTLC: 0, MinHTLC: 0,
MaxAcceptedHtlcs: MaxHTLCNumber / 2, MaxAcceptedHtlcs: MaxHTLCNumber / 2,
CsvDelay: uint16(csvTimeoutBob),
}, },
CsvDelay: uint16(csvTimeoutBob),
MultiSigKey: keychain.KeyDescriptor{ MultiSigKey: keychain.KeyDescriptor{
PubKey: bobKeys[0].PubKey(), PubKey: bobKeys[0].PubKey(),
}, },

@ -379,8 +379,8 @@ func TestCommitmentAndHTLCTransactions(t *testing.T) {
DustLimit: tc.dustLimit, DustLimit: tc.dustLimit,
MaxPendingAmount: lnwire.NewMSatFromSatoshis(tc.fundingAmount), MaxPendingAmount: lnwire.NewMSatFromSatoshis(tc.fundingAmount),
MaxAcceptedHtlcs: MaxHTLCNumber, MaxAcceptedHtlcs: MaxHTLCNumber,
CsvDelay: tc.localCsvDelay,
}, },
CsvDelay: tc.localCsvDelay,
MultiSigKey: keychain.KeyDescriptor{ MultiSigKey: keychain.KeyDescriptor{
PubKey: tc.localFundingPubKey, PubKey: tc.localFundingPubKey,
}, },

@ -117,8 +117,8 @@ func createTestPeer(notifier chainntnfs.ChainNotifier,
ChanReserve: btcutil.Amount(rand.Int63()), ChanReserve: btcutil.Amount(rand.Int63()),
MinHTLC: lnwire.MilliSatoshi(rand.Int63()), MinHTLC: lnwire.MilliSatoshi(rand.Int63()),
MaxAcceptedHtlcs: uint16(rand.Int31()), MaxAcceptedHtlcs: uint16(rand.Int31()),
CsvDelay: uint16(csvTimeoutAlice),
}, },
CsvDelay: uint16(csvTimeoutAlice),
MultiSigKey: keychain.KeyDescriptor{ MultiSigKey: keychain.KeyDescriptor{
PubKey: aliceKeyPub, PubKey: aliceKeyPub,
}, },
@ -142,8 +142,8 @@ func createTestPeer(notifier chainntnfs.ChainNotifier,
ChanReserve: btcutil.Amount(rand.Int63()), ChanReserve: btcutil.Amount(rand.Int63()),
MinHTLC: lnwire.MilliSatoshi(rand.Int63()), MinHTLC: lnwire.MilliSatoshi(rand.Int63()),
MaxAcceptedHtlcs: uint16(rand.Int31()), MaxAcceptedHtlcs: uint16(rand.Int31()),
CsvDelay: uint16(csvTimeoutBob),
}, },
CsvDelay: uint16(csvTimeoutBob),
MultiSigKey: keychain.KeyDescriptor{ MultiSigKey: keychain.KeyDescriptor{
PubKey: bobKeyPub, PubKey: bobKeyPub,
}, },