mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-30 04:32:33 +02:00
Merge pull request #7857 from hieblmi/wallet-balance-account
lnrpc: adding account name to the `WalletBalance` rpc
This commit is contained in:
commit
d62bed22a3
@ -1314,7 +1314,15 @@ var walletBalanceCommand = cli.Command{
|
||||
Name: "walletbalance",
|
||||
Category: "Wallet",
|
||||
Usage: "Compute and display the wallet's current balance.",
|
||||
Action: actionDecorator(walletBalance),
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "account",
|
||||
Usage: "(optional) the account for which the balance " +
|
||||
"is shown",
|
||||
Value: "",
|
||||
},
|
||||
},
|
||||
Action: actionDecorator(walletBalance),
|
||||
}
|
||||
|
||||
func walletBalance(ctx *cli.Context) error {
|
||||
@ -1322,7 +1330,9 @@ func walletBalance(ctx *cli.Context) error {
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
req := &lnrpc.WalletBalanceRequest{}
|
||||
req := &lnrpc.WalletBalanceRequest{
|
||||
Account: ctx.String("account"),
|
||||
}
|
||||
resp, err := client.WalletBalance(ctxc, req)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -120,6 +120,9 @@ on the old value of 10000](https://github.com/lightningnetwork/lnd/pull/7780).
|
||||
message now supports all fields that are present in the `OpenChannel` message,
|
||||
except for the `funding_shim` and `fundmax` fields.
|
||||
|
||||
* The [WalletBalance](https://github.com/lightningnetwork/lnd/pull/7857) RPC
|
||||
(lncli walletbalance) now supports showing the balance for a specific account.
|
||||
|
||||
## Misc
|
||||
|
||||
* [Generate default macaroons
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -31,10 +31,21 @@ var _ = runtime.String
|
||||
var _ = utilities.NewDoubleArray
|
||||
var _ = metadata.Join
|
||||
|
||||
var (
|
||||
filter_Lightning_WalletBalance_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
||||
)
|
||||
|
||||
func request_Lightning_WalletBalance_0(ctx context.Context, marshaler runtime.Marshaler, client LightningClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq WalletBalanceRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Lightning_WalletBalance_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := client.WalletBalance(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
@ -44,6 +55,13 @@ func local_request_Lightning_WalletBalance_0(ctx context.Context, marshaler runt
|
||||
var protoReq WalletBalanceRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
if err := req.ParseForm(); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Lightning_WalletBalance_0); err != nil {
|
||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
||||
}
|
||||
|
||||
msg, err := server.WalletBalance(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
|
@ -2828,6 +2828,9 @@ message WalletAccountBalance {
|
||||
}
|
||||
|
||||
message WalletBalanceRequest {
|
||||
// The wallet account the balance is shown for.
|
||||
// If this is not specified, the balance of the "default" account is shown.
|
||||
string account = 1;
|
||||
}
|
||||
|
||||
message WalletBalanceResponse {
|
||||
|
@ -57,6 +57,15 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"parameters": [
|
||||
{
|
||||
"name": "account",
|
||||
"description": "The wallet account the balance is shown for.\nIf this is not specified, the balance of the \"default\" account is shown.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
"Lightning"
|
||||
]
|
||||
|
@ -3194,7 +3194,7 @@ func (r *rpcServer) WalletBalance(ctx context.Context,
|
||||
|
||||
// Retrieve all existing wallet accounts. We'll compute the confirmed
|
||||
// and unconfirmed balance for each and tally them up.
|
||||
accounts, err := r.server.cc.Wallet.ListAccounts("", nil)
|
||||
accounts, err := r.server.cc.Wallet.ListAccounts(in.Account, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user