BlockchainTransactionSign(for Bitcoin)

$BlockchainBase = "Bitcoin"

BlockchainTransactionSign[obj,key]

digitally signs a Bitcoin blockchain transaction using the specified private key.

BlockchainTransactionSign[obj,{key1,key2,}]

digitally signs a transaction using all the keys keyi.

BlockchainTransactionSign[obj,{assoc1,assoc2,}]

digitally signs a transaction where associ contains Pay-to-Script-Hash data.

Details

  • Digitally signs a Bitcoin blockchain transaction using the specified private key.
  • In BlockchainTransactionSign[obj,], obj is a BlockchainTransaction object.
  • The key for BlockchainTransactionSign must be a PrivateKey object or a hex string representing a private key.
  • BlockchainTransactionSign returns a blockchain transaction object with True as the value of its property "Signed" and with the added property "RawTransaction".
  • For a Bitcoin BlockchainTransaction object, BlockchainTransactionSign will use the value of the property "SignatureHash" provided with each input to determine the appropriate digital signature method.
  • Multiple private keys can be given in any order.
  • If an input of the transaction belongs to a Pay-to-Script-Hash address, the association in the list must have the following elements:
  • "Data"list of elements used during the execution of the script
    "Script"valid Bitcoin script
  • "Data" may contain PrivateKey objects, hexadecimal strings or Bitcoin script opcodes according to the script. PrivateKey objects will be used for signing the corresponding input. "Script" is a valid Bitcoin script composed of opcodes and hexadecimal strings.
  • If an input of the transaction is related to a multi-signature script, the association in the list must have the following elements:
  • "PrivateKeys"list of PrivateKey objects used for signing
    "PublicKeys"list of all the PublicKey objects used in the script
    "RequiredKeys"minimum number of private keys required

Examples

open allclose all

Basic Examples  (1)

Create a Bitcoin Pay-to-Public-Key-Hash BlockchainTransaction:

Sign the transaction object using a WIF-encoded private key:

Scope  (3)

Multiple Key Signatures  (1)

Sign a Bitcoin transaction with multiple keys:

Pay-to-Script-Hash Input  (1)

Sign a Bitcoin transaction with an input that belongs to a Pay-to-Script-Hash address:

The association must include the "Data" required to run the "Script" used when creating the Pay-to-Script-Hash address:

The PrivateKey object in "Data" was used to create a signature of the transaction that appears in the final transaction object:

Multi-signature Input  (1)

Sign a Bitcoin transaction with an input related to a multi-signature script:

The transaction must be signed with a minimum number of private keys from the participants according to the "RequiredKeys" parameter:

Alternatively, the transaction object can be signed sequentially by each participant:

Applications  (1)

Create a Bitcoin Pay-to-Public-Key-Hash BlockchainTransaction:

Sign the transaction object using a WIF-encoded private key:

Send the signed transaction to the Bitcoin blockchain:

Possible Issues  (1)

Incorrect Private Key  (1)

Providing an invalid private key will return a $Failed output:

Wolfram Research (2019), BlockchainTransactionSign, Wolfram Language function, https://reference.wolfram.com/language/ref/blockchain/BlockchainTransactionSign-Bitcoin.html.

Text

Wolfram Research (2019), BlockchainTransactionSign, Wolfram Language function, https://reference.wolfram.com/language/ref/blockchain/BlockchainTransactionSign-Bitcoin.html.

CMS

Wolfram Language. 2019. "BlockchainTransactionSign." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/blockchain/BlockchainTransactionSign-Bitcoin.html.

APA

Wolfram Language. (2019). BlockchainTransactionSign. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/blockchain/BlockchainTransactionSign-Bitcoin.html

BibTeX

@misc{reference.wolfram_2024_blockchaintransactionsign, author="Wolfram Research", title="{BlockchainTransactionSign}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/blockchain/BlockchainTransactionSign-Bitcoin.html}", note=[Accessed: 04-October-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_blockchaintransactionsign, organization={Wolfram Research}, title={BlockchainTransactionSign}, year={2019}, url={https://reference.wolfram.com/language/ref/blockchain/BlockchainTransactionSign-Bitcoin.html}, note=[Accessed: 04-October-2024 ]}