rpc: compute and display blocks left till channel open in PendingChannels

This commit is contained in:
Olaoluwa Osuntokun 2017-12-02 18:41:41 -08:00
parent c57eda4c6d
commit ad71a62b96
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -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
}
}