mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-28 12:39:51 +02:00
lnrpc: add push amount to listchannels
This commit is contained in:
parent
41355756a1
commit
72e3b0a5d7
1179
lnrpc/rpc.pb.go
1179
lnrpc/rpc.pb.go
File diff suppressed because it is too large
Load Diff
@ -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 {
|
||||
|
@ -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."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
17
rpcserver.go
17
rpcserver.go
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user