Page MenuHomePhabricator

[rpc] walletcreatefundedpsbt: allow inputs to be null
ClosedPublic

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

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC98047924103b: [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

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable