fundrawtransaction
fundrawtransaction "hexstring" ( options iswitness )
If the transaction has no inputs, they will be automatically selected to cover the output value. At most one change output will be added, and no existing outputs will be modified unless “subtractFeeFromOutputs” is specified.
Note that inputs that were signed may need to be re-signed after completion, as inputs/outputs have been added. The newly added inputs will not be signed; use signrawtransactionwithkey
or signrawtransactionwithwallet
to sign them.
All existing inputs must have their previous output transactions available in the wallet. Additionally, all selected inputs must be of a standard form, and P2SH scripts must be in the wallet using importaddress
or addmultisigaddress
(to calculate fees).
You can verify this by checking the “solvable” field in the listunspent
output. Currently, only pay-to-pubkey, multisig, and their P2SH variants are supported for watch-only.
Argument #1 – hexstring
Type: string, required
The hex string of the raw transaction
Argument #2 – options
Type: json object, optional
- For backward compatibility, passing
true
instead of an object will result in{"includeWatching":true}
.
-
Options:
- replaceable: Marks the transaction as BIP125 replaceable, allowing replacement by a transaction with higher fees.
-
conf_target: The target number of blocks for confirmation (default is the wallet’s
-txconfirmtarget
setting). -
estimate_mode: Sets the fee estimate mode, which can be
"unset"
,"economical"
, or"conservative"
.
Argument #3 – iswitness
Type: boolean, optional, default=depends on heuristic tests
-
iswitness:
Specifies whether the transaction hex is a serialized witness transaction. If
iswitness
is not provided, heuristic tests will be used to determine the format:- If true, only witness deserialization will be attempted.
- If false, only non-witness deserialization will be tried.
This boolean should indicate whether the transaction has inputs (e.g., fully valid or on-chain transactions), if known by the caller.
Result
Examples
Create a transaction with no inputs:
Add sufficient unsigned inputs to meet the output value:
Sign the transaction:
Send the transaction: