RPC 调用 bitcoind 以添加 P2SH
RPC call on bitcoind for adding P2SH
我到处搜索了很多,但我似乎无法弄清楚。
我想通过使用 Bitcoin Core 的 RPC 调用创建一个带有自定义 P2SH 地址的交易。我发现 signrawtransaction
中有一个 redeemScript
字段,所以我假设这是我应该发送脚本的十六进制编码的地方。但这需要一个 txid
,那么我是否应该首先使用 createrawtransaction
并将输出作为我要发送到的地址,然后使用包含的脚本签署交易?
我看到已经有一个 createmultisig
调用,因为它也是 P2SH 似乎其他 P2SH[= 也应该有类似的东西27=] 笔交易。
知道如何解决这个问题或在哪里可以找到更多相关信息吗?
如果我根据比特币书籍的 this 部分理解正确,你应该从你的脚本中创建一个散列,然后将这个散列转换成一个地址,这样你就可以使用常规 sendtoaddress
rpc调用发送硬币到地址。
Another important part of the P2SH feature is the ability to encode a script hash as an address, as defined in BIP-13. P2SH addresses are Base58Check encodings of the 20-byte hash of a script, just like bitcoin addresses are Base58Check encodings of the 20-byte hash of a public key. P2SH addresses use the version prefix "5," which results in Base58Check-encoded addresses that start with a "3."
Now, Mohammed can give this "address" to his customers and they can use almost any bitcoin wallet to make a simple payment, as if it were a bitcoin address. The 3 prefix gives them a hint that this is a special type of address, one corresponding to a script instead of a public key, but otherwise it works in exactly the same way as a payment to a bitcoin address.
P2SH addresses hide all of the complexity, so that the person making a payment does not see the script.
查看整个 section 了解如何将脚本转换为哈希。
您可以在此处下载本书中使用的可执行文件:https://github.com/libbitcoin/libbitcoin-explorer/releases
我到处搜索了很多,但我似乎无法弄清楚。
我想通过使用 Bitcoin Core 的 RPC 调用创建一个带有自定义 P2SH 地址的交易。我发现 signrawtransaction
中有一个 redeemScript
字段,所以我假设这是我应该发送脚本的十六进制编码的地方。但这需要一个 txid
,那么我是否应该首先使用 createrawtransaction
并将输出作为我要发送到的地址,然后使用包含的脚本签署交易?
我看到已经有一个 createmultisig
调用,因为它也是 P2SH 似乎其他 P2SH[= 也应该有类似的东西27=] 笔交易。
知道如何解决这个问题或在哪里可以找到更多相关信息吗?
如果我根据比特币书籍的 this 部分理解正确,你应该从你的脚本中创建一个散列,然后将这个散列转换成一个地址,这样你就可以使用常规 sendtoaddress
rpc调用发送硬币到地址。
Another important part of the P2SH feature is the ability to encode a script hash as an address, as defined in BIP-13. P2SH addresses are Base58Check encodings of the 20-byte hash of a script, just like bitcoin addresses are Base58Check encodings of the 20-byte hash of a public key. P2SH addresses use the version prefix "5," which results in Base58Check-encoded addresses that start with a "3."
Now, Mohammed can give this "address" to his customers and they can use almost any bitcoin wallet to make a simple payment, as if it were a bitcoin address. The 3 prefix gives them a hint that this is a special type of address, one corresponding to a script instead of a public key, but otherwise it works in exactly the same way as a payment to a bitcoin address.
P2SH addresses hide all of the complexity, so that the person making a payment does not see the script.
查看整个 section 了解如何将脚本转换为哈希。
您可以在此处下载本书中使用的可执行文件:https://github.com/libbitcoin/libbitcoin-explorer/releases