mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-29 03:01:52 +01:00
cmd/lncli: add new --sat_per_kw flag to lncli wallet fundpsbt
This commit is contained in:
parent
fb8bdfefd3
commit
837ff3427c
@ -1160,7 +1160,8 @@ var fundPsbtCommand = cli.Command{
|
|||||||
Name: "fund",
|
Name: "fund",
|
||||||
Usage: "Fund a Partially Signed Bitcoin Transaction (PSBT).",
|
Usage: "Fund a Partially Signed Bitcoin Transaction (PSBT).",
|
||||||
ArgsUsage: "[--template_psbt=T | [--outputs=O [--inputs=I]]] " +
|
ArgsUsage: "[--template_psbt=T | [--outputs=O [--inputs=I]]] " +
|
||||||
"[--conf_target=C | --sat_per_vbyte=S] [--change_type=A]",
|
"[--conf_target=C | --sat_per_vbyte=S | --sat_per_kw=K] " +
|
||||||
|
"[--change_type=A]",
|
||||||
Description: `
|
Description: `
|
||||||
The fund command creates a fully populated PSBT that contains enough
|
The fund command creates a fully populated PSBT that contains enough
|
||||||
inputs to fund the outputs specified in either the PSBT or the
|
inputs to fund the outputs specified in either the PSBT or the
|
||||||
@ -1222,6 +1223,11 @@ var fundPsbtCommand = cli.Command{
|
|||||||
Usage: "a manual fee expressed in sat/vbyte that " +
|
Usage: "a manual fee expressed in sat/vbyte that " +
|
||||||
"should be used when creating the transaction",
|
"should be used when creating the transaction",
|
||||||
},
|
},
|
||||||
|
cli.Uint64Flag{
|
||||||
|
Name: "sat_per_kw",
|
||||||
|
Usage: "a manual fee expressed in sat/kw that " +
|
||||||
|
"should be used when creating the transaction",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "account",
|
Name: "account",
|
||||||
Usage: "(optional) the name of the account to use to " +
|
Usage: "(optional) the name of the account to use to " +
|
||||||
@ -1302,10 +1308,11 @@ func fundPsbt(ctx *cli.Context) error {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if len(ctx.String("outputs")) > 0 {
|
if len(ctx.String("outputs")) > 0 {
|
||||||
// Parse the address to amount map as JSON now. At least one
|
// Parse the address to amount map as JSON now. At least
|
||||||
// entry must be present.
|
// one entry must be present.
|
||||||
jsonMap := []byte(ctx.String("outputs"))
|
jsonMap := []byte(ctx.String("outputs"))
|
||||||
if err := json.Unmarshal(jsonMap, &amountToAddr); err != nil {
|
err := json.Unmarshal(jsonMap, &amountToAddr)
|
||||||
|
if err != nil {
|
||||||
return fmt.Errorf("error parsing outputs "+
|
return fmt.Errorf("error parsing outputs "+
|
||||||
"JSON: %w", err)
|
"JSON: %w", err)
|
||||||
}
|
}
|
||||||
@ -1317,7 +1324,8 @@ func fundPsbt(ctx *cli.Context) error {
|
|||||||
var inputs []string
|
var inputs []string
|
||||||
|
|
||||||
jsonList := []byte(ctx.String("inputs"))
|
jsonList := []byte(ctx.String("inputs"))
|
||||||
if err := json.Unmarshal(jsonList, &inputs); err != nil {
|
err := json.Unmarshal(jsonList, &inputs)
|
||||||
|
if err != nil {
|
||||||
return fmt.Errorf("error parsing inputs JSON: "+
|
return fmt.Errorf("error parsing inputs JSON: "+
|
||||||
"%v", err)
|
"%v", err)
|
||||||
}
|
}
|
||||||
@ -1344,15 +1352,23 @@ func fundPsbt(ctx *cli.Context) error {
|
|||||||
|
|
||||||
// Parse fee flags.
|
// Parse fee flags.
|
||||||
switch {
|
switch {
|
||||||
case ctx.IsSet("conf_target") && ctx.IsSet("sat_per_vbyte"):
|
case ctx.IsSet("conf_target") && ctx.IsSet("sat_per_vbyte") ||
|
||||||
return fmt.Errorf("cannot set conf_target and sat_per_vbyte " +
|
ctx.IsSet("conf_target") && ctx.IsSet("sat_per_kw") ||
|
||||||
"at the same time")
|
ctx.IsSet("sat_per_vbyte") && ctx.IsSet("sat_per_kw"):
|
||||||
|
|
||||||
|
return fmt.Errorf("only one of conf_target, sat_per_vbyte, " +
|
||||||
|
"or sat_per_kw can be set at the same time")
|
||||||
|
|
||||||
case ctx.Uint64("sat_per_vbyte") > 0:
|
case ctx.Uint64("sat_per_vbyte") > 0:
|
||||||
req.Fees = &walletrpc.FundPsbtRequest_SatPerVbyte{
|
req.Fees = &walletrpc.FundPsbtRequest_SatPerVbyte{
|
||||||
SatPerVbyte: ctx.Uint64("sat_per_vbyte"),
|
SatPerVbyte: ctx.Uint64("sat_per_vbyte"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ctx.Uint64("sat_per_kw") > 0:
|
||||||
|
req.Fees = &walletrpc.FundPsbtRequest_SatPerKw{
|
||||||
|
SatPerKw: ctx.Uint64("sat_per_kw"),
|
||||||
|
}
|
||||||
|
|
||||||
// Check conf_target last because it has a default value.
|
// Check conf_target last because it has a default value.
|
||||||
case ctx.Uint64("conf_target") > 0:
|
case ctx.Uint64("conf_target") > 0:
|
||||||
req.Fees = &walletrpc.FundPsbtRequest_TargetConf{
|
req.Fees = &walletrpc.FundPsbtRequest_TargetConf{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user