Page MenuHomePhabricator

[rpc] walletcreatefundedpsbt: allow inputs to be null

Authored by PiRK on Wed, Oct 6, 11:18.


Group Reviewers
Restricted Project
rABC98047924103b: [rpc] walletcreatefundedpsbt: allow inputs to be null

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]

Test Plan

ninja all check-all

Diff Detail

rABC Bitcoin ABC
Lint Not Applicable
Tests Not Applicable