mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-03 22:53:32 +02:00
lncli: Add outpoints
flag to sendcoins command
Signed-off-by: Ononiwu Maureen <59079323+Chinwendu20@users.noreply.github.com>
This commit is contained in:
committed by
yyforyongyu
parent
900d7fdd17
commit
018484628a
@@ -288,10 +288,11 @@ var sendCoinsCommand = cli.Command{
|
|||||||
},
|
},
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "sweepall",
|
Name: "sweepall",
|
||||||
Usage: "if set, then the amount field will be ignored, " +
|
Usage: "if set, then the amount field should be " +
|
||||||
"and the wallet will attempt to sweep all " +
|
"unset. This indicates that the wallet will " +
|
||||||
"outputs within the wallet to the target " +
|
"attempt to sweep all outputs within the " +
|
||||||
"address",
|
"wallet or all funds in select utxos (when " +
|
||||||
|
"supplied) to the target address",
|
||||||
},
|
},
|
||||||
cli.Int64Flag{
|
cli.Int64Flag{
|
||||||
Name: "amt",
|
Name: "amt",
|
||||||
@@ -330,6 +331,17 @@ var sendCoinsCommand = cli.Command{
|
|||||||
"scripts",
|
"scripts",
|
||||||
},
|
},
|
||||||
coinSelectionStrategyFlag,
|
coinSelectionStrategyFlag,
|
||||||
|
cli.StringSliceFlag{
|
||||||
|
Name: "utxo",
|
||||||
|
Usage: "a utxo specified as outpoint(tx:idx) which " +
|
||||||
|
"will be used as input for the transaction. " +
|
||||||
|
"This flag can be repeatedly used to specify " +
|
||||||
|
"multiple utxos as inputs. The selected " +
|
||||||
|
"utxos can either be entirely spent by " +
|
||||||
|
"specifying the sweepall flag or a specified " +
|
||||||
|
"amount can be spent in the utxos through " +
|
||||||
|
"the amt flag",
|
||||||
|
},
|
||||||
txLabelFlag,
|
txLabelFlag,
|
||||||
},
|
},
|
||||||
Action: actionDecorator(sendCoins),
|
Action: actionDecorator(sendCoins),
|
||||||
@@ -337,9 +349,10 @@ var sendCoinsCommand = cli.Command{
|
|||||||
|
|
||||||
func sendCoins(ctx *cli.Context) error {
|
func sendCoins(ctx *cli.Context) error {
|
||||||
var (
|
var (
|
||||||
addr string
|
addr string
|
||||||
amt int64
|
amt int64
|
||||||
err error
|
err error
|
||||||
|
outpoints []*lnrpc.OutPoint
|
||||||
)
|
)
|
||||||
ctxc := getContext()
|
ctxc := getContext()
|
||||||
args := ctx.Args()
|
args := ctx.Args()
|
||||||
@@ -417,6 +430,15 @@ func sendCoins(ctx *cli.Context) error {
|
|||||||
displayAmt = balanceResponse.GetConfirmedBalance()
|
displayAmt = balanceResponse.GetConfirmedBalance()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ctx.IsSet("utxo") {
|
||||||
|
utxos := ctx.StringSlice("utxo")
|
||||||
|
|
||||||
|
outpoints, err = UtxosToOutpoints(utxos)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to decode utxos: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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.
|
||||||
@@ -440,6 +462,7 @@ func sendCoins(ctx *cli.Context) error {
|
|||||||
MinConfs: minConfs,
|
MinConfs: minConfs,
|
||||||
SpendUnconfirmed: minConfs == 0,
|
SpendUnconfirmed: minConfs == 0,
|
||||||
CoinSelectionStrategy: coinSelectionStrategy,
|
CoinSelectionStrategy: coinSelectionStrategy,
|
||||||
|
Outpoints: outpoints,
|
||||||
}
|
}
|
||||||
txid, err := client.SendCoins(ctxc, req)
|
txid, err := client.SendCoins(ctxc, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Reference in New Issue
Block a user