funding+lnwallet: validate ChannelReserve is above DustLimit
This is necessary and is implied by BOLT#02. Both ChannelReserve parameters should be above both DustLimit parameters. Otherwise, it is possible for one side to have nothing at stake.
This commit is contained in:
5 files changed
+81
-14
No files matched your search
+15
-3
@@ -1266,6 +1266,13 @@ func (l *LightningWallet) handleContributionMsg(req *addContributionMsg) {
|
||||
theirContribution := req.contribution
|
||||
ourContribution := pendingReservation.ourContribution
|
||||
|
||||
// Perform bounds-checking on both ChannelReserve and DustLimit
|
||||
// parameters.
|
||||
if !pendingReservation.validateReserveBounds() {
|
||||
req.err <- fmt.Errorf("invalid reserve and dust bounds")
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
chanPoint *wire.OutPoint
|
||||
err error
|
||||
@@ -1564,9 +1571,6 @@ func (l *LightningWallet) handleSingleContribution(req *addSingleContributionMsg
|
||||
pendingReservation.Lock()
|
||||
defer pendingReservation.Unlock()
|
||||
|
||||
// TODO(roasbeef): verify sanity of remote party's parameters, fail if
|
||||
// disagree
|
||||
|
||||
// Validate that the remote's UpfrontShutdownScript is a valid script
|
||||
// if it's set.
|
||||
shutdown := req.contribution.UpfrontShutdown
|
||||
@@ -1584,6 +1588,14 @@ func (l *LightningWallet) handleSingleContribution(req *addSingleContributionMsg
|
||||
theirContribution := pendingReservation.theirContribution
|
||||
chanState := pendingReservation.partialState
|
||||
|
||||
// Perform bounds checking on both ChannelReserve and DustLimit
|
||||
// parameters. The ChannelReserve may have been changed by the
|
||||
// ChannelAcceptor RPC, so this is necessary.
|
||||
if !pendingReservation.validateReserveBounds() {
|
||||
req.err <- fmt.Errorf("invalid reserve and dust bounds")
|
||||
return
|
||||
}
|
||||
|
||||
// Initialize an empty sha-chain for them, tracking the current pending
|
||||
// revocation hash (we don't yet know the preimage so we can't add it
|
||||
// to the chain).
|
||||
|
||||
Reference in new issue
Block a user