rpc: compute and display blocks left till channel open in PendingChannels
This commit is contained in:
parent
c57eda4c6d
commit
ad71a62b96
14
rpcserver.go
14
rpcserver.go
@ -1246,6 +1246,11 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
||||
}
|
||||
}
|
||||
|
||||
_, bestHeight, err := r.server.cc.chainIO.GetBestBlock()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rpcsLog.Debugf("[pendingchannels]")
|
||||
|
||||
resp := &lnrpc.PendingChannelResponse{}
|
||||
@ -1274,6 +1279,8 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
||||
commitBaseWeight := blockchain.GetTransactionWeight(utx)
|
||||
commitWeight := commitBaseWeight + lnwallet.WitnessCommitmentTxWeight
|
||||
|
||||
targetConfHeight := pendingChan.FundingBroadcastHeight + uint32(pendingChan.NumConfsRequired)
|
||||
blocksTillOpen := int32(targetConfHeight) - bestHeight
|
||||
resp.PendingOpenChannels[i] = &lnrpc.PendingChannelResponse_PendingOpenChannel{
|
||||
Channel: &lnrpc.PendingChannelResponse_PendingChannel{
|
||||
RemoteNodePub: hex.EncodeToString(pub),
|
||||
@ -1282,9 +1289,10 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
|
||||
LocalBalance: int64(localCommitment.LocalBalance.ToSatoshis()),
|
||||
RemoteBalance: int64(localCommitment.RemoteBalance.ToSatoshis()),
|
||||
},
|
||||
CommitWeight: commitWeight,
|
||||
CommitFee: int64(localCommitment.CommitFee),
|
||||
FeePerKw: int64(localCommitment.FeePerKw),
|
||||
CommitWeight: commitWeight,
|
||||
CommitFee: int64(localCommitment.CommitFee),
|
||||
FeePerKw: int64(localCommitment.FeePerKw),
|
||||
BlocksTillOpen: blocksTillOpen,
|
||||
// TODO(roasbeef): need to track confirmation height
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user