lnwallet: add dust limit to contribution
In order to make the node's dust limit available to the wallet during the initial stages of the funding process, add and set a DustLimit field in the Contribution.
This commit is contained in:
parent
74854963bf
commit
18f453a3e6
@ -579,6 +579,7 @@ func (f *fundingManager) handleFundingRequest(fmsg *fundingRequestMsg) {
|
|||||||
MultiSigKey: copyPubKey(msg.ChannelDerivationPoint),
|
MultiSigKey: copyPubKey(msg.ChannelDerivationPoint),
|
||||||
CommitKey: copyPubKey(msg.CommitmentKey),
|
CommitKey: copyPubKey(msg.CommitmentKey),
|
||||||
DeliveryAddress: addrs[0],
|
DeliveryAddress: addrs[0],
|
||||||
|
DustLimit: msg.DustLimit,
|
||||||
CsvDelay: delay,
|
CsvDelay: delay,
|
||||||
}
|
}
|
||||||
if err := reservation.ProcessSingleContribution(contribution); err != nil {
|
if err := reservation.ProcessSingleContribution(contribution); err != nil {
|
||||||
@ -662,6 +663,7 @@ func (f *fundingManager) handleFundingResponse(fmsg *fundingResponseMsg) {
|
|||||||
CommitKey: copyPubKey(msg.CommitmentKey),
|
CommitKey: copyPubKey(msg.CommitmentKey),
|
||||||
DeliveryAddress: addrs[0],
|
DeliveryAddress: addrs[0],
|
||||||
RevocationKey: copyPubKey(msg.RevocationKey),
|
RevocationKey: copyPubKey(msg.RevocationKey),
|
||||||
|
DustLimit: msg.DustLimit,
|
||||||
CsvDelay: msg.CsvDelay,
|
CsvDelay: msg.CsvDelay,
|
||||||
}
|
}
|
||||||
if err := resCtx.reservation.ProcessContribution(contribution); err != nil {
|
if err := resCtx.reservation.ProcessContribution(contribution); err != nil {
|
||||||
|
@ -46,6 +46,11 @@ type ChannelContribution struct {
|
|||||||
// initial version of this party's commitment transaction.
|
// initial version of this party's commitment transaction.
|
||||||
RevocationKey *btcec.PublicKey
|
RevocationKey *btcec.PublicKey
|
||||||
|
|
||||||
|
// DustLimit is the threshold below which no HTLC output should be
|
||||||
|
// generated for this party. HTLCs below this amount are not
|
||||||
|
// enforceable on-chain from this party's point of view.
|
||||||
|
DustLimit btcutil.Amount
|
||||||
|
|
||||||
// CsvDelay The delay (in blocks) to be used for the pay-to-self output
|
// CsvDelay The delay (in blocks) to be used for the pay-to-self output
|
||||||
// in this party's version of the commitment transaction.
|
// in this party's version of the commitment transaction.
|
||||||
CsvDelay uint32
|
CsvDelay uint32
|
||||||
|
@ -529,6 +529,7 @@ func (l *LightningWallet) handleFundingReserveRequest(req *initFundingReserveMsg
|
|||||||
|
|
||||||
reservation.nodeAddr = req.nodeAddr
|
reservation.nodeAddr = req.nodeAddr
|
||||||
reservation.ourContribution.CsvDelay = req.csvDelay
|
reservation.ourContribution.CsvDelay = req.csvDelay
|
||||||
|
reservation.ourContribution.DustLimit = req.ourDustLimit
|
||||||
|
|
||||||
reservation.partialState.NumConfsRequired = req.numConfs
|
reservation.partialState.NumConfsRequired = req.numConfs
|
||||||
reservation.partialState.IdentityPub = req.nodeID
|
reservation.partialState.IdentityPub = req.nodeID
|
||||||
@ -779,16 +780,18 @@ func (l *LightningWallet) handleContributionMsg(req *addContributionMsg) {
|
|||||||
ourBalance := pendingReservation.partialState.OurBalance
|
ourBalance := pendingReservation.partialState.OurBalance
|
||||||
theirBalance := pendingReservation.partialState.TheirBalance
|
theirBalance := pendingReservation.partialState.TheirBalance
|
||||||
ourCommitKey := ourContribution.CommitKey
|
ourCommitKey := ourContribution.CommitKey
|
||||||
ourCommitTx, err := CreateCommitTx(fundingTxIn, ourCommitKey, theirCommitKey,
|
ourCommitTx, err := CreateCommitTx(fundingTxIn, ourCommitKey,
|
||||||
ourRevokeKey, ourContribution.CsvDelay,
|
theirCommitKey, ourRevokeKey, ourContribution.CsvDelay,
|
||||||
ourBalance, theirBalance, pendingReservation.partialState.OurDustLimit)
|
ourBalance, theirBalance,
|
||||||
|
pendingReservation.ourContribution.DustLimit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
req.err <- err
|
req.err <- err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
theirCommitTx, err := CreateCommitTx(fundingTxIn, theirCommitKey, ourCommitKey,
|
theirCommitTx, err := CreateCommitTx(fundingTxIn, theirCommitKey,
|
||||||
theirContribution.RevocationKey, theirContribution.CsvDelay,
|
ourCommitKey, theirContribution.RevocationKey,
|
||||||
theirBalance, ourBalance, pendingReservation.partialState.TheirDustLimit)
|
theirContribution.CsvDelay, theirBalance, ourBalance,
|
||||||
|
pendingReservation.theirContribution.DustLimit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
req.err <- err
|
req.err <- err
|
||||||
return
|
return
|
||||||
@ -1109,18 +1112,19 @@ func (l *LightningWallet) handleSingleFunderSigs(req *addSingleFunderSigsMsg) {
|
|||||||
theirCommitKey := pendingReservation.theirContribution.CommitKey
|
theirCommitKey := pendingReservation.theirContribution.CommitKey
|
||||||
ourBalance := pendingReservation.partialState.OurBalance
|
ourBalance := pendingReservation.partialState.OurBalance
|
||||||
theirBalance := pendingReservation.partialState.TheirBalance
|
theirBalance := pendingReservation.partialState.TheirBalance
|
||||||
ourCommitTx, err := CreateCommitTx(fundingTxIn, ourCommitKey, theirCommitKey,
|
ourCommitTx, err := CreateCommitTx(fundingTxIn, ourCommitKey,
|
||||||
pendingReservation.ourContribution.RevocationKey,
|
theirCommitKey, pendingReservation.ourContribution.RevocationKey,
|
||||||
pendingReservation.ourContribution.CsvDelay, ourBalance, theirBalance,
|
pendingReservation.ourContribution.CsvDelay, ourBalance,
|
||||||
pendingReservation.partialState.OurDustLimit)
|
theirBalance, pendingReservation.ourContribution.DustLimit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
req.err <- err
|
req.err <- err
|
||||||
req.completeChan <- nil
|
req.completeChan <- nil
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
theirCommitTx, err := CreateCommitTx(fundingTxIn, theirCommitKey, ourCommitKey,
|
theirCommitTx, err := CreateCommitTx(fundingTxIn, theirCommitKey,
|
||||||
req.revokeKey, pendingReservation.theirContribution.CsvDelay,
|
ourCommitKey, req.revokeKey,
|
||||||
theirBalance, ourBalance, pendingReservation.partialState.TheirDustLimit)
|
pendingReservation.theirContribution.CsvDelay, theirBalance,
|
||||||
|
ourBalance, pendingReservation.theirContribution.DustLimit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
req.err <- err
|
req.err <- err
|
||||||
req.completeChan <- nil
|
req.completeChan <- nil
|
||||||
|
Loading…
Reference in New Issue
Block a user