HomePhabricator

[rpc] walletcreatefundedpsbt: allow inputs to be null

Description

[rpc] walletcreatefundedpsbt: allow inputs to be null

Summary:
This is of neglible use here, but it allows new RPC methods to take outputs as their first argument and make inputs optional.

PR description:

walletcreatefundedpsbt has some interesting features that sendtoaddress and sendmany don't have:

  • manual coin selection
  • outputting a PSBT
  • create a transaction without adding to wallet (which leads to broadcasting, unless -walletbroadcast=0)

At the same time walletcreatefundedpsbt can't broadcast a transaction, which is inconvenient for simple use cases.

This PR introduces a new send RPC method which creates a PSBT, signs it if possible and adds it to the wallet by default. If it can't sign all inputs, it outputs a PSBT. If add_to_wallet is set to false it will return the transaction in both PSBT and hex format.

Because it uses a PSBT internally, it will much easier to add hardware wallet support to this method (see #16546).

For bitcoin-cli users, it tries to keep the simplest use case easy to use:

`bitcoin-cli -regtest send '{"ADDRESS": 0.1}' `

This paves the way for deprecating sendtoaddress and sendmany though there's no rush. The only missing feature compared to these older methods is adding labels to a destination address.

This is a backport of core#16378 [1/3]
https://github.com/bitcoin/bitcoin/pull/16378/commits/1bc8d0fd5906bc9637d513cd193a1f47ad94da28

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D10263

Details

Provenance
Sjors Provoost <sjors@sprovoost.nl>Authored on Jul 11 2019, 17:50
PiRKCommitted on Oct 7 2021, 12:57
PiRKPushed on Oct 7 2021, 12:57
Reviewer
Restricted Project
Differential Revision
D10263: [rpc] walletcreatefundedpsbt: allow inputs to be null
Parents
rABC8a0c123c2d0b: [avalanche] Split the poll_and_response test in two
Branches
Unknown
Tags
Unknown