From ad71a62b96c5c83229c7bd74f572567a0c2e0207 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sat, 2 Dec 2017 18:41:41 -0800 Subject: [PATCH] rpc: compute and display blocks left till channel open in PendingChannels --- rpcserver.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/rpcserver.go b/rpcserver.go index 7ee4e171..65cc6260 100644 --- a/rpcserver.go +++ b/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 } }