当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Bitcoin walletcreatefundedpsbt用法及代码示例


比特币(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.org大神的英文原创作品 Bitcoin walletcreatefundedpsbt。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。