Skip to content

walletcreatefundedpsbt JSON-RPC command

walletcreatefundedpsbt [{"txid":"hex","vout":n,"sequence":n},...] [{"address":amount},{"address":},{"data":"hex"},...] ( locktime options bip32derivs )

Creates and funds a transaction in the Partially Signed Transaction format. Inputs will be added if supplied inputs are not enough
Implements the Creator and Updater roles.

Arguments

1. inputs                              (json array, required) A json array of json objects
     [
       {                               (json object)
         "txid": "hex",                (string, required) The transaction id
         "vout": n,                    (numeric, required) The output number
         "sequence": n,                (numeric, required) The sequence number
       },
       ...
     ]
2. outputs                             (json array, required) a json array with outputs (key-value pairs).For compatibility reasons, a dictionary, which holds the key-value pairs directly, is also
                                       accepted as second parameter.
     [
       {                               (json object)
         "address": amount,            (numeric or string, optional) A key-value pair. The key (string) is the Bitcoin Cash address, the value (float or string) is the amount in BCH
       },
       {                               (json object)
         "address": {                  (json object, required) A key-value pair. The key (string) is the Bitcoin Cash address, the value is a JSON object
           "amount": amount,           (numeric or string, required) The amount in BCH
           "tokenData": {              (json object, optional) Optional CashToken data to add to this output
             "category": "hex",        (string, required) The token id
             "amount": n,              (numeric, optional) The token fungible amount, use JSON strings for >53-bit amounts
             "nft": {                  (json object, optional) NFT data for the token
               "capability": "str",    (string, optional) One of "none", "mutable", "minting"
               "commitment": "hex",    (string, optional) The token NFT commitment
             },
           },
         },
       },
       {                               (json object)
         "data": "hex",                (string, optional) A key-value pair. The key must be "data", the value is a hex-encoded data string or an array of hex-encoded data strings (each item yields a separate data push)
       },
       ...
     ]
3. locktime                            (numeric, optional, default=0) Raw locktime. Non-0 value also locktime-activates inputs
                                       Allows this transaction to be replaced by a transaction with higher fees. If provided, it is an error if explicit sequence numbers are incompatible.
4. options                             (json object, optional)
     {
       "include_unsafe": bool,         (boolean, optional, default=false) Include inputs that are not safe to spend (unconfirmed transactions from outside keys).
                                       Warning: the resulting transaction may become invalid if one of the unsafe inputs disappears.
                                       If that happens, you will need to fund the transaction with different inputs and republish it.
       "changeAddress": "hex",         (string, optional, default=pool address) The Bitcoin Cash address to receive the change
       "changePosition": n,            (numeric, optional, default=random) The index of the change output
       "includeWatching": bool,        (boolean, optional, default=false) Also select inputs which are watch only
       "lockUnspents": bool,           (boolean, optional, default=false) Lock selected unspent outputs
       "feeRate": amount,              (numeric or string, optional, default=not set: makes wallet determine the fee) Set a specific fee rate in BCH/kB
       "subtractFeeFromOutputs": [     (json array, optional) A json array of integers.
                                       The fee will be equally deducted from the amount of each specified output.
                                       The outputs are specified by their zero-based index, before any change output is added.
                                       Those recipients will receive less bitcoins than you enter in their corresponding amount field.
                                       If no outputs are specified here, the sender pays the fee.
         vout_index,                   (numeric)
         ...
       ],
     }
5. bip32derivs                         (boolean, optional, default=false) If true, includes the BIP 32 derivation paths for public keys if we know them

Result

{
  "psbt": "value",        (string)  The resulting raw transaction (base64-encoded string)
  "fee":       n,         (numeric) Fee in BCH the resulting transaction pays
  "changepos": n          (numeric) The position of the added change output, or -1
}

Examples

Create a transaction with no inputs
> bitcoin-cli walletcreatefundedpsbt "[{\"txid\":\"myid\",\"vout\":0}]" "[{\"data\":\"00010203\"}]"

Bitcoin Cash Node Daemon version v27.0.1-6a03070

Documentation on docs.bitcoincashnode.org reflects the current master branch in Git, and may include API changes that are not yet present in the latest release.