lnrpc+lnd: adds required reserve in walletbalance rpc
This commit is contained in:
1 parent
150c0b5de8
commit
8578433b3d
4 files changed
+1569
-1536
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.
|
// other usage.
|
||||||
int64 locked_balance = 5;
|
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.
|
// A mapping of each wallet account's name to its balance.
|
||||||
map<string, WalletAccountBalance> account_balance = 4;
|
map<string, WalletAccountBalance> account_balance = 4;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6646,6 +6646,11 @@
|
|||||||
"format": "int64",
|
"format": "int64",
|
||||||
"description": "The total amount of wallet UTXOs held in outputs that are locked for\nother usage."
|
"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": {
|
"account_balance": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": {
|
"additionalProperties": {
|
||||||
|
|||||||
@@ -3136,6 +3136,17 @@ func (r *rpcServer) WalletBalance(ctx context.Context,
|
|||||||
lockedBalance += utxoInfo.Value
|
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, "+
|
rpcsLog.Debugf("[walletbalance] Total balance=%v (confirmed=%v, "+
|
||||||
"unconfirmed=%v)", totalBalance, confirmedBalance,
|
"unconfirmed=%v)", totalBalance, confirmedBalance,
|
||||||
unconfirmedBalance)
|
unconfirmedBalance)
|
||||||
@@ -3145,6 +3156,7 @@ func (r *rpcServer) WalletBalance(ctx context.Context,
|
|||||||
ConfirmedBalance: int64(confirmedBalance),
|
ConfirmedBalance: int64(confirmedBalance),
|
||||||
UnconfirmedBalance: int64(unconfirmedBalance),
|
UnconfirmedBalance: int64(unconfirmedBalance),
|
||||||
LockedBalance: int64(lockedBalance),
|
LockedBalance: int64(lockedBalance),
|
||||||
|
ReservedBalanceAnchorChan: int64(requiredReserve),
|
||||||
AccountBalance: rpcAccountBalances,
|
AccountBalance: rpcAccountBalances,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user