lnrpc: add push amount to listchannels

This commit is contained in:
carla
2020-03-18 10:52:43 +02:00
parent 41355756a1
commit 72e3b0a5d7
4 changed files with 628 additions and 582 deletions

View File

@@ -3195,6 +3195,23 @@ func createRPCOpenChannel(r *rpcServer, graph *channeldb.ChannelGraph,
channel.UnsettledBalance += channel.PendingHtlcs[i].Amount
}
// Lookup our balances at height 0, because they will reflect any
// push amounts that may have been present when this channel was
// created.
localBalance, remoteBalance, err := dbChannel.BalancesAtHeight(0)
if err != nil {
return nil, err
}
// If we initiated opening the channel, the zero height remote balance
// is the push amount. Otherwise, our starting balance is the push
// amount. If there is no push amount, these values will simply be zero.
if dbChannel.IsInitiator {
channel.PushAmountSat = uint64(remoteBalance.ToSatoshis())
} else {
channel.PushAmountSat = uint64(localBalance.ToSatoshis())
}
outpoint := dbChannel.FundingOutpoint
// Get the lifespan observed by the channel event store. If the channel is