比特幣(Bitcoin) RPC Wallet API中walletcreatefundedpsbt的用法及代碼示例。
用法:
walletcreatefundedpsbt [{"txid":"hex","vout":n,"sequence":n},...] [{"address":amount},{"data":"hex"},...] ( locktime options bip32derivs )
以“部分簽名的交易”格式創建交易並為其提供資金。如果提供的輸入不夠,將添加輸入。實現創建者和更新者角色。
參數1 - inputs
類型:json數組,必需
json對象的json數組
[
{ (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數組,必需
- 一個具有輸出(鍵-值對)的json數組,其中沒有重複的鍵。
也就是說,每個地址隻能出現一次,並且隻能有一個‘data’對象。出於兼容性原因,也可以將直接保存鍵值對的字典作為第二個參數。
[
{ (json object)
"address": amount, (numeric or string, required) A key-value pair. The key (string) is the bitcoin address, the value (float or string) is the amount in BTC
},
{ (json object)
"data": "hex", (string, required) A key-value pair. The key must be "data", the value is hex-encoded data
},
...
]
參數3 - locktime
類型:數字,可選,默認值= 0
原始鎖定時間。非0值也為locktime-activates輸入
參數4 - options
類型:json對象,可選
- “replaceable”:bool,(布爾值,可選,默認值= false)將此交易標記為BIP125可替換。
允許將此交易替換為費用較高的交易“conf_target”:n,(數字,可選,默認=退回至錢包的確認目標)確認目標(以塊為單位)“estimate_mode”:“str”,(字符串,可選,默認= UNSET)費用估計模式,必須為以下之一:“UNSET” “ECONOMICAL” “CONSERVATIVE”}
{
"changeAddress": "hex", (string, optional, default=pool address) The bitcoin address to receive the change
"changePosition": n, (numeric, optional, default=random) The index of the change output
"change_type": "str", (string, optional, default=set by -changetype) The output type to use. Only valid if changeAddress is not specified. Options are "legacy", "p2sh-segwit", and "bech32".
"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 BTC/kB
"subtractFeeFromOutputs": [ (json array, optional, default=empty array) A json array of integers.
The fee will be equally deducted from the amount of each specified output.
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) The zero-based output index, before a change output is added.
...
],
參數5 - bip32derivs
類型:布爾值,可選,默認= false
如果為true,則在知道公鑰的情況下包括公鑰的BIP 32派生路徑
返回結果
{
"psbt": "value", (string) The resulting raw transaction (base64-encoded string)
"fee": n, (numeric) Fee in BTC the resulting transaction pays
"changepos": n (numeric) The position of the added change output, or -1
}
示例
創建沒有輸入的交易:
bitcoin-cli walletcreatefundedpsbt "[{\"txid\":\"myid\",\"vout\":0}]" "[{\"data\":\"00010203\"}]"
相關用法
- 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 walletcreatefundedpsbt。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。