mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-09 18:52:09 +02:00
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:
@@ -659,26 +659,24 @@ func fundPsbt(ctx *cli.Context) error {
|
|||||||
Psbt: psbtBytes,
|
Psbt: psbtBytes,
|
||||||
}
|
}
|
||||||
|
|
||||||
// The user manually specified outputs and optional inputs in JSON
|
// The user manually specified outputs and/or inputs in JSON
|
||||||
// format.
|
// format.
|
||||||
case len(ctx.String("outputs")) > 0:
|
case len(ctx.String("outputs")) > 0 || len(ctx.String("inputs")) > 0:
|
||||||
var (
|
var (
|
||||||
tpl = &walletrpc.TxTemplate{}
|
tpl = &walletrpc.TxTemplate{}
|
||||||
amountToAddr map[string]uint64
|
amountToAddr map[string]uint64
|
||||||
)
|
)
|
||||||
|
|
||||||
// Parse the address to amount map as JSON now. At least one
|
if len(ctx.String("outputs")) > 0 {
|
||||||
// entry must be present.
|
// Parse the address to amount map as JSON now. At least one
|
||||||
jsonMap := []byte(ctx.String("outputs"))
|
// entry must be present.
|
||||||
if err := json.Unmarshal(jsonMap, &amountToAddr); err != nil {
|
jsonMap := []byte(ctx.String("outputs"))
|
||||||
return fmt.Errorf("error parsing outputs JSON: %v",
|
if err := json.Unmarshal(jsonMap, &amountToAddr); err != nil {
|
||||||
err)
|
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.
|
// Inputs are optional.
|
||||||
if len(ctx.String("inputs")) > 0 {
|
if len(ctx.String("inputs")) > 0 {
|
||||||
@@ -707,7 +705,7 @@ func fundPsbt(ctx *cli.Context) error {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("must specify either template_psbt or " +
|
return fmt.Errorf("must specify either template_psbt or " +
|
||||||
"outputs flag")
|
"inputs/outputs flag")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse fee flags.
|
// Parse fee flags.
|
||||||
|
@@ -25,6 +25,12 @@ for more information.
|
|||||||
* [Stub code for interacting with `lnrpc` from a WASM context through JSON
|
* [Stub code for interacting with `lnrpc` from a WASM context through JSON
|
||||||
messages was added](https://github.com/lightningnetwork/lnd/pull/5601).
|
messages was added](https://github.com/lightningnetwork/lnd/pull/5601).
|
||||||
|
|
||||||
|
## Wallet
|
||||||
|
|
||||||
|
* It is now possible to fund a psbt [without specifying any
|
||||||
|
outputs](https://github.com/lightningnetwork/lnd/pull/5442). This option is
|
||||||
|
useful for CPFP bumping of unconfirmed outputs or general utxo consolidation.
|
||||||
|
|
||||||
## Security
|
## Security
|
||||||
|
|
||||||
### Admin macaroon permissions
|
### Admin macaroon permissions
|
||||||
|
@@ -996,9 +996,6 @@ func (w *WalletKit) FundPsbt(_ context.Context,
|
|||||||
// PSBT and copy the RPC information over.
|
// PSBT and copy the RPC information over.
|
||||||
case req.GetRaw() != nil:
|
case req.GetRaw() != nil:
|
||||||
tpl := req.GetRaw()
|
tpl := req.GetRaw()
|
||||||
if len(tpl.Outputs) == 0 {
|
|
||||||
return nil, fmt.Errorf("no outputs specified")
|
|
||||||
}
|
|
||||||
|
|
||||||
txOut := make([]*wire.TxOut, 0, len(tpl.Outputs))
|
txOut := make([]*wire.TxOut, 0, len(tpl.Outputs))
|
||||||
for addrStr, amt := range tpl.Outputs {
|
for addrStr, amt := range tpl.Outputs {
|
||||||
|
Reference in New Issue
Block a user