lnrpc: add push amount to listchannels

This commit is contained in:
carla 2020-03-18 10:52:43 +02:00
parent 41355756a1
commit 72e3b0a5d7
No known key found for this signature in database
GPG Key ID: 4CA7FE54A6213C91
4 changed files with 628 additions and 582 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1428,6 +1428,15 @@ message Channel {
cooperatively closing with the delivery_address field set.
*/
string close_address = 25;
/*
The amount that the initiator of the channel optionally pushed to the remote
party on channel open. This amount will be zero if the channel initiator did
not push any funds to the remote peer. If the initiator field is true, we
pushed this amount to our peer, if it is false, the remote peer pushed this
amount to us.
*/
uint64 push_amount_sat = 27;
}
message ListChannelsRequest {

View File

@ -1997,6 +1997,11 @@
"close_address": {
"type": "string",
"description": "*\nClose address is the address that we will enforce payout to on cooperative\nclose if the channel was opened utilizing option upfront shutdown. This\nvalue can be set on channel open by setting close_address in an open channel\nrequest. If this value is not set, you can still choose a payout address by\ncooperatively closing with the delivery_address field set."
},
"push_amount_sat": {
"type": "string",
"format": "uint64",
"description": "The amount that the initiator of the channel optionally pushed to the remote\nparty on channel open. This amount will be zero if the channel initiator did\nnot push any funds to the remote peer. If the initiator field is true, we\npushed this amount to our peer, if it is false, the remote peer pushed this\namount to us."
}
}
},

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