Merge pull request #8953 from ProofOfKeags/refactor/lnwallet-channel-channel-constraints-partition
[MICRO]: multi: break ChannelConstraints into two sub-structures
This commit is contained in:
15 files changed
+338
-242
No files matched your search
+62
-57
@@ -126,6 +126,64 @@ func genRandomOpenChannelShell() (*channeldb.OpenChannel, error) {
|
|||||||
|
|
||||||
chanType := channeldb.ChannelType(rand.Intn(8))
|
chanType := channeldb.ChannelType(rand.Intn(8))
|
||||||
|
|
||||||
|
localCfg := channeldb.ChannelConfig{
|
||||||
|
ChannelStateBounds: channeldb.ChannelStateBounds{},
|
||||||
|
CommitmentParams: channeldb.CommitmentParams{
|
||||||
|
CsvDelay: uint16(rand.Int63()),
|
||||||
|
},
|
||||||
|
MultiSigKey: keychain.KeyDescriptor{
|
||||||
|
KeyLocator: keychain.KeyLocator{
|
||||||
|
Family: keychain.KeyFamily(rand.Int63()),
|
||||||
|
Index: uint32(rand.Int63()),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
RevocationBasePoint: keychain.KeyDescriptor{
|
||||||
|
KeyLocator: keychain.KeyLocator{
|
||||||
|
Family: keychain.KeyFamily(rand.Int63()),
|
||||||
|
Index: uint32(rand.Int63()),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
PaymentBasePoint: keychain.KeyDescriptor{
|
||||||
|
KeyLocator: keychain.KeyLocator{
|
||||||
|
Family: keychain.KeyFamily(rand.Int63()),
|
||||||
|
Index: uint32(rand.Int63()),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
DelayBasePoint: keychain.KeyDescriptor{
|
||||||
|
KeyLocator: keychain.KeyLocator{
|
||||||
|
Family: keychain.KeyFamily(rand.Int63()),
|
||||||
|
Index: uint32(rand.Int63()),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
HtlcBasePoint: keychain.KeyDescriptor{
|
||||||
|
KeyLocator: keychain.KeyLocator{
|
||||||
|
Family: keychain.KeyFamily(rand.Int63()),
|
||||||
|
Index: uint32(rand.Int63()),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
remoteCfg := channeldb.ChannelConfig{
|
||||||
|
CommitmentParams: channeldb.CommitmentParams{
|
||||||
|
CsvDelay: uint16(rand.Int63()),
|
||||||
|
},
|
||||||
|
MultiSigKey: keychain.KeyDescriptor{
|
||||||
|
PubKey: pub,
|
||||||
|
},
|
||||||
|
RevocationBasePoint: keychain.KeyDescriptor{
|
||||||
|
PubKey: pub,
|
||||||
|
},
|
||||||
|
PaymentBasePoint: keychain.KeyDescriptor{
|
||||||
|
PubKey: pub,
|
||||||
|
},
|
||||||
|
DelayBasePoint: keychain.KeyDescriptor{
|
||||||
|
PubKey: pub,
|
||||||
|
},
|
||||||
|
HtlcBasePoint: keychain.KeyDescriptor{
|
||||||
|
PubKey: pub,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
return &channeldb.OpenChannel{
|
return &channeldb.OpenChannel{
|
||||||
ChainHash: chainHash,
|
ChainHash: chainHash,
|
||||||
ChanType: chanType,
|
ChanType: chanType,
|
||||||
@@ -134,63 +192,10 @@ func genRandomOpenChannelShell() (*channeldb.OpenChannel, error) {
|
|||||||
ShortChannelID: lnwire.NewShortChanIDFromInt(
|
ShortChannelID: lnwire.NewShortChanIDFromInt(
|
||||||
uint64(rand.Int63()),
|
uint64(rand.Int63()),
|
||||||
),
|
),
|
||||||
ThawHeight: rand.Uint32(),
|
ThawHeight: rand.Uint32(),
|
||||||
IdentityPub: pub,
|
IdentityPub: pub,
|
||||||
LocalChanCfg: channeldb.ChannelConfig{
|
LocalChanCfg: localCfg,
|
||||||
ChannelConstraints: channeldb.ChannelConstraints{
|
RemoteChanCfg: remoteCfg,
|
||||||
CsvDelay: uint16(rand.Int63()),
|
|
||||||
},
|
|
||||||
MultiSigKey: keychain.KeyDescriptor{
|
|
||||||
KeyLocator: keychain.KeyLocator{
|
|
||||||
Family: keychain.KeyFamily(rand.Int63()),
|
|
||||||
Index: uint32(rand.Int63()),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
RevocationBasePoint: keychain.KeyDescriptor{
|
|
||||||
KeyLocator: keychain.KeyLocator{
|
|
||||||
Family: keychain.KeyFamily(rand.Int63()),
|
|
||||||
Index: uint32(rand.Int63()),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
PaymentBasePoint: keychain.KeyDescriptor{
|
|
||||||
KeyLocator: keychain.KeyLocator{
|
|
||||||
Family: keychain.KeyFamily(rand.Int63()),
|
|
||||||
Index: uint32(rand.Int63()),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
DelayBasePoint: keychain.KeyDescriptor{
|
|
||||||
KeyLocator: keychain.KeyLocator{
|
|
||||||
Family: keychain.KeyFamily(rand.Int63()),
|
|
||||||
Index: uint32(rand.Int63()),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
HtlcBasePoint: keychain.KeyDescriptor{
|
|
||||||
KeyLocator: keychain.KeyLocator{
|
|
||||||
Family: keychain.KeyFamily(rand.Int63()),
|
|
||||||
Index: uint32(rand.Int63()),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
RemoteChanCfg: channeldb.ChannelConfig{
|
|
||||||
ChannelConstraints: channeldb.ChannelConstraints{
|
|
||||||
CsvDelay: uint16(rand.Int63()),
|
|
||||||
},
|
|
||||||
MultiSigKey: keychain.KeyDescriptor{
|
|
||||||
PubKey: pub,
|
|
||||||
},
|
|
||||||
RevocationBasePoint: keychain.KeyDescriptor{
|
|
||||||
PubKey: pub,
|
|
||||||
},
|
|
||||||
PaymentBasePoint: keychain.KeyDescriptor{
|
|
||||||
PubKey: pub,
|
|
||||||
},
|
|
||||||
DelayBasePoint: keychain.KeyDescriptor{
|
|
||||||
PubKey: pub,
|
|
||||||
},
|
|
||||||
HtlcBasePoint: keychain.KeyDescriptor{
|
|
||||||
PubKey: pub,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
RevocationProducer: shaChainProducer,
|
RevocationProducer: shaChainProducer,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
+26
-16
@@ -395,19 +395,11 @@ func (c ChannelType) IsTaproot() bool {
|
|||||||
return c&SimpleTaprootFeatureBit == SimpleTaprootFeatureBit
|
return c&SimpleTaprootFeatureBit == SimpleTaprootFeatureBit
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChannelConstraints represents a set of constraints meant to allow a node to
|
// ChannelStateBounds are the parameters from OpenChannel and AcceptChannel
|
||||||
// limit their exposure, enact flow control and ensure that all HTLCs are
|
// that are responsible for providing bounds on the state space of the abstract
|
||||||
// economically relevant. This struct will be mirrored for both sides of the
|
// channel state. These values must be remembered for normal channel operation
|
||||||
// channel, as each side will enforce various constraints that MUST be adhered
|
// but they do not impact how we compute the commitment transactions themselves.
|
||||||
// to for the life time of the channel. The parameters for each of these
|
type ChannelStateBounds struct {
|
||||||
// constraints are static for the duration of the channel, meaning the channel
|
|
||||||
// must be torn down for them to change.
|
|
||||||
type ChannelConstraints struct {
|
|
||||||
// DustLimit is the threshold (in satoshis) below which any outputs
|
|
||||||
// should be trimmed. When an output is trimmed, it isn't materialized
|
|
||||||
// as an actual output, but is instead burned to miner's fees.
|
|
||||||
DustLimit btcutil.Amount
|
|
||||||
|
|
||||||
// ChanReserve is an absolute reservation on the channel for the
|
// ChanReserve is an absolute reservation on the channel for the
|
||||||
// owner of this set of constraints. This means that the current
|
// owner of this set of constraints. This means that the current
|
||||||
// settled balance for this node CANNOT dip below the reservation
|
// settled balance for this node CANNOT dip below the reservation
|
||||||
@@ -433,6 +425,19 @@ 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// CommitmentParams are the parameters from OpenChannel and
|
||||||
|
// AcceptChannel that are required to render an abstract channel state to a
|
||||||
|
// concrete commitment transaction. These values are necessary to (re)compute
|
||||||
|
// the commitment transaction. We treat these differently than the state space
|
||||||
|
// bounds because their history needs to be stored in order to properly handle
|
||||||
|
// chain resolution.
|
||||||
|
type CommitmentParams struct {
|
||||||
|
// DustLimit is the threshold (in satoshis) below which any outputs
|
||||||
|
// should be trimmed. When an output is trimmed, it isn't materialized
|
||||||
|
// as an actual output, but is instead burned to miner's fees.
|
||||||
|
DustLimit btcutil.Amount
|
||||||
|
|
||||||
// CsvDelay is the relative time lock delay expressed in blocks. Any
|
// CsvDelay is the relative time lock delay expressed in blocks. Any
|
||||||
// settled outputs that pay to the owner of this channel configuration
|
// settled outputs that pay to the owner of this channel configuration
|
||||||
@@ -448,12 +453,17 @@ type ChannelConstraints struct {
|
|||||||
// nature of HTLC's allotted, the keys to be used for delivery, and relative
|
// nature of HTLC's allotted, the keys to be used for delivery, and relative
|
||||||
// time lock parameters.
|
// time lock parameters.
|
||||||
type ChannelConfig struct {
|
type ChannelConfig struct {
|
||||||
// ChannelConstraints is the set of constraints that must be upheld for
|
// ChannelStateBounds is the set of constraints that must be
|
||||||
// the duration of the channel for the owner of this channel
|
// upheld for the duration of the channel for the owner of this channel
|
||||||
// configuration. Constraints govern a number of flow control related
|
// configuration. Constraints govern a number of flow control related
|
||||||
// parameters, also including the smallest HTLC that will be accepted
|
// parameters, also including the smallest HTLC that will be accepted
|
||||||
// by a participant.
|
// by a participant.
|
||||||
ChannelConstraints
|
ChannelStateBounds
|
||||||
|
|
||||||
|
// CommitmentParams is an embedding of the parameters
|
||||||
|
// required to render an abstract channel state into a concrete
|
||||||
|
// commitment transaction.
|
||||||
|
CommitmentParams
|
||||||
|
|
||||||
// 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.
|
||||||
|
|||||||
+29
-16
@@ -235,15 +235,21 @@ func createTestChannelState(t *testing.T, cdb *ChannelStateDB) *OpenChannel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
localStateBounds := ChannelStateBounds{
|
||||||
|
MaxPendingAmount: lnwire.MilliSatoshi(rand.Int63()),
|
||||||
|
ChanReserve: btcutil.Amount(rand.Int63()),
|
||||||
|
MinHTLC: lnwire.MilliSatoshi(rand.Int63()),
|
||||||
|
MaxAcceptedHtlcs: uint16(rand.Int31()),
|
||||||
|
}
|
||||||
|
|
||||||
|
localRenderingParams := CommitmentParams{
|
||||||
|
DustLimit: btcutil.Amount(rand.Int63()),
|
||||||
|
CsvDelay: uint16(rand.Int31()),
|
||||||
|
}
|
||||||
|
|
||||||
localCfg := ChannelConfig{
|
localCfg := ChannelConfig{
|
||||||
ChannelConstraints: ChannelConstraints{
|
ChannelStateBounds: localStateBounds,
|
||||||
DustLimit: btcutil.Amount(rand.Int63()),
|
CommitmentParams: localRenderingParams,
|
||||||
MaxPendingAmount: lnwire.MilliSatoshi(rand.Int63()),
|
|
||||||
ChanReserve: btcutil.Amount(rand.Int63()),
|
|
||||||
MinHTLC: lnwire.MilliSatoshi(rand.Int63()),
|
|
||||||
MaxAcceptedHtlcs: uint16(rand.Int31()),
|
|
||||||
CsvDelay: uint16(rand.Int31()),
|
|
||||||
},
|
|
||||||
MultiSigKey: keychain.KeyDescriptor{
|
MultiSigKey: keychain.KeyDescriptor{
|
||||||
PubKey: privKey.PubKey(),
|
PubKey: privKey.PubKey(),
|
||||||
},
|
},
|
||||||
@@ -260,15 +266,22 @@ func createTestChannelState(t *testing.T, cdb *ChannelStateDB) *OpenChannel {
|
|||||||
PubKey: privKey.PubKey(),
|
PubKey: privKey.PubKey(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remoteStateBounds := ChannelStateBounds{
|
||||||
|
MaxPendingAmount: lnwire.MilliSatoshi(rand.Int63()),
|
||||||
|
ChanReserve: btcutil.Amount(rand.Int63()),
|
||||||
|
MinHTLC: lnwire.MilliSatoshi(rand.Int63()),
|
||||||
|
MaxAcceptedHtlcs: uint16(rand.Int31()),
|
||||||
|
}
|
||||||
|
|
||||||
|
remoteRenderingParams := CommitmentParams{
|
||||||
|
DustLimit: btcutil.Amount(rand.Int63()),
|
||||||
|
CsvDelay: uint16(rand.Int31()),
|
||||||
|
}
|
||||||
|
|
||||||
remoteCfg := ChannelConfig{
|
remoteCfg := ChannelConfig{
|
||||||
ChannelConstraints: ChannelConstraints{
|
ChannelStateBounds: remoteStateBounds,
|
||||||
DustLimit: btcutil.Amount(rand.Int63()),
|
CommitmentParams: remoteRenderingParams,
|
||||||
MaxPendingAmount: lnwire.MilliSatoshi(rand.Int63()),
|
|
||||||
ChanReserve: btcutil.Amount(rand.Int63()),
|
|
||||||
MinHTLC: lnwire.MilliSatoshi(rand.Int63()),
|
|
||||||
MaxAcceptedHtlcs: 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{
|
||||||
|
|||||||
@@ -292,6 +292,10 @@ func genRandomChannelShell() (*ChannelShell, error) {
|
|||||||
}
|
}
|
||||||
shaChainProducer := shachain.NewRevocationProducer(*revRoot)
|
shaChainProducer := shachain.NewRevocationProducer(*revRoot)
|
||||||
|
|
||||||
|
commitParams := CommitmentParams{
|
||||||
|
CsvDelay: uint16(rand.Int63()),
|
||||||
|
}
|
||||||
|
|
||||||
return &ChannelShell{
|
return &ChannelShell{
|
||||||
NodeAddrs: []net.Addr{&net.TCPAddr{
|
NodeAddrs: []net.Addr{&net.TCPAddr{
|
||||||
IP: net.ParseIP("127.0.0.1"),
|
IP: net.ParseIP("127.0.0.1"),
|
||||||
@@ -306,9 +310,7 @@ func genRandomChannelShell() (*ChannelShell, error) {
|
|||||||
),
|
),
|
||||||
IdentityPub: pub,
|
IdentityPub: pub,
|
||||||
LocalChanCfg: ChannelConfig{
|
LocalChanCfg: ChannelConfig{
|
||||||
ChannelConstraints: ChannelConstraints{
|
CommitmentParams: commitParams,
|
||||||
CsvDelay: uint16(rand.Int63()),
|
|
||||||
},
|
|
||||||
PaymentBasePoint: keychain.KeyDescriptor{
|
PaymentBasePoint: keychain.KeyDescriptor{
|
||||||
KeyLocator: keychain.KeyLocator{
|
KeyLocator: keychain.KeyLocator{
|
||||||
Family: keychain.KeyFamily(rand.Int63()),
|
Family: keychain.KeyFamily(rand.Int63()),
|
||||||
|
|||||||
@@ -2178,13 +2178,15 @@ func createInitChannels(t *testing.T) (
|
|||||||
fundingTxIn := wire.NewTxIn(prevOut, nil, nil)
|
fundingTxIn := wire.NewTxIn(prevOut, nil, nil)
|
||||||
|
|
||||||
aliceCfg := channeldb.ChannelConfig{
|
aliceCfg := channeldb.ChannelConfig{
|
||||||
ChannelConstraints: channeldb.ChannelConstraints{
|
ChannelStateBounds: channeldb.ChannelStateBounds{
|
||||||
DustLimit: aliceDustLimit,
|
|
||||||
MaxPendingAmount: lnwire.MilliSatoshi(rand.Int63()),
|
MaxPendingAmount: lnwire.MilliSatoshi(rand.Int63()),
|
||||||
ChanReserve: 0,
|
ChanReserve: 0,
|
||||||
MinHTLC: 0,
|
MinHTLC: 0,
|
||||||
MaxAcceptedHtlcs: uint16(rand.Int31()),
|
MaxAcceptedHtlcs: uint16(rand.Int31()),
|
||||||
CsvDelay: uint16(csvTimeoutAlice),
|
},
|
||||||
|
CommitmentParams: channeldb.CommitmentParams{
|
||||||
|
DustLimit: aliceDustLimit,
|
||||||
|
CsvDelay: uint16(csvTimeoutAlice),
|
||||||
},
|
},
|
||||||
MultiSigKey: keychain.KeyDescriptor{
|
MultiSigKey: keychain.KeyDescriptor{
|
||||||
PubKey: aliceKeyPub,
|
PubKey: aliceKeyPub,
|
||||||
@@ -2203,13 +2205,15 @@ func createInitChannels(t *testing.T) (
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
bobCfg := channeldb.ChannelConfig{
|
bobCfg := channeldb.ChannelConfig{
|
||||||
ChannelConstraints: channeldb.ChannelConstraints{
|
ChannelStateBounds: channeldb.ChannelStateBounds{
|
||||||
DustLimit: bobDustLimit,
|
|
||||||
MaxPendingAmount: lnwire.MilliSatoshi(rand.Int63()),
|
MaxPendingAmount: lnwire.MilliSatoshi(rand.Int63()),
|
||||||
ChanReserve: 0,
|
ChanReserve: 0,
|
||||||
MinHTLC: 0,
|
MinHTLC: 0,
|
||||||
MaxAcceptedHtlcs: uint16(rand.Int31()),
|
MaxAcceptedHtlcs: uint16(rand.Int31()),
|
||||||
CsvDelay: uint16(csvTimeoutBob),
|
},
|
||||||
|
CommitmentParams: channeldb.CommitmentParams{
|
||||||
|
DustLimit: bobDustLimit,
|
||||||
|
CsvDelay: uint16(csvTimeoutBob),
|
||||||
},
|
},
|
||||||
MultiSigKey: keychain.KeyDescriptor{
|
MultiSigKey: keychain.KeyDescriptor{
|
||||||
PubKey: bobKeyPub,
|
PubKey: bobKeyPub,
|
||||||
|
|||||||
+96
-74
@@ -1671,16 +1671,18 @@ func (f *Manager) fundeeProcessOpenChannel(peer lnpeer.Peer,
|
|||||||
|
|
||||||
// We'll also validate and apply all the constraints the initiating
|
// We'll also validate and apply all the constraints the initiating
|
||||||
// party is attempting to dictate for our commitment transaction.
|
// party is attempting to dictate for our commitment transaction.
|
||||||
channelConstraints := &channeldb.ChannelConstraints{
|
stateBounds := &channeldb.ChannelStateBounds{
|
||||||
DustLimit: msg.DustLimit,
|
|
||||||
ChanReserve: msg.ChannelReserve,
|
ChanReserve: msg.ChannelReserve,
|
||||||
MaxPendingAmount: msg.MaxValueInFlight,
|
MaxPendingAmount: msg.MaxValueInFlight,
|
||||||
MinHTLC: msg.HtlcMinimum,
|
MinHTLC: msg.HtlcMinimum,
|
||||||
MaxAcceptedHtlcs: msg.MaxAcceptedHTLCs,
|
MaxAcceptedHtlcs: msg.MaxAcceptedHTLCs,
|
||||||
CsvDelay: msg.CsvDelay,
|
}
|
||||||
|
commitParams := &channeldb.CommitmentParams{
|
||||||
|
DustLimit: msg.DustLimit,
|
||||||
|
CsvDelay: msg.CsvDelay,
|
||||||
}
|
}
|
||||||
err = reservation.CommitConstraints(
|
err = reservation.CommitConstraints(
|
||||||
channelConstraints, f.cfg.MaxLocalCSVDelay, true,
|
stateBounds, commitParams, f.cfg.MaxLocalCSVDelay, true,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Unacceptable channel constraints: %v", err)
|
log.Errorf("Unacceptable channel constraints: %v", err)
|
||||||
@@ -1780,7 +1782,7 @@ func (f *Manager) fundeeProcessOpenChannel(peer lnpeer.Peer,
|
|||||||
// interactively.
|
// interactively.
|
||||||
ourContribution := reservation.OurContribution()
|
ourContribution := reservation.OurContribution()
|
||||||
forwardingPolicy := f.defaultForwardingPolicy(
|
forwardingPolicy := f.defaultForwardingPolicy(
|
||||||
ourContribution.ChannelConstraints,
|
ourContribution.ChannelStateBounds,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Once the reservation has been created successfully, we add it to
|
// Once the reservation has been created successfully, we add it to
|
||||||
@@ -1810,37 +1812,41 @@ func (f *Manager) fundeeProcessOpenChannel(peer lnpeer.Peer,
|
|||||||
// Update the timestamp once the fundingOpenMsg has been handled.
|
// Update the timestamp once the fundingOpenMsg has been handled.
|
||||||
defer resCtx.updateTimestamp()
|
defer resCtx.updateTimestamp()
|
||||||
|
|
||||||
|
cfg := channeldb.ChannelConfig{
|
||||||
|
ChannelStateBounds: channeldb.ChannelStateBounds{
|
||||||
|
MaxPendingAmount: remoteMaxValue,
|
||||||
|
ChanReserve: chanReserve,
|
||||||
|
MinHTLC: minHtlc,
|
||||||
|
MaxAcceptedHtlcs: maxHtlcs,
|
||||||
|
},
|
||||||
|
CommitmentParams: channeldb.CommitmentParams{
|
||||||
|
DustLimit: msg.DustLimit,
|
||||||
|
CsvDelay: remoteCsvDelay,
|
||||||
|
},
|
||||||
|
MultiSigKey: keychain.KeyDescriptor{
|
||||||
|
PubKey: copyPubKey(msg.FundingKey),
|
||||||
|
},
|
||||||
|
RevocationBasePoint: keychain.KeyDescriptor{
|
||||||
|
PubKey: copyPubKey(msg.RevocationPoint),
|
||||||
|
},
|
||||||
|
PaymentBasePoint: keychain.KeyDescriptor{
|
||||||
|
PubKey: copyPubKey(msg.PaymentPoint),
|
||||||
|
},
|
||||||
|
DelayBasePoint: keychain.KeyDescriptor{
|
||||||
|
PubKey: copyPubKey(msg.DelayedPaymentPoint),
|
||||||
|
},
|
||||||
|
HtlcBasePoint: keychain.KeyDescriptor{
|
||||||
|
PubKey: copyPubKey(msg.HtlcPoint),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// With our parameters set, we'll now process their contribution so we
|
// With our parameters set, we'll now process their contribution so we
|
||||||
// can move the funding workflow ahead.
|
// can move the funding workflow ahead.
|
||||||
remoteContribution := &lnwallet.ChannelContribution{
|
remoteContribution := &lnwallet.ChannelContribution{
|
||||||
FundingAmount: amt,
|
FundingAmount: amt,
|
||||||
FirstCommitmentPoint: msg.FirstCommitmentPoint,
|
FirstCommitmentPoint: msg.FirstCommitmentPoint,
|
||||||
ChannelConfig: &channeldb.ChannelConfig{
|
ChannelConfig: &cfg,
|
||||||
ChannelConstraints: channeldb.ChannelConstraints{
|
UpfrontShutdown: msg.UpfrontShutdownScript,
|
||||||
DustLimit: msg.DustLimit,
|
|
||||||
MaxPendingAmount: remoteMaxValue,
|
|
||||||
ChanReserve: chanReserve,
|
|
||||||
MinHTLC: minHtlc,
|
|
||||||
MaxAcceptedHtlcs: maxHtlcs,
|
|
||||||
CsvDelay: remoteCsvDelay,
|
|
||||||
},
|
|
||||||
MultiSigKey: keychain.KeyDescriptor{
|
|
||||||
PubKey: copyPubKey(msg.FundingKey),
|
|
||||||
},
|
|
||||||
RevocationBasePoint: keychain.KeyDescriptor{
|
|
||||||
PubKey: copyPubKey(msg.RevocationPoint),
|
|
||||||
},
|
|
||||||
PaymentBasePoint: keychain.KeyDescriptor{
|
|
||||||
PubKey: copyPubKey(msg.PaymentPoint),
|
|
||||||
},
|
|
||||||
DelayBasePoint: keychain.KeyDescriptor{
|
|
||||||
PubKey: copyPubKey(msg.DelayedPaymentPoint),
|
|
||||||
},
|
|
||||||
HtlcBasePoint: keychain.KeyDescriptor{
|
|
||||||
PubKey: copyPubKey(msg.HtlcPoint),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UpfrontShutdown: msg.UpfrontShutdownScript,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if resCtx.reservation.IsTaproot() {
|
if resCtx.reservation.IsTaproot() {
|
||||||
@@ -1867,8 +1873,12 @@ func (f *Manager) fundeeProcessOpenChannel(peer lnpeer.Peer,
|
|||||||
|
|
||||||
log.Infof("Sending fundingResp for pending_id(%x)",
|
log.Infof("Sending fundingResp for pending_id(%x)",
|
||||||
msg.PendingChannelID)
|
msg.PendingChannelID)
|
||||||
log.Debugf("Remote party accepted commitment constraints: %v",
|
bounds := remoteContribution.ChannelConfig.ChannelStateBounds
|
||||||
spew.Sdump(remoteContribution.ChannelConfig.ChannelConstraints))
|
log.Debugf("Remote party accepted channel state space bounds: %v",
|
||||||
|
lnutils.SpewLogClosure(bounds))
|
||||||
|
params := remoteContribution.ChannelConfig.CommitmentParams
|
||||||
|
log.Debugf("Remote party accepted commitment rendering params: %v",
|
||||||
|
lnutils.SpewLogClosure(params))
|
||||||
|
|
||||||
// With the initiator's contribution recorded, respond with our
|
// With the initiator's contribution recorded, respond with our
|
||||||
// contribution in the next message of the workflow.
|
// contribution in the next message of the workflow.
|
||||||
@@ -2036,16 +2046,18 @@ func (f *Manager) funderProcessAcceptChannel(peer lnpeer.Peer,
|
|||||||
// required confirmations, and also the set of channel constraints
|
// required confirmations, and also the set of channel constraints
|
||||||
// they've specified for commitment states we can create.
|
// they've specified for commitment states we can create.
|
||||||
resCtx.reservation.SetNumConfsRequired(uint16(minDepth))
|
resCtx.reservation.SetNumConfsRequired(uint16(minDepth))
|
||||||
channelConstraints := &channeldb.ChannelConstraints{
|
bounds := channeldb.ChannelStateBounds{
|
||||||
DustLimit: msg.DustLimit,
|
|
||||||
ChanReserve: msg.ChannelReserve,
|
ChanReserve: msg.ChannelReserve,
|
||||||
MaxPendingAmount: msg.MaxValueInFlight,
|
MaxPendingAmount: msg.MaxValueInFlight,
|
||||||
MinHTLC: msg.HtlcMinimum,
|
MinHTLC: msg.HtlcMinimum,
|
||||||
MaxAcceptedHtlcs: msg.MaxAcceptedHTLCs,
|
MaxAcceptedHtlcs: msg.MaxAcceptedHTLCs,
|
||||||
CsvDelay: msg.CsvDelay,
|
}
|
||||||
|
commitParams := channeldb.CommitmentParams{
|
||||||
|
DustLimit: msg.DustLimit,
|
||||||
|
CsvDelay: msg.CsvDelay,
|
||||||
}
|
}
|
||||||
err = resCtx.reservation.CommitConstraints(
|
err = resCtx.reservation.CommitConstraints(
|
||||||
channelConstraints, resCtx.maxLocalCsv, false,
|
&bounds, &commitParams, resCtx.maxLocalCsv, false,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warnf("Unacceptable channel constraints: %v", err)
|
log.Warnf("Unacceptable channel constraints: %v", err)
|
||||||
@@ -2053,38 +2065,42 @@ func (f *Manager) funderProcessAcceptChannel(peer lnpeer.Peer,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cfg := channeldb.ChannelConfig{
|
||||||
|
ChannelStateBounds: channeldb.ChannelStateBounds{
|
||||||
|
MaxPendingAmount: resCtx.remoteMaxValue,
|
||||||
|
ChanReserve: resCtx.remoteChanReserve,
|
||||||
|
MinHTLC: resCtx.remoteMinHtlc,
|
||||||
|
MaxAcceptedHtlcs: resCtx.remoteMaxHtlcs,
|
||||||
|
},
|
||||||
|
CommitmentParams: channeldb.CommitmentParams{
|
||||||
|
DustLimit: msg.DustLimit,
|
||||||
|
CsvDelay: resCtx.remoteCsvDelay,
|
||||||
|
},
|
||||||
|
MultiSigKey: keychain.KeyDescriptor{
|
||||||
|
PubKey: copyPubKey(msg.FundingKey),
|
||||||
|
},
|
||||||
|
RevocationBasePoint: keychain.KeyDescriptor{
|
||||||
|
PubKey: copyPubKey(msg.RevocationPoint),
|
||||||
|
},
|
||||||
|
PaymentBasePoint: keychain.KeyDescriptor{
|
||||||
|
PubKey: copyPubKey(msg.PaymentPoint),
|
||||||
|
},
|
||||||
|
DelayBasePoint: keychain.KeyDescriptor{
|
||||||
|
PubKey: copyPubKey(msg.DelayedPaymentPoint),
|
||||||
|
},
|
||||||
|
HtlcBasePoint: keychain.KeyDescriptor{
|
||||||
|
PubKey: copyPubKey(msg.HtlcPoint),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// The remote node has responded with their portion of the channel
|
// The remote node has responded with their portion of the channel
|
||||||
// contribution. At this point, we can process their contribution which
|
// contribution. At this point, we can process their contribution which
|
||||||
// allows us to construct and sign both the commitment transaction, and
|
// allows us to construct and sign both the commitment transaction, and
|
||||||
// the funding transaction.
|
// the funding transaction.
|
||||||
remoteContribution := &lnwallet.ChannelContribution{
|
remoteContribution := &lnwallet.ChannelContribution{
|
||||||
FirstCommitmentPoint: msg.FirstCommitmentPoint,
|
FirstCommitmentPoint: msg.FirstCommitmentPoint,
|
||||||
ChannelConfig: &channeldb.ChannelConfig{
|
ChannelConfig: &cfg,
|
||||||
ChannelConstraints: channeldb.ChannelConstraints{
|
UpfrontShutdown: msg.UpfrontShutdownScript,
|
||||||
DustLimit: msg.DustLimit,
|
|
||||||
MaxPendingAmount: resCtx.remoteMaxValue,
|
|
||||||
ChanReserve: resCtx.remoteChanReserve,
|
|
||||||
MinHTLC: resCtx.remoteMinHtlc,
|
|
||||||
MaxAcceptedHtlcs: resCtx.remoteMaxHtlcs,
|
|
||||||
CsvDelay: resCtx.remoteCsvDelay,
|
|
||||||
},
|
|
||||||
MultiSigKey: keychain.KeyDescriptor{
|
|
||||||
PubKey: copyPubKey(msg.FundingKey),
|
|
||||||
},
|
|
||||||
RevocationBasePoint: keychain.KeyDescriptor{
|
|
||||||
PubKey: copyPubKey(msg.RevocationPoint),
|
|
||||||
},
|
|
||||||
PaymentBasePoint: keychain.KeyDescriptor{
|
|
||||||
PubKey: copyPubKey(msg.PaymentPoint),
|
|
||||||
},
|
|
||||||
DelayBasePoint: keychain.KeyDescriptor{
|
|
||||||
PubKey: copyPubKey(msg.DelayedPaymentPoint),
|
|
||||||
},
|
|
||||||
HtlcBasePoint: keychain.KeyDescriptor{
|
|
||||||
PubKey: copyPubKey(msg.HtlcPoint),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
UpfrontShutdown: msg.UpfrontShutdownScript,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if resCtx.reservation.IsTaproot() {
|
if resCtx.reservation.IsTaproot() {
|
||||||
@@ -2149,8 +2165,12 @@ func (f *Manager) funderProcessAcceptChannel(peer lnpeer.Peer,
|
|||||||
log.Infof("pendingChan(%x): remote party proposes num_confs=%v, "+
|
log.Infof("pendingChan(%x): remote party proposes num_confs=%v, "+
|
||||||
"csv_delay=%v", pendingChanID[:], msg.MinAcceptDepth,
|
"csv_delay=%v", pendingChanID[:], msg.MinAcceptDepth,
|
||||||
msg.CsvDelay)
|
msg.CsvDelay)
|
||||||
log.Debugf("Remote party accepted commitment constraints: %v",
|
bounds = remoteContribution.ChannelConfig.ChannelStateBounds
|
||||||
spew.Sdump(remoteContribution.ChannelConfig.ChannelConstraints))
|
log.Debugf("Remote party accepted channel state space bounds: %v",
|
||||||
|
lnutils.SpewLogClosure(bounds))
|
||||||
|
commitParams = remoteContribution.ChannelConfig.CommitmentParams
|
||||||
|
log.Debugf("Remote party accepted commitment rendering params: %v",
|
||||||
|
lnutils.SpewLogClosure(commitParams))
|
||||||
|
|
||||||
// If the user requested funding through a PSBT, we cannot directly
|
// If the user requested funding through a PSBT, we cannot directly
|
||||||
// continue now and need to wait for the fully funded and signed PSBT
|
// continue now and need to wait for the fully funded and signed PSBT
|
||||||
@@ -4070,7 +4090,7 @@ func (f *Manager) ensureInitialForwardingPolicy(chanID lnwire.ChannelID,
|
|||||||
"falling back to default values: %v", err)
|
"falling back to default values: %v", err)
|
||||||
|
|
||||||
forwardingPolicy = f.defaultForwardingPolicy(
|
forwardingPolicy = f.defaultForwardingPolicy(
|
||||||
channel.LocalChanCfg.ChannelConstraints,
|
channel.LocalChanCfg.ChannelStateBounds,
|
||||||
)
|
)
|
||||||
needDBUpdate = true
|
needDBUpdate = true
|
||||||
}
|
}
|
||||||
@@ -4695,7 +4715,7 @@ func (f *Manager) handleInitFundingMsg(msg *InitFundingMsg) {
|
|||||||
// useBaseFee or useFeeRate are false the client did not provide fee
|
// useBaseFee or useFeeRate are false the client did not provide fee
|
||||||
// values hence we assume default fee settings from the config.
|
// values hence we assume default fee settings from the config.
|
||||||
forwardingPolicy := f.defaultForwardingPolicy(
|
forwardingPolicy := f.defaultForwardingPolicy(
|
||||||
ourContribution.ChannelConstraints,
|
ourContribution.ChannelStateBounds,
|
||||||
)
|
)
|
||||||
if baseFee != nil {
|
if baseFee != nil {
|
||||||
forwardingPolicy.BaseFee = lnwire.MilliSatoshi(*baseFee)
|
forwardingPolicy.BaseFee = lnwire.MilliSatoshi(*baseFee)
|
||||||
@@ -4750,16 +4770,18 @@ func (f *Manager) handleInitFundingMsg(msg *InitFundingMsg) {
|
|||||||
defer resCtx.updateTimestamp()
|
defer resCtx.updateTimestamp()
|
||||||
|
|
||||||
// Check the sanity of the selected channel constraints.
|
// Check the sanity of the selected channel constraints.
|
||||||
channelConstraints := &channeldb.ChannelConstraints{
|
bounds := &channeldb.ChannelStateBounds{
|
||||||
DustLimit: ourDustLimit,
|
|
||||||
ChanReserve: chanReserve,
|
ChanReserve: chanReserve,
|
||||||
MaxPendingAmount: maxValue,
|
MaxPendingAmount: maxValue,
|
||||||
MinHTLC: minHtlcIn,
|
MinHTLC: minHtlcIn,
|
||||||
MaxAcceptedHtlcs: maxHtlcs,
|
MaxAcceptedHtlcs: maxHtlcs,
|
||||||
CsvDelay: remoteCsvDelay,
|
}
|
||||||
|
commitParams := &channeldb.CommitmentParams{
|
||||||
|
DustLimit: ourDustLimit,
|
||||||
|
CsvDelay: remoteCsvDelay,
|
||||||
}
|
}
|
||||||
err = lnwallet.VerifyConstraints(
|
err = lnwallet.VerifyConstraints(
|
||||||
channelConstraints, resCtx.maxLocalCsv, capacity,
|
bounds, commitParams, resCtx.maxLocalCsv, capacity,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_, reserveErr := f.cancelReservationCtx(peerKey, chanID, false)
|
_, reserveErr := f.cancelReservationCtx(peerKey, chanID, false)
|
||||||
@@ -5032,11 +5054,11 @@ func copyPubKey(pub *btcec.PublicKey) *btcec.PublicKey {
|
|||||||
// defaultForwardingPolicy returns the default forwarding policy based on the
|
// defaultForwardingPolicy returns the default forwarding policy based on the
|
||||||
// default routing policy and our local channel constraints.
|
// default routing policy and our local channel constraints.
|
||||||
func (f *Manager) defaultForwardingPolicy(
|
func (f *Manager) defaultForwardingPolicy(
|
||||||
constraints channeldb.ChannelConstraints) *models.ForwardingPolicy {
|
bounds channeldb.ChannelStateBounds) *models.ForwardingPolicy {
|
||||||
|
|
||||||
return &models.ForwardingPolicy{
|
return &models.ForwardingPolicy{
|
||||||
MinHTLCOut: constraints.MinHTLC,
|
MinHTLCOut: bounds.MinHTLC,
|
||||||
MaxHTLC: constraints.MaxPendingAmount,
|
MaxHTLC: bounds.MaxPendingAmount,
|
||||||
BaseFee: f.cfg.DefaultRoutingPolicy.BaseFee,
|
BaseFee: f.cfg.DefaultRoutingPolicy.BaseFee,
|
||||||
FeeRate: f.cfg.DefaultRoutingPolicy.FeeRate,
|
FeeRate: f.cfg.DefaultRoutingPolicy.FeeRate,
|
||||||
TimeLockDelta: f.cfg.DefaultRoutingPolicy.TimeLockDelta,
|
TimeLockDelta: f.cfg.DefaultRoutingPolicy.TimeLockDelta,
|
||||||
|
|||||||
@@ -138,24 +138,28 @@ func createTestChannel(t *testing.T, alicePrivKey, bobPrivKey []byte,
|
|||||||
csvTimeoutBob := uint32(4)
|
csvTimeoutBob := uint32(4)
|
||||||
isAliceInitiator := true
|
isAliceInitiator := true
|
||||||
|
|
||||||
aliceConstraints := &channeldb.ChannelConstraints{
|
aliceBounds := channeldb.ChannelStateBounds{
|
||||||
DustLimit: btcutil.Amount(200),
|
|
||||||
MaxPendingAmount: lnwire.NewMSatFromSatoshis(
|
MaxPendingAmount: lnwire.NewMSatFromSatoshis(
|
||||||
channelCapacity),
|
channelCapacity),
|
||||||
ChanReserve: aliceReserve,
|
ChanReserve: aliceReserve,
|
||||||
MinHTLC: 0,
|
MinHTLC: 0,
|
||||||
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
||||||
CsvDelay: uint16(csvTimeoutAlice),
|
}
|
||||||
|
aliceCommitParams := channeldb.CommitmentParams{
|
||||||
|
DustLimit: btcutil.Amount(200),
|
||||||
|
CsvDelay: uint16(csvTimeoutAlice),
|
||||||
}
|
}
|
||||||
|
|
||||||
bobConstraints := &channeldb.ChannelConstraints{
|
bobBounds := channeldb.ChannelStateBounds{
|
||||||
DustLimit: btcutil.Amount(800),
|
|
||||||
MaxPendingAmount: lnwire.NewMSatFromSatoshis(
|
MaxPendingAmount: lnwire.NewMSatFromSatoshis(
|
||||||
channelCapacity),
|
channelCapacity),
|
||||||
ChanReserve: bobReserve,
|
ChanReserve: bobReserve,
|
||||||
MinHTLC: 0,
|
MinHTLC: 0,
|
||||||
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
||||||
CsvDelay: uint16(csvTimeoutBob),
|
}
|
||||||
|
bobCommitParams := channeldb.CommitmentParams{
|
||||||
|
DustLimit: btcutil.Amount(800),
|
||||||
|
CsvDelay: uint16(csvTimeoutBob),
|
||||||
}
|
}
|
||||||
|
|
||||||
var hash [sha256.Size]byte
|
var hash [sha256.Size]byte
|
||||||
@@ -172,7 +176,8 @@ func createTestChannel(t *testing.T, alicePrivKey, bobPrivKey []byte,
|
|||||||
fundingTxIn := wire.NewTxIn(prevOut, nil, nil)
|
fundingTxIn := wire.NewTxIn(prevOut, nil, nil)
|
||||||
|
|
||||||
aliceCfg := channeldb.ChannelConfig{
|
aliceCfg := channeldb.ChannelConfig{
|
||||||
ChannelConstraints: *aliceConstraints,
|
ChannelStateBounds: aliceBounds,
|
||||||
|
CommitmentParams: aliceCommitParams,
|
||||||
MultiSigKey: keychain.KeyDescriptor{
|
MultiSigKey: keychain.KeyDescriptor{
|
||||||
PubKey: aliceKeyPub,
|
PubKey: aliceKeyPub,
|
||||||
},
|
},
|
||||||
@@ -190,7 +195,8 @@ func createTestChannel(t *testing.T, alicePrivKey, bobPrivKey []byte,
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
bobCfg := channeldb.ChannelConfig{
|
bobCfg := channeldb.ChannelConfig{
|
||||||
ChannelConstraints: *bobConstraints,
|
ChannelStateBounds: bobBounds,
|
||||||
|
CommitmentParams: bobCommitParams,
|
||||||
MultiSigKey: keychain.KeyDescriptor{
|
MultiSigKey: keychain.KeyDescriptor{
|
||||||
PubKey: bobKeyPub,
|
PubKey: bobKeyPub,
|
||||||
},
|
},
|
||||||
|
|||||||
+46
-28
@@ -501,29 +501,34 @@ func (r *ChannelReservation) IsTaproot() bool {
|
|||||||
// of satoshis that can be transferred in a single commitment. This function
|
// of satoshis that can be transferred in a single commitment. This function
|
||||||
// will also attempt to verify the constraints for sanity, returning an error
|
// will also attempt to verify the constraints for sanity, returning an error
|
||||||
// if the parameters are seemed unsound.
|
// if the parameters are seemed unsound.
|
||||||
func (r *ChannelReservation) CommitConstraints(c *channeldb.ChannelConstraints,
|
func (r *ChannelReservation) CommitConstraints(
|
||||||
maxLocalCSVDelay uint16, responder bool) error {
|
bounds *channeldb.ChannelStateBounds,
|
||||||
|
commitParams *channeldb.CommitmentParams,
|
||||||
|
maxLocalCSVDelay uint16,
|
||||||
|
responder bool) error {
|
||||||
|
|
||||||
r.Lock()
|
r.Lock()
|
||||||
defer r.Unlock()
|
defer r.Unlock()
|
||||||
|
|
||||||
// First, verify the sanity of the channel constraints.
|
// First, verify the sanity of the channel constraints.
|
||||||
err := VerifyConstraints(c, maxLocalCSVDelay, r.partialState.Capacity)
|
err := VerifyConstraints(
|
||||||
|
bounds, commitParams, maxLocalCSVDelay, r.partialState.Capacity,
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Our dust limit should always be less than or equal to our proposed
|
// Our dust limit should always be less than or equal to our proposed
|
||||||
// channel reserve.
|
// channel reserve.
|
||||||
if responder && r.ourContribution.DustLimit > c.ChanReserve {
|
if responder && r.ourContribution.DustLimit > bounds.ChanReserve {
|
||||||
r.ourContribution.DustLimit = c.ChanReserve
|
r.ourContribution.DustLimit = bounds.ChanReserve
|
||||||
}
|
}
|
||||||
|
|
||||||
r.ourContribution.ChanReserve = c.ChanReserve
|
r.ourContribution.ChanReserve = bounds.ChanReserve
|
||||||
r.ourContribution.MaxPendingAmount = c.MaxPendingAmount
|
r.ourContribution.MaxPendingAmount = bounds.MaxPendingAmount
|
||||||
r.ourContribution.MinHTLC = c.MinHTLC
|
r.ourContribution.MinHTLC = bounds.MinHTLC
|
||||||
r.ourContribution.MaxAcceptedHtlcs = c.MaxAcceptedHtlcs
|
r.ourContribution.MaxAcceptedHtlcs = bounds.MaxAcceptedHtlcs
|
||||||
r.ourContribution.CsvDelay = c.CsvDelay
|
r.ourContribution.CsvDelay = commitParams.CsvDelay
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -805,62 +810,75 @@ func (r *ChannelReservation) Cancel() error {
|
|||||||
|
|
||||||
// VerifyConstraints is a helper function that can be used to check the sanity
|
// VerifyConstraints is a helper function that can be used to check the sanity
|
||||||
// of various channel constraints.
|
// of various channel constraints.
|
||||||
func VerifyConstraints(c *channeldb.ChannelConstraints,
|
func VerifyConstraints(bounds *channeldb.ChannelStateBounds,
|
||||||
maxLocalCSVDelay uint16, channelCapacity btcutil.Amount) error {
|
commitParams *channeldb.CommitmentParams, maxLocalCSVDelay uint16,
|
||||||
|
channelCapacity btcutil.Amount) error {
|
||||||
|
|
||||||
// Fail if the csv delay for our funds exceeds our maximum.
|
// Fail if the csv delay for our funds exceeds our maximum.
|
||||||
if c.CsvDelay > maxLocalCSVDelay {
|
if commitParams.CsvDelay > maxLocalCSVDelay {
|
||||||
return ErrCsvDelayTooLarge(c.CsvDelay, maxLocalCSVDelay)
|
return ErrCsvDelayTooLarge(
|
||||||
|
commitParams.CsvDelay, maxLocalCSVDelay,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// The channel reserve should always be greater or equal to the dust
|
// The channel reserve should always be greater or equal to the dust
|
||||||
// limit. The reservation request should be denied if otherwise.
|
// limit. The reservation request should be denied if otherwise.
|
||||||
if c.DustLimit > c.ChanReserve {
|
if commitParams.DustLimit > bounds.ChanReserve {
|
||||||
return ErrChanReserveTooSmall(c.ChanReserve, c.DustLimit)
|
return ErrChanReserveTooSmall(
|
||||||
|
bounds.ChanReserve, commitParams.DustLimit,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate against the maximum-sized witness script dust limit, and
|
// Validate against the maximum-sized witness script dust limit, and
|
||||||
// also ensure that the DustLimit is not too large.
|
// also ensure that the DustLimit is not too large.
|
||||||
maxWitnessLimit := DustLimitForSize(input.UnknownWitnessSize)
|
maxWitnessLimit := DustLimitForSize(input.UnknownWitnessSize)
|
||||||
if c.DustLimit < maxWitnessLimit || c.DustLimit > 3*maxWitnessLimit {
|
if commitParams.DustLimit < maxWitnessLimit ||
|
||||||
return ErrInvalidDustLimit(c.DustLimit)
|
commitParams.DustLimit > 3*maxWitnessLimit {
|
||||||
|
|
||||||
|
return ErrInvalidDustLimit(commitParams.DustLimit)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fail if we consider the channel reserve to be too large. We
|
// Fail if we consider the channel reserve to be too large. We
|
||||||
// currently fail if it is greater than 20% of the channel capacity.
|
// currently fail if it is greater than 20% of the channel capacity.
|
||||||
maxChanReserve := channelCapacity / 5
|
maxChanReserve := channelCapacity / 5
|
||||||
if c.ChanReserve > maxChanReserve {
|
if bounds.ChanReserve > maxChanReserve {
|
||||||
return ErrChanReserveTooLarge(c.ChanReserve, maxChanReserve)
|
return ErrChanReserveTooLarge(
|
||||||
|
bounds.ChanReserve, maxChanReserve,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fail if the minimum HTLC value is too large. If this is too large,
|
// Fail if the minimum HTLC value is too large. If this is too large,
|
||||||
// the channel won't be useful for sending small payments. This limit
|
// the channel won't be useful for sending small payments. This limit
|
||||||
// is currently set to maxValueInFlight, effectively letting the remote
|
// is currently set to maxValueInFlight, effectively letting the remote
|
||||||
// setting this as large as it wants.
|
// setting this as large as it wants.
|
||||||
if c.MinHTLC > c.MaxPendingAmount {
|
if bounds.MinHTLC > bounds.MaxPendingAmount {
|
||||||
return ErrMinHtlcTooLarge(c.MinHTLC, c.MaxPendingAmount)
|
return ErrMinHtlcTooLarge(
|
||||||
|
bounds.MinHTLC, bounds.MaxPendingAmount,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fail if maxHtlcs is above the maximum allowed number of 483. This
|
// Fail if maxHtlcs is above the maximum allowed number of 483. This
|
||||||
// number is specified in BOLT-02.
|
// number is specified in BOLT-02.
|
||||||
if c.MaxAcceptedHtlcs > uint16(input.MaxHTLCNumber/2) {
|
if bounds.MaxAcceptedHtlcs > uint16(input.MaxHTLCNumber/2) {
|
||||||
return ErrMaxHtlcNumTooLarge(
|
return ErrMaxHtlcNumTooLarge(
|
||||||
c.MaxAcceptedHtlcs, uint16(input.MaxHTLCNumber/2),
|
bounds.MaxAcceptedHtlcs, uint16(input.MaxHTLCNumber/2),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fail if we consider maxHtlcs too small. If this is too small we
|
// Fail if we consider maxHtlcs too small. If this is too small we
|
||||||
// cannot offer many HTLCs to the remote.
|
// cannot offer many HTLCs to the remote.
|
||||||
const minNumHtlc = 5
|
const minNumHtlc = 5
|
||||||
if c.MaxAcceptedHtlcs < minNumHtlc {
|
if bounds.MaxAcceptedHtlcs < minNumHtlc {
|
||||||
return ErrMaxHtlcNumTooSmall(c.MaxAcceptedHtlcs, minNumHtlc)
|
return ErrMaxHtlcNumTooSmall(
|
||||||
|
bounds.MaxAcceptedHtlcs, minNumHtlc,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fail if we consider maxValueInFlight too small. We currently require
|
// Fail if we consider maxValueInFlight too small. We currently require
|
||||||
// the remote to at least allow minNumHtlc * minHtlc in flight.
|
// the remote to at least allow minNumHtlc * minHtlc in flight.
|
||||||
if c.MaxPendingAmount < minNumHtlc*c.MinHTLC {
|
if bounds.MaxPendingAmount < minNumHtlc*bounds.MinHTLC {
|
||||||
return ErrMaxValueInFlightTooSmall(
|
return ErrMaxValueInFlightTooSmall(
|
||||||
c.MaxPendingAmount, minNumHtlc*c.MinHTLC,
|
bounds.MaxPendingAmount, minNumHtlc*bounds.MinHTLC,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -422,16 +422,18 @@ func testDualFundingReservationWorkflow(miner *rpctest.Harness,
|
|||||||
aliceChanReservation, err := alice.InitChannelReservation(aliceReq)
|
aliceChanReservation, err := alice.InitChannelReservation(aliceReq)
|
||||||
require.NoError(t, err, "unable to initialize funding reservation")
|
require.NoError(t, err, "unable to initialize funding reservation")
|
||||||
aliceChanReservation.SetNumConfsRequired(numReqConfs)
|
aliceChanReservation.SetNumConfsRequired(numReqConfs)
|
||||||
channelConstraints := &channeldb.ChannelConstraints{
|
bounds := &channeldb.ChannelStateBounds{
|
||||||
DustLimit: lnwallet.DustLimitUnknownWitness(),
|
|
||||||
ChanReserve: fundingAmount / 100,
|
ChanReserve: fundingAmount / 100,
|
||||||
MaxPendingAmount: lnwire.NewMSatFromSatoshis(fundingAmount),
|
MaxPendingAmount: lnwire.NewMSatFromSatoshis(fundingAmount),
|
||||||
MinHTLC: 1,
|
MinHTLC: 1,
|
||||||
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
||||||
CsvDelay: csvDelay,
|
}
|
||||||
|
commitParams := &channeldb.CommitmentParams{
|
||||||
|
DustLimit: lnwallet.DustLimitUnknownWitness(),
|
||||||
|
CsvDelay: csvDelay,
|
||||||
}
|
}
|
||||||
err = aliceChanReservation.CommitConstraints(
|
err = aliceChanReservation.CommitConstraints(
|
||||||
channelConstraints, defaultMaxLocalCsvDelay, false,
|
bounds, commitParams, defaultMaxLocalCsvDelay, false,
|
||||||
)
|
)
|
||||||
require.NoError(t, err, "unable to verify constraints")
|
require.NoError(t, err, "unable to verify constraints")
|
||||||
|
|
||||||
@@ -463,7 +465,7 @@ func testDualFundingReservationWorkflow(miner *rpctest.Harness,
|
|||||||
bobChanReservation, err := bob.InitChannelReservation(bobReq)
|
bobChanReservation, err := bob.InitChannelReservation(bobReq)
|
||||||
require.NoError(t, err, "bob unable to init channel reservation")
|
require.NoError(t, err, "bob unable to init channel reservation")
|
||||||
err = bobChanReservation.CommitConstraints(
|
err = bobChanReservation.CommitConstraints(
|
||||||
channelConstraints, defaultMaxLocalCsvDelay, true,
|
bounds, commitParams, defaultMaxLocalCsvDelay, true,
|
||||||
)
|
)
|
||||||
require.NoError(t, err, "unable to verify constraints")
|
require.NoError(t, err, "unable to verify constraints")
|
||||||
bobChanReservation.SetNumConfsRequired(numReqConfs)
|
bobChanReservation.SetNumConfsRequired(numReqConfs)
|
||||||
@@ -827,16 +829,18 @@ func testSingleFunderReservationWorkflow(miner *rpctest.Harness,
|
|||||||
aliceChanReservation, err := alice.InitChannelReservation(aliceReq)
|
aliceChanReservation, err := alice.InitChannelReservation(aliceReq)
|
||||||
require.NoError(t, err, "unable to init channel reservation")
|
require.NoError(t, err, "unable to init channel reservation")
|
||||||
aliceChanReservation.SetNumConfsRequired(numReqConfs)
|
aliceChanReservation.SetNumConfsRequired(numReqConfs)
|
||||||
channelConstraints := &channeldb.ChannelConstraints{
|
bounds := &channeldb.ChannelStateBounds{
|
||||||
DustLimit: lnwallet.DustLimitUnknownWitness(),
|
|
||||||
ChanReserve: fundingAmt / 100,
|
ChanReserve: fundingAmt / 100,
|
||||||
MaxPendingAmount: lnwire.NewMSatFromSatoshis(fundingAmt),
|
MaxPendingAmount: lnwire.NewMSatFromSatoshis(fundingAmt),
|
||||||
MinHTLC: 1,
|
MinHTLC: 1,
|
||||||
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
||||||
CsvDelay: csvDelay,
|
}
|
||||||
|
commitParams := &channeldb.CommitmentParams{
|
||||||
|
DustLimit: lnwallet.DustLimitUnknownWitness(),
|
||||||
|
CsvDelay: csvDelay,
|
||||||
}
|
}
|
||||||
err = aliceChanReservation.CommitConstraints(
|
err = aliceChanReservation.CommitConstraints(
|
||||||
channelConstraints, defaultMaxLocalCsvDelay, false,
|
bounds, commitParams, defaultMaxLocalCsvDelay, false,
|
||||||
)
|
)
|
||||||
require.NoError(t, err, "unable to verify constraints")
|
require.NoError(t, err, "unable to verify constraints")
|
||||||
|
|
||||||
@@ -875,7 +879,7 @@ func testSingleFunderReservationWorkflow(miner *rpctest.Harness,
|
|||||||
bobChanReservation, err := bob.InitChannelReservation(bobReq)
|
bobChanReservation, err := bob.InitChannelReservation(bobReq)
|
||||||
require.NoError(t, err, "unable to create bob reservation")
|
require.NoError(t, err, "unable to create bob reservation")
|
||||||
err = bobChanReservation.CommitConstraints(
|
err = bobChanReservation.CommitConstraints(
|
||||||
channelConstraints, defaultMaxLocalCsvDelay, true,
|
bounds, commitParams, defaultMaxLocalCsvDelay, true,
|
||||||
)
|
)
|
||||||
require.NoError(t, err, "unable to verify constraints")
|
require.NoError(t, err, "unable to verify constraints")
|
||||||
bobChanReservation.SetNumConfsRequired(numReqConfs)
|
bobChanReservation.SetNumConfsRequired(numReqConfs)
|
||||||
|
|||||||
+10
-6
@@ -150,13 +150,15 @@ func CreateTestChannels(t *testing.T, chanType channeldb.ChannelType,
|
|||||||
}
|
}
|
||||||
|
|
||||||
aliceCfg := channeldb.ChannelConfig{
|
aliceCfg := channeldb.ChannelConfig{
|
||||||
ChannelConstraints: channeldb.ChannelConstraints{
|
ChannelStateBounds: channeldb.ChannelStateBounds{
|
||||||
DustLimit: aliceDustLimit,
|
|
||||||
MaxPendingAmount: lnwire.NewMSatFromSatoshis(channelCapacity),
|
MaxPendingAmount: lnwire.NewMSatFromSatoshis(channelCapacity),
|
||||||
ChanReserve: channelCapacity / 100,
|
ChanReserve: channelCapacity / 100,
|
||||||
MinHTLC: 0,
|
MinHTLC: 0,
|
||||||
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
||||||
CsvDelay: uint16(csvTimeoutAlice),
|
},
|
||||||
|
CommitmentParams: channeldb.CommitmentParams{
|
||||||
|
DustLimit: aliceDustLimit,
|
||||||
|
CsvDelay: uint16(csvTimeoutAlice),
|
||||||
},
|
},
|
||||||
MultiSigKey: keychain.KeyDescriptor{
|
MultiSigKey: keychain.KeyDescriptor{
|
||||||
PubKey: aliceKeys[0].PubKey(),
|
PubKey: aliceKeys[0].PubKey(),
|
||||||
@@ -175,13 +177,15 @@ func CreateTestChannels(t *testing.T, chanType channeldb.ChannelType,
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
bobCfg := channeldb.ChannelConfig{
|
bobCfg := channeldb.ChannelConfig{
|
||||||
ChannelConstraints: channeldb.ChannelConstraints{
|
ChannelStateBounds: channeldb.ChannelStateBounds{
|
||||||
DustLimit: bobDustLimit,
|
|
||||||
MaxPendingAmount: lnwire.NewMSatFromSatoshis(channelCapacity),
|
MaxPendingAmount: lnwire.NewMSatFromSatoshis(channelCapacity),
|
||||||
ChanReserve: channelCapacity / 100,
|
ChanReserve: channelCapacity / 100,
|
||||||
MinHTLC: 0,
|
MinHTLC: 0,
|
||||||
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
||||||
CsvDelay: uint16(csvTimeoutBob),
|
},
|
||||||
|
CommitmentParams: channeldb.CommitmentParams{
|
||||||
|
DustLimit: bobDustLimit,
|
||||||
|
CsvDelay: uint16(csvTimeoutBob),
|
||||||
},
|
},
|
||||||
MultiSigKey: keychain.KeyDescriptor{
|
MultiSigKey: keychain.KeyDescriptor{
|
||||||
PubKey: bobKeys[0].PubKey(),
|
PubKey: bobKeys[0].PubKey(),
|
||||||
|
|||||||
@@ -603,14 +603,14 @@ func testSpendValidation(t *testing.T, tweakless bool) {
|
|||||||
dustLimit := DustLimitForSize(input.UnknownWitnessSize)
|
dustLimit := DustLimitForSize(input.UnknownWitnessSize)
|
||||||
|
|
||||||
aliceChanCfg := &channeldb.ChannelConfig{
|
aliceChanCfg := &channeldb.ChannelConfig{
|
||||||
ChannelConstraints: channeldb.ChannelConstraints{
|
CommitmentParams: channeldb.CommitmentParams{
|
||||||
DustLimit: dustLimit,
|
DustLimit: dustLimit,
|
||||||
CsvDelay: csvTimeout,
|
CsvDelay: csvTimeout,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
bobChanCfg := &channeldb.ChannelConfig{
|
bobChanCfg := &channeldb.ChannelConfig{
|
||||||
ChannelConstraints: channeldb.ChannelConstraints{
|
CommitmentParams: channeldb.CommitmentParams{
|
||||||
DustLimit: dustLimit,
|
DustLimit: dustLimit,
|
||||||
CsvDelay: csvTimeout,
|
CsvDelay: csvTimeout,
|
||||||
},
|
},
|
||||||
@@ -834,15 +834,17 @@ func createTestChannelsForVectors(tc *testContext, chanType channeldb.ChannelTyp
|
|||||||
|
|
||||||
// Define channel configurations.
|
// Define channel configurations.
|
||||||
remoteCfg := channeldb.ChannelConfig{
|
remoteCfg := channeldb.ChannelConfig{
|
||||||
ChannelConstraints: channeldb.ChannelConstraints{
|
ChannelStateBounds: channeldb.ChannelStateBounds{
|
||||||
DustLimit: tc.dustLimit,
|
|
||||||
MaxPendingAmount: lnwire.NewMSatFromSatoshis(
|
MaxPendingAmount: lnwire.NewMSatFromSatoshis(
|
||||||
tc.fundingAmount,
|
tc.fundingAmount,
|
||||||
),
|
),
|
||||||
ChanReserve: 0,
|
ChanReserve: 0,
|
||||||
MinHTLC: 0,
|
MinHTLC: 0,
|
||||||
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
||||||
CsvDelay: tc.localCsvDelay,
|
},
|
||||||
|
CommitmentParams: channeldb.CommitmentParams{
|
||||||
|
DustLimit: tc.dustLimit,
|
||||||
|
CsvDelay: tc.localCsvDelay,
|
||||||
},
|
},
|
||||||
MultiSigKey: keychain.KeyDescriptor{
|
MultiSigKey: keychain.KeyDescriptor{
|
||||||
PubKey: tc.remoteFundingPrivkey.PubKey(),
|
PubKey: tc.remoteFundingPrivkey.PubKey(),
|
||||||
@@ -861,15 +863,17 @@ func createTestChannelsForVectors(tc *testContext, chanType channeldb.ChannelTyp
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
localCfg := channeldb.ChannelConfig{
|
localCfg := channeldb.ChannelConfig{
|
||||||
ChannelConstraints: channeldb.ChannelConstraints{
|
ChannelStateBounds: channeldb.ChannelStateBounds{
|
||||||
DustLimit: tc.dustLimit,
|
|
||||||
MaxPendingAmount: lnwire.NewMSatFromSatoshis(
|
MaxPendingAmount: lnwire.NewMSatFromSatoshis(
|
||||||
tc.fundingAmount,
|
tc.fundingAmount,
|
||||||
),
|
),
|
||||||
ChanReserve: 0,
|
ChanReserve: 0,
|
||||||
MinHTLC: 0,
|
MinHTLC: 0,
|
||||||
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
||||||
CsvDelay: tc.localCsvDelay,
|
},
|
||||||
|
CommitmentParams: channeldb.CommitmentParams{
|
||||||
|
DustLimit: tc.dustLimit,
|
||||||
|
CsvDelay: tc.localCsvDelay,
|
||||||
},
|
},
|
||||||
MultiSigKey: keychain.KeyDescriptor{
|
MultiSigKey: keychain.KeyDescriptor{
|
||||||
PubKey: tc.localFundingPrivkey.PubKey(),
|
PubKey: tc.localFundingPrivkey.PubKey(),
|
||||||
|
|||||||
+1
-1
@@ -1379,7 +1379,7 @@ func (l *LightningWallet) initOurContribution(reservation *ChannelReservation,
|
|||||||
)
|
)
|
||||||
|
|
||||||
reservation.partialState.RevocationProducer = producer
|
reservation.partialState.RevocationProducer = producer
|
||||||
reservation.ourContribution.ChannelConstraints.DustLimit =
|
reservation.ourContribution.CommitmentParams.DustLimit =
|
||||||
DustLimitUnknownWitness()
|
DustLimitUnknownWitness()
|
||||||
|
|
||||||
// If taproot channels are active, then we'll generate our verification
|
// If taproot channels are active, then we'll generate our verification
|
||||||
|
|||||||
+10
-6
@@ -115,13 +115,15 @@ func createTestPeerWithChannel(t *testing.T, updateChan func(a,
|
|||||||
)
|
)
|
||||||
|
|
||||||
aliceCfg := channeldb.ChannelConfig{
|
aliceCfg := channeldb.ChannelConfig{
|
||||||
ChannelConstraints: channeldb.ChannelConstraints{
|
ChannelStateBounds: channeldb.ChannelStateBounds{
|
||||||
DustLimit: aliceDustLimit,
|
|
||||||
MaxPendingAmount: lnwire.MilliSatoshi(rand.Int63()),
|
MaxPendingAmount: lnwire.MilliSatoshi(rand.Int63()),
|
||||||
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),
|
},
|
||||||
|
CommitmentParams: channeldb.CommitmentParams{
|
||||||
|
DustLimit: aliceDustLimit,
|
||||||
|
CsvDelay: uint16(csvTimeoutAlice),
|
||||||
},
|
},
|
||||||
MultiSigKey: keychain.KeyDescriptor{
|
MultiSigKey: keychain.KeyDescriptor{
|
||||||
PubKey: aliceKeyPub,
|
PubKey: aliceKeyPub,
|
||||||
@@ -140,13 +142,15 @@ func createTestPeerWithChannel(t *testing.T, updateChan func(a,
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
bobCfg := channeldb.ChannelConfig{
|
bobCfg := channeldb.ChannelConfig{
|
||||||
ChannelConstraints: channeldb.ChannelConstraints{
|
ChannelStateBounds: channeldb.ChannelStateBounds{
|
||||||
DustLimit: bobDustLimit,
|
|
||||||
MaxPendingAmount: lnwire.MilliSatoshi(rand.Int63()),
|
MaxPendingAmount: lnwire.MilliSatoshi(rand.Int63()),
|
||||||
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),
|
},
|
||||||
|
CommitmentParams: channeldb.CommitmentParams{
|
||||||
|
DustLimit: bobDustLimit,
|
||||||
|
CsvDelay: uint16(csvTimeoutBob),
|
||||||
},
|
},
|
||||||
MultiSigKey: keychain.KeyDescriptor{
|
MultiSigKey: keychain.KeyDescriptor{
|
||||||
PubKey: bobKeyPub,
|
PubKey: bobKeyPub,
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ func (r *Manager) getHtlcAmtLimits(tx kvdb.RTx, chanPoint wire.OutPoint) (
|
|||||||
// capacity AND less than or equal to the max in-flight HTLC value.
|
// capacity AND less than or equal to the max in-flight HTLC value.
|
||||||
// Since the latter is always less than or equal to the former, just
|
// Since the latter is always less than or equal to the former, just
|
||||||
// return the max in-flight value.
|
// return the max in-flight value.
|
||||||
maxAmt := ch.LocalChanCfg.ChannelConstraints.MaxPendingAmount
|
maxAmt := ch.LocalChanCfg.ChannelStateBounds.MaxPendingAmount
|
||||||
|
|
||||||
return ch.LocalChanCfg.MinHTLC, maxAmt, nil
|
return ch.LocalChanCfg.MinHTLC, maxAmt, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,14 +125,14 @@ func TestManager(t *testing.T) {
|
|||||||
return &channeldb.OpenChannel{}, channeldb.ErrChannelNotFound
|
return &channeldb.OpenChannel{}, channeldb.ErrChannelNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
constraints := channeldb.ChannelConstraints{
|
bounds := channeldb.ChannelStateBounds{
|
||||||
MaxPendingAmount: maxPendingAmount,
|
MaxPendingAmount: maxPendingAmount,
|
||||||
MinHTLC: minHTLC,
|
MinHTLC: minHTLC,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &channeldb.OpenChannel{
|
return &channeldb.OpenChannel{
|
||||||
LocalChanCfg: channeldb.ChannelConfig{
|
LocalChanCfg: channeldb.ChannelConfig{
|
||||||
ChannelConstraints: constraints,
|
ChannelStateBounds: bounds,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user