Merge pull request #7857 from hieblmi/wallet-balance-account
lnrpc: adding account name to the `WalletBalance` rpc
This commit is contained in:
7 files changed
+1687
-1632
No files matched your search
+12
-2
@@ -1314,7 +1314,15 @@ var walletBalanceCommand = cli.Command{
|
|||||||
Name: "walletbalance",
|
Name: "walletbalance",
|
||||||
Category: "Wallet",
|
Category: "Wallet",
|
||||||
Usage: "Compute and display the wallet's current balance.",
|
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 {
|
func walletBalance(ctx *cli.Context) error {
|
||||||
@@ -1322,7 +1330,9 @@ func walletBalance(ctx *cli.Context) error {
|
|||||||
client, cleanUp := getClient(ctx)
|
client, cleanUp := getClient(ctx)
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
req := &lnrpc.WalletBalanceRequest{}
|
req := &lnrpc.WalletBalanceRequest{
|
||||||
|
Account: ctx.String("account"),
|
||||||
|
}
|
||||||
resp, err := client.WalletBalance(ctxc, req)
|
resp, err := client.WalletBalance(ctxc, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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,
|
message now supports all fields that are present in the `OpenChannel` message,
|
||||||
except for the `funding_shim` and `fundmax` fields.
|
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
|
## Misc
|
||||||
|
|
||||||
* [Generate default macaroons
|
* [Generate default macaroons
|
||||||
|
|||||||
+1641
-1629
File diff suppressed because it is too large.
Load diff
@@ -31,10 +31,21 @@ var _ = runtime.String
|
|||||||
var _ = utilities.NewDoubleArray
|
var _ = utilities.NewDoubleArray
|
||||||
var _ = metadata.Join
|
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) {
|
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 protoReq WalletBalanceRequest
|
||||||
var metadata runtime.ServerMetadata
|
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))
|
msg, err := client.WalletBalance(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
|
|
||||||
@@ -44,6 +55,13 @@ func local_request_Lightning_WalletBalance_0(ctx context.Context, marshaler runt
|
|||||||
var protoReq WalletBalanceRequest
|
var protoReq WalletBalanceRequest
|
||||||
var metadata runtime.ServerMetadata
|
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)
|
msg, err := server.WalletBalance(ctx, &protoReq)
|
||||||
return msg, metadata, err
|
return msg, metadata, err
|
||||||
|
|
||||||
|
|||||||
@@ -2828,6 +2828,9 @@ message WalletAccountBalance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message WalletBalanceRequest {
|
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 {
|
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": [
|
"tags": [
|
||||||
"Lightning"
|
"Lightning"
|
||||||
]
|
]
|
||||||
|
|||||||
+1
-1
@@ -3194,7 +3194,7 @@ func (r *rpcServer) WalletBalance(ctx context.Context,
|
|||||||
|
|
||||||
// Retrieve all existing wallet accounts. We'll compute the confirmed
|
// Retrieve all existing wallet accounts. We'll compute the confirmed
|
||||||
// and unconfirmed balance for each and tally them up.
|
// 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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user