rpc: expand external fee to properly tally HTLC outputs
This commit is contained in:
parent
60791d83d5
commit
4f2a8fd533
15
rpcserver.go
15
rpcserver.go
@ -1484,20 +1484,19 @@ func (r *rpcServer) ListChannels(ctx context.Context,
|
|||||||
|
|
||||||
localBalance := localCommit.LocalBalance
|
localBalance := localCommit.LocalBalance
|
||||||
remoteBalance := localCommit.RemoteBalance
|
remoteBalance := localCommit.RemoteBalance
|
||||||
commitFee := localCommit.CommitFee
|
|
||||||
|
|
||||||
// As an artefact of our usage of mSAT internally, either party
|
// As an artefact of our usage of mSAT internally, either party
|
||||||
// may end up in a state where they're holding a fractional
|
// may end up in a state where they're holding a fractional
|
||||||
// amount of satoshis which can't be expressed within the
|
// amount of satoshis which can't be expressed within the
|
||||||
// actual commitment output. Since we round down when going
|
// actual commitment output. Since we round down when going
|
||||||
// from mSAT -> SAT, we may at any point be adding an
|
// from mSAT -> SAT, we may at any point be adding an
|
||||||
// additional SAT to miners fees. We'll detect this, and
|
// additional SAT to miners fees. As a result, we display a
|
||||||
// display the proper commitment fee in this case.
|
// commitment fee that accounts for this externally.
|
||||||
externalCommitFee := (dbChannel.Capacity - localBalance.ToSatoshis() -
|
var sumOutputs btcutil.Amount
|
||||||
remoteBalance.ToSatoshis())
|
for _, txOut := range localCommit.CommitTx.TxOut {
|
||||||
if commitFee != externalCommitFee {
|
sumOutputs += btcutil.Amount(txOut.Value)
|
||||||
commitFee = externalCommitFee
|
|
||||||
}
|
}
|
||||||
|
externalCommitFee := dbChannel.Capacity - sumOutputs
|
||||||
|
|
||||||
channel := &lnrpc.ActiveChannel{
|
channel := &lnrpc.ActiveChannel{
|
||||||
Active: peerOnline && linkActive,
|
Active: peerOnline && linkActive,
|
||||||
@ -1507,7 +1506,7 @@ func (r *rpcServer) ListChannels(ctx context.Context,
|
|||||||
Capacity: int64(dbChannel.Capacity),
|
Capacity: int64(dbChannel.Capacity),
|
||||||
LocalBalance: int64(localBalance.ToSatoshis()),
|
LocalBalance: int64(localBalance.ToSatoshis()),
|
||||||
RemoteBalance: int64(remoteBalance.ToSatoshis()),
|
RemoteBalance: int64(remoteBalance.ToSatoshis()),
|
||||||
CommitFee: int64(commitFee),
|
CommitFee: int64(externalCommitFee),
|
||||||
CommitWeight: commitWeight,
|
CommitWeight: commitWeight,
|
||||||
FeePerKw: int64(localCommit.FeePerKw),
|
FeePerKw: int64(localCommit.FeePerKw),
|
||||||
TotalSatoshisSent: int64(dbChannel.TotalMSatSent.ToSatoshis()),
|
TotalSatoshisSent: int64(dbChannel.TotalMSatSent.ToSatoshis()),
|
||||||
|
Loading…
Reference in New Issue
Block a user