比特币(Bitcoin) RPC Wallet API中signrawtransactionwithwallet的用法及代码示例。
用法:
signrawtransactionwithwallet "hexstring" ( [{"txid":"hex","vout":n,"scriptPubKey":"hex","redeemScript":"hex","witnessScript":"hex","amount":amount},...] "sighashtype" )
签署原始交易的输入(序列化,hex-encoded)。
第二个可选参数(可以为null)是此事务所依赖的先前事务输出的数组,但可能不在区块链中。
参数1 - hexstring
类型:字符串,必填
交易十六进制字符串
参数2 - prevtxs
类型:json数组,可选
先前相关交易输出的json数组
[
{ (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) (required for P2SH) redeem script
"witnessScript": "hex", (string) (required for P2WSH or P2SH-P2WSH) witness script
"amount": amount, (numeric or string, required) The amount spent
},
...
]
参数3 - sighashtype
类型:字符串,可选,默认= ALL
- 签名哈希类型。必须是以下之一
“ALL” “NONE” “SINGLE” “ALL|ANYONECANPAY” “NONE|ANYONECANPAY” “SINGLE|ANYONECANPAY”
返回结果
{
"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
}
,...
]
}
示例
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 abandontransaction用法及代码示例
- Bitcoin abortrescan用法及代码示例
- Bitcoin addmultisigaddress用法及代码示例
- Bitcoin backupwallet用法及代码示例
- Bitcoin bumpfee用法及代码示例
- Bitcoin createwallet用法及代码示例
- Bitcoin dumpprivkey用法及代码示例
- Bitcoin dumpwallet用法及代码示例
- Bitcoin encryptwallet用法及代码示例
- Bitcoin getaddressesbylabel用法及代码示例
- Bitcoin getaddressinfo用法及代码示例
- Bitcoin getbalance用法及代码示例
- Bitcoin getnewaddress用法及代码示例
- Bitcoin getrawchangeaddress用法及代码示例
- Bitcoin getreceivedbyaddress用法及代码示例
- Bitcoin getreceivedbylabel用法及代码示例
- Bitcoin gettransaction用法及代码示例
- Bitcoin getwalletinfo用法及代码示例
- Bitcoin importaddress用法及代码示例
- Bitcoin importmulti用法及代码示例
- Bitcoin importprivkey用法及代码示例
- Bitcoin importpubkey用法及代码示例
- Bitcoin importwallet用法及代码示例
- Bitcoin keypoolrefill用法及代码示例
- Bitcoin listaddressgroupings用法及代码示例
注:本文由纯净天空筛选整理自bitcoin.org大神的英文原创作品 Bitcoin signrawtransactionwithwallet。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。