Merge pull request #8097 from markettes/fix-amount-field

Fix amount field
This commit is contained in:
Oliver Gugger authored and GitHub committed 2023-12-04 12:19:07 +01:00
commit ad88396a34
6 files changed
+1731 -1681

No files matched your search

+21 -5
View File
@@ -373,11 +373,31 @@ func sendCoins(ctx *cli.Context) error {
"sweep all coins out of the wallet") "sweep all coins out of the wallet")
} }
client, cleanUp := getClient(ctx)
defer cleanUp()
minConfs := int32(ctx.Uint64("min_confs"))
// In case that the user has specified the sweepall flag, we'll
// calculate the amount to send based on the current wallet balance.
displayAmt := amt
if ctx.Bool("sweepall") {
balanceResponse, err := client.WalletBalance(
ctxc, &lnrpc.WalletBalanceRequest{
MinConfs: minConfs,
},
)
if err != nil {
return fmt.Errorf("unable to retrieve wallet balance:"+
" %w", err)
}
displayAmt = balanceResponse.GetConfirmedBalance()
}
// Ask for confirmation if we're on an actual terminal and the output is // Ask for confirmation if we're on an actual terminal and the output is
// not being redirected to another command. This prevents existing shell // not being redirected to another command. This prevents existing shell
// scripts from breaking. // scripts from breaking.
if !ctx.Bool("force") && term.IsTerminal(int(os.Stdout.Fd())) { if !ctx.Bool("force") && term.IsTerminal(int(os.Stdout.Fd())) {
fmt.Printf("Amount: %d\n", amt) fmt.Printf("Amount: %d\n", displayAmt)
fmt.Printf("Destination address: %v\n", addr) fmt.Printf("Destination address: %v\n", addr)
confirm := promptForConfirmation("Confirm payment (yes/no): ") confirm := promptForConfirmation("Confirm payment (yes/no): ")
@@ -386,10 +406,6 @@ func sendCoins(ctx *cli.Context) error {
} }
} }
client, cleanUp := getClient(ctx)
defer cleanUp()
minConfs := int32(ctx.Uint64("min_confs"))
req := &lnrpc.SendCoinsRequest{ req := &lnrpc.SendCoinsRequest{
Addr: addr, Addr: addr,
Amount: amt, Amount: amt,
@@ -21,6 +21,8 @@
- [Contributors (Alphabetical Order)](#contributors-alphabetical-order) - [Contributors (Alphabetical Order)](#contributors-alphabetical-order)
# Bug Fixes # Bug Fixes
* [Fix a bug](https://github.com/lightningnetwork/lnd/pull/8097) where
`sendcoins` command with `--sweepall` flag would not show the correct amount.
* [Fixed a potential case](https://github.com/lightningnetwork/lnd/pull/7824) * [Fixed a potential case](https://github.com/lightningnetwork/lnd/pull/7824)
that when sweeping inputs with locktime, an unexpected lower fee rate is that when sweeping inputs with locktime, an unexpected lower fee rate is
@@ -104,6 +106,9 @@
error is defined as a routing error found in one of a MPP's HTLC attempts. error is defined as a routing error found in one of a MPP's HTLC attempts.
If, however, there's only one HTLC attempt, when it's failed, this payment is If, however, there's only one HTLC attempt, when it's failed, this payment is
considered failed, thus there's no such thing as temp error for a non-MPP. considered failed, thus there's no such thing as temp error for a non-MPP.
* Support for
[MinConf](https://github.com/lightningnetwork/lnd/pull/8097)(minimum number
of confirmations) has been added to the `WalletBalance` RPC call.
## lncli Updates ## lncli Updates
@@ -167,6 +172,7 @@
* Carla Kirk-Cohen * Carla Kirk-Cohen
* Elle Mouton * Elle Mouton
* Keagan McClelland * Keagan McClelland
* Marcos Fernandez Perez
* Matt Morehouse * Matt Morehouse
* Slyghtning * Slyghtning
* Turtle * Turtle
+1687 -1675
View File
File diff suppressed because it is too large. Load diff
+5
View File
@@ -2847,6 +2847,11 @@ message WalletBalanceRequest {
// The wallet account the balance is shown for. // The wallet account the balance is shown for.
// If this is not specified, the balance of the "default" account is shown. // If this is not specified, the balance of the "default" account is shown.
string account = 1; string account = 1;
// The minimum number of confirmations each one of your outputs used for the
// funding transaction must satisfy. If this is not specified, the default
// value of 1 is used.
int32 min_confs = 2;
} }
message WalletBalanceResponse { message WalletBalanceResponse {
+8
View File
@@ -64,6 +64,14 @@
"in": "query", "in": "query",
"required": false, "required": false,
"type": "string" "type": "string"
},
{
"name": "min_confs",
"description": "The minimum number of confirmations each one of your outputs used for the\nfunding transaction must satisfy. If this is not specified, the default\nvalue of 1 is used.",
"in": "query",
"required": false,
"type": "integer",
"format": "int32"
} }
], ],
"tags": [ "tags": [
+4 -1
View File
@@ -3292,8 +3292,11 @@ func (r *rpcServer) WalletBalance(ctx context.Context,
// Get confirmed balance, from txs that have >= 1 confirmations. // Get confirmed balance, from txs that have >= 1 confirmations.
// TODO(halseth): get both unconfirmed and confirmed balance in // TODO(halseth): get both unconfirmed and confirmed balance in
// one call, as this is racy. // one call, as this is racy.
if in.MinConfs <= 0 {
in.MinConfs = 1
}
confirmedBal, err := r.server.cc.Wallet.ConfirmedBalance( confirmedBal, err := r.server.cc.Wallet.ConfirmedBalance(
1, account.AccountName, in.MinConfs, account.AccountName,
) )
if err != nil { if err != nil {
return nil, err return nil, err