Client

如何向我可以廣播的交易添加簽名

  • September 17, 2018

我正在使用分類帳和多重簽名來簽署交易我得到了雙方簽署交易的簽名雜湊。如何將此簽名附加到交易中,以便將其廣播到網路?歡迎任何程式碼參考。目前我正在引用電子程式碼。

如何將此簽名附加到交易中,以便將其廣播到網路?

這對任何特定的錢包軟體都更不可知,但我希望它會有所幫助。當您簽署交易時,您將簽名放在它對應的scriptSig欄位中(tx 可能有多個輸入)。input

對於 m-of-n 多重簽名交易,scriptSig格式為:

0 <sig1> ... OP_m <pubKey1> ... OP_n OP_CHECKMULTISIG

要將其廣播到網路,您可以使用電子中的廣播命令:

cat signed.txn | electrum broadcast -

If successful, the command will return the ID of the transaction.

或者,您可以在執行比特幣核心的節點上使用。sendrawtransaction RPC

sendrawtransaction “hexstring” (allowhighfees)

Submits raw transaction (serialized, hex-encoded) to local node and network.

Also see createrawtransaction and signrawtransaction calls.

Arguments:
1. "hexstring"    (string, required) The hex string of the raw transaction)
2. allowhighfees    (boolean, optional, default=false) Allow high fees

Result:
"hex"             (string) The transaction hash in hex

Examples:

Create a transaction
> bitcoin-cli createrawtransaction "[{\"txid\" : \"mytxid\",\"vout\":0}]" "{\"myaddress\":0.01}"
Sign the transaction, and get back the hex
> bitcoin-cli signrawtransaction "myhex"

Send the transaction (signed hex)
> bitcoin-cli sendrawtransaction "signedhex"

As a json rpc call
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendrawtransaction", "params": ["signedhex"] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/

引用自:https://bitcoin.stackexchange.com/questions/79316