signrawtransactionwithkey

Back to rawtransactions

Changed params/results since v30.2

Summary

Sign inputs for raw transaction (serialized, hex-encoded).

Description

Sign inputs for raw transaction (serialized, hex-encoded). The second argument is an array of private keys that will be the only keys used to sign the transaction. Accepted formats are legacy base58 WIF keys and explicit pqc(KEY) expressions. For pqc(KEY), KEY must be either a hex-encoded raw PQC secret key (64 bytes) or a concrete non-ranged extended private key expression accepted by mr(pk(...)) descriptors. The third 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.

Change Buckets

  • Changed params/results since v30.2

Arguments

  • hexstring (STR, required): The transaction hex string
  • privkeys (ARR, required): Private keys for signing
  • privatekey (STR): Either a legacy WIF private key, or pqc(KEY) where KEY is raw PQC secret key hex (64 bytes) or a concrete extended private key expression
  • prevtxs (ARR): The previous dependent transaction outputs
  • value (OBJ): No description.
    • txid (STR_HEX, required): The transaction id
    • vout (NUM, required): The output number
    • scriptPubKey (STR_HEX, required): output script
    • redeemScript (STR_HEX): (required for P2SH) redeem script
    • witnessScript (STR_HEX): (required for P2WSH or P2SH-P2WSH) witness script
    • p2mrScript (STR_HEX): (required with p2mrControlBlock for P2MR script-path spends) P2MR leaf script
    • p2mrControlBlock (STR_HEX): (required with p2mrScript for P2MR script-path spends) P2MR control block matching scriptPubKey
    • p2mrLeafVersion (NUM): (optional for P2MR script-path spends, defaults to the control block leaf version) leaf version for p2mrScript
    • amount (AMOUNT): (required for Segwit inputs) the amount spent
  • sighashtype (STR): The signature hash type. Must be one of: "DEFAULT" "ALL" "NONE" "SINGLE" "ALL|ANYONECANPAY" "NONE|ANYONECANPAY" "SINGLE|ANYONECANPAY"

Results

  • value (OBJ): No description.
  • hex (STR_HEX): The hex-encoded raw transaction with signature(s)
  • complete (BOOL): If the transaction has a complete set of signatures
  • errors (ARR, optional): Script verification errors (if there are any)
    • value (OBJ): No description.
    • txid (STR_HEX): The hash of the referenced, previous transaction
    • vout (NUM): The index of the output to spent and used as input
    • witness (ARR): No description.
      • witness (STR_HEX): No description.
    • scriptSig (STR_HEX): The hex-encoded signature script
    • sequence (NUM): Script sequence number
    • error (STR): Verification or signing error related to the input

Examples

qbit-cli signrawtransactionwithkey "myhex" "[\"key1\",\"key2\"]"
curl --user myusername --data-binary '{"jsonrpc": "2.0", "id": "curltest", "method": "signrawtransactionwithkey", "params": ["myhex", "[\"key1\",\"key2\"]"]}' -H 'content-type: application/json' http://127.0.0.1:8352/
qbit-cli signrawtransactionwithkey "myhex" "[\"pqc(tprv.../87h/1h/0h/0/0)\"]" "[{\"txid\":\"id\",\"vout\":0,\"scriptPubKey\":\"5220...\",\"amount\":1.0,\"p2mrScript\":\"20...b3\",\"p2mrControlBlock\":\"c1\"}]"