mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-23 23:31:02 +02:00
Merge branch '0-18-5-branch-rc1-9226' into 0-18-5-branch-rc1
This commit is contained in:
commit
3909cd96e5
@ -461,7 +461,7 @@ func sendCoins(ctx *cli.Context) error {
|
|||||||
// In case that the user has specified the sweepall flag, we'll
|
// In case that the user has specified the sweepall flag, we'll
|
||||||
// calculate the amount to send based on the current wallet balance.
|
// calculate the amount to send based on the current wallet balance.
|
||||||
displayAmt := amt
|
displayAmt := amt
|
||||||
if ctx.Bool("sweepall") {
|
if ctx.Bool("sweepall") && !ctx.IsSet("utxo") {
|
||||||
balanceResponse, err := client.WalletBalance(
|
balanceResponse, err := client.WalletBalance(
|
||||||
ctxc, &lnrpc.WalletBalanceRequest{
|
ctxc, &lnrpc.WalletBalanceRequest{
|
||||||
MinConfs: minConfs,
|
MinConfs: minConfs,
|
||||||
@ -481,6 +481,32 @@ func sendCoins(ctx *cli.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("unable to decode utxos: %w", err)
|
return fmt.Errorf("unable to decode utxos: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.Bool("sweepall") {
|
||||||
|
displayAmt = 0
|
||||||
|
// If we're sweeping all funds of the utxos, we'll need
|
||||||
|
// to set the display amount to the total amount of the
|
||||||
|
// utxos.
|
||||||
|
unspents, err := client.ListUnspent(
|
||||||
|
ctxc, &lnrpc.ListUnspentRequest{
|
||||||
|
MinConfs: 0,
|
||||||
|
MaxConfs: math.MaxInt32,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, utxo := range outpoints {
|
||||||
|
for _, unspent := range unspents.Utxos {
|
||||||
|
unspentUtxo := unspent.Outpoint
|
||||||
|
if isSameOutpoint(utxo, unspentUtxo) {
|
||||||
|
displayAmt += unspent.AmountSat
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
@ -517,6 +543,10 @@ func sendCoins(ctx *cli.Context) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isSameOutpoint(a, b *lnrpc.OutPoint) bool {
|
||||||
|
return a.TxidStr == b.TxidStr && a.OutputIndex == b.OutputIndex
|
||||||
|
}
|
||||||
|
|
||||||
var listUnspentCommand = cli.Command{
|
var listUnspentCommand = cli.Command{
|
||||||
Name: "listunspent",
|
Name: "listunspent",
|
||||||
Category: "On-chain",
|
Category: "On-chain",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user