Skip to content

signrawtransactionwithwallet JSON-RPC command

signrawtransactionwithwallet "hexstring" ( [{"txid":"hex","vout":n,"scriptPubKey":"hex","redeemScript":"hex","amount":amount,"tokenData":},...] "sighashtype" )

Sign inputs for raw transaction (serialized, hex-encoded).
The second optional argument (may be null) is an array of previous transaction outputs that
this transaction depends on but may not yet be in the block chain.

Arguments

1. "hexstring"                       (string, required) The transaction hex string
2. prevtxs                           (json array, optional) A json array of previous dependent transaction outputs
     [
       {                             (json object)
         "txid": "hex",              (string, required) The transaction id
         "vout": n,                  (numeric, required) The output number
         "scriptPubKey": "hex",      (string, required) script key
         "redeemScript": "hex",      (string, optional) (required for P2SH)
         "amount": amount,           (numeric or string, required) The amount spent
         "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
           },
         },
       },
       ...
     ]
3. "sighashtype"                     (string, optional, default=ALL|FORKID) The signature hash type. Must be one of
                                     "ALL|FORKID"
                                     "NONE|FORKID"
                                     "SINGLE|FORKID"
                                     "ALL|FORKID|ANYONECANPAY"
                                     "NONE|FORKID|ANYONECANPAY"
                                     "SINGLE|FORKID|ANYONECANPAY"
                                     "ALL|FORKID|UTXOS"    (after May 2023 upgrade)
                                     "NONE|FORKID|UTXOS"   (after May 2023 upgrade)
                                     "SINGLE|FORKID|UTXOS" (after May 2023 upgrade)

Result

{
  "hex" : "value",                  (string) The hex-encoded raw transaction with signature(s)
  "complete" : true|false,          (boolean) If the transaction has a complete set of signatures
  "errors" : [                      (json array of objects) Script verification errors (if there are any)
    {
      "txid" : "hash",              (string) The hash of the referenced, previous transaction
      "vout" : n,                   (numeric) The index of the output to spent and used as input
      "scriptSig" : "hex",          (string) The hex-encoded signature script
      "sequence" : n,               (numeric) Script sequence number
      "error" : "text"              (string) Verification or signing error related to the input
    }
    ,...
  ]
}

Examples

> bitcoin-cli signrawtransactionwithwallet "myhex"
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "signrawtransactionwithwallet", "params": ["myhex"] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/

Bitcoin Cash Node Daemon version v27.1.1-1ce1d89

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.