lnrpc+lnd: adds required reserve in walletbalance rpc
This commit is contained in:
1 parent
150c0b5de8
commit
8578433b3d
4 files changed
+1574
-1541
No files matched your search
+1549
-1536
File diff suppressed because it is too large.
Load diff
@@ -2567,6 +2567,9 @@ message WalletBalanceResponse {
|
||||
// other usage.
|
||||
int64 locked_balance = 5;
|
||||
|
||||
// The amount of reserve required.
|
||||
int64 reserved_balance_anchor_chan = 6;
|
||||
|
||||
// A mapping of each wallet account's name to its balance.
|
||||
map<string, WalletAccountBalance> account_balance = 4;
|
||||
}
|
||||
|
||||
@@ -6646,6 +6646,11 @@
|
||||
"format": "int64",
|
||||
"description": "The total amount of wallet UTXOs held in outputs that are locked for\nother usage."
|
||||
},
|
||||
"reserved_balance_anchor_chan": {
|
||||
"type": "string",
|
||||
"format": "int64",
|
||||
"description": "The amount of reserve required."
|
||||
},
|
||||
"account_balance": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
|
||||
+17
-5
@@ -3136,16 +3136,28 @@ func (r *rpcServer) WalletBalance(ctx context.Context,
|
||||
lockedBalance += utxoInfo.Value
|
||||
}
|
||||
|
||||
// Get the current number of non-private anchor channels.
|
||||
currentNumAnchorChans, err := r.server.cc.Wallet.CurrentNumAnchorChans()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Get the required reserve for the wallet.
|
||||
requiredReserve := r.server.cc.Wallet.RequiredReserve(
|
||||
uint32(currentNumAnchorChans),
|
||||
)
|
||||
|
||||
rpcsLog.Debugf("[walletbalance] Total balance=%v (confirmed=%v, "+
|
||||
"unconfirmed=%v)", totalBalance, confirmedBalance,
|
||||
unconfirmedBalance)
|
||||
|
||||
return &lnrpc.WalletBalanceResponse{
|
||||
TotalBalance: int64(totalBalance),
|
||||
ConfirmedBalance: int64(confirmedBalance),
|
||||
UnconfirmedBalance: int64(unconfirmedBalance),
|
||||
LockedBalance: int64(lockedBalance),
|
||||
AccountBalance: rpcAccountBalances,
|
||||
TotalBalance: int64(totalBalance),
|
||||
ConfirmedBalance: int64(confirmedBalance),
|
||||
UnconfirmedBalance: int64(unconfirmedBalance),
|
||||
LockedBalance: int64(lockedBalance),
|
||||
ReservedBalanceAnchorChan: int64(requiredReserve),
|
||||
AccountBalance: rpcAccountBalances,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user