funding: provide FundingExpiryBlock field in PendingOpenChannel message.

This commit is contained in:
Maxwell Sayles committed 2023-06-12 10:04:04 -07:00
1 parent 9dea695079
commit 663b28808a
4 files changed
+1801 -1753

No files matched your search

+1770 -1750
View File
File diff suppressed because it is too large. Load diff
+11
View File
@@ -2581,6 +2581,17 @@ message PendingChannelsResponse {
// Previously used for confirmation_height. Do not reuse.
reserved 2;
// The number of blocks until the funding transaction is considered
// expired. If this value gets close to zero, there is a risk that the
// channel funding will be canceled by the channel responder. The
// channel should be fee bumped using CPFP (see walletrpc.BumpFee) to
// ensure that the channel confirms in time. Otherwise a force-close
// will be necessary if the channel confirms after the funding
// transaction expires. A negative value means the channel responder has
// very likely canceled the funding and the channel will never become
// fully operational.
int32 funding_expiry_blocks = 3;
}
message WaitingCloseChannel {
+5
View File
@@ -3052,6 +3052,11 @@
"type": "string",
"format": "int64",
"description": "The required number of satoshis per kilo-weight that the requester will\npay at all times, for both the funding transaction and commitment\ntransaction. This value can later be updated once the channel is open."
},
"funding_expiry_blocks": {
"type": "integer",
"format": "int32",
"description": "The number of blocks until the funding transaction is considered\nexpired. If this value gets close to zero, there is a risk that the\nchannel funding will be canceled by the channel responder. The\nchannel should be fee bumped using CPFP (see walletrpc.BumpFee) to\nensure that the channel confirms in time. Otherwise a force-close\nwill be necessary if the channel confirms after the funding\ntransaction expires. A negative value means the channel responder has\nvery likely canceled the funding and the channel will never become\nfully operational."
}
}
},
+15 -3
View File
@@ -3373,6 +3373,11 @@ func (r *rpcServer) fetchPendingOpenChannels() (pendingOpenChannels, error) {
return nil, err
}
_, currentHeight, err := r.server.cc.ChainIO.GetBestBlock()
if err != nil {
return nil, err
}
result := make(pendingOpenChannels, len(channels))
for i, pendingChan := range channels {
pub := pendingChan.IdentityPub.SerializeCompressed()
@@ -3389,6 +3394,12 @@ func (r *rpcServer) fetchPendingOpenChannels() (pendingOpenChannels, error) {
commitBaseWeight := blockchain.GetTransactionWeight(utx)
commitWeight := commitBaseWeight + input.WitnessCommitmentTxWeight
// FundingExpiryBlocks is the distance from the current block
// height to the broadcast height + MaxWaitNumBlocksFundingConf.
maxFundingHeight := funding.MaxWaitNumBlocksFundingConf +
pendingChan.BroadcastHeight()
fundingExpiryBlocks := int32(maxFundingHeight) - currentHeight
result[i] = &lnrpc.PendingChannelsResponse_PendingOpenChannel{
Channel: &lnrpc.PendingChannelsResponse_PendingChannel{
RemoteNodePub: hex.EncodeToString(pub),
@@ -3402,9 +3413,10 @@ func (r *rpcServer) fetchPendingOpenChannels() (pendingOpenChannels, error) {
CommitmentType: rpcCommitmentType(pendingChan.ChanType),
Private: isPrivate(pendingChan),
},
CommitWeight: commitWeight,
CommitFee: int64(localCommitment.CommitFee),
FeePerKw: int64(localCommitment.FeePerKw),
CommitWeight: commitWeight,
CommitFee: int64(localCommitment.CommitFee),
FeePerKw: int64(localCommitment.FeePerKw),
FundingExpiryBlocks: fundingExpiryBlocks,
// TODO(roasbeef): need to track confirmation height
}
}