walletrpc+lncli: allow zero output psbt funding

To support the cpfp fee bump use case where no external outputs are
required.
This commit is contained in:
Joost Jager committed 2021-08-16 08:41:50 +02:00
1 parent 5499a35987
commit 925229f9df
3 files changed
+18 -17

No files matched your search

+12 -14
View File
@@ -659,26 +659,24 @@ func fundPsbt(ctx *cli.Context) error {
Psbt: psbtBytes,
}
// The user manually specified outputs and optional inputs in JSON
// The user manually specified outputs and/or inputs in JSON
// format.
case len(ctx.String("outputs")) > 0:
case len(ctx.String("outputs")) > 0 || len(ctx.String("inputs")) > 0:
var (
tpl = &walletrpc.TxTemplate{}
amountToAddr map[string]uint64
)
// Parse the address to amount map as JSON now. At least one
// entry must be present.
jsonMap := []byte(ctx.String("outputs"))
if err := json.Unmarshal(jsonMap, &amountToAddr); err != nil {
return fmt.Errorf("error parsing outputs JSON: %v",
err)
if len(ctx.String("outputs")) > 0 {
// Parse the address to amount map as JSON now. At least one
// entry must be present.
jsonMap := []byte(ctx.String("outputs"))
if err := json.Unmarshal(jsonMap, &amountToAddr); err != nil {
return fmt.Errorf("error parsing outputs JSON: %v",
err)
}
tpl.Outputs = amountToAddr
}
if len(amountToAddr) == 0 {
return fmt.Errorf("at least one output must be " +
"specified")
}
tpl.Outputs = amountToAddr
// Inputs are optional.
if len(ctx.String("inputs")) > 0 {
@@ -707,7 +705,7 @@ func fundPsbt(ctx *cli.Context) error {
default:
return fmt.Errorf("must specify either template_psbt or " +
"outputs flag")
"inputs/outputs flag")
}
// Parse fee flags.