BlockchainTransaction(for Bitcoin)

$BlockchainBase = "Bitcoin"

BlockchainTransaction[assoc]

represents a Bitcoin blockchain transaction built from the components in the association assoc.

Details

  • Gives a symbolic representation of a Bitcoin blockchain transaction; it does not submit the transaction, and the transaction is not signed.
  • BlockchainTransaction[][prop] gives the value of the property prop for the transaction.
  • The following elements must be given:
  • "Inputs"list of inputs, given as associations
    "Outputs"list of outputs, given as associations
  • The following additional elements can also be given:
  • "Version"transaction version number (default: 1)
    "LockTime"earliest time or block when the transaction may be added (default: 0)
  • Each association in the "Inputs" list must have the following entries:
  • "TransactionID"hash of a previous transaction
    "Index"index within the previous transaction output
  • The following additional entries can also be given:
  • "ScriptString"""unlocking script also known as scriptSig
    "SignatureHash"Allsignature hash flag
  • Possible values for "SignatureHash" include:
  • Allsignature applies to all inputs and outputs
    Nonesignature applies to all inputs, none of the outputs
    "Single"signature applies to all inputs and the output with the same index number as the signed input
    "AllAnyoneCanPay"signature applies to one input and all outputs
    "NoneAnyoneCanPay"signature applies to one input, none of the outputs
    "SingleAnyoneCanPay"signature applies to one input and the output with the same index number
  • For Pay-to-Public-Key-Hash (P2PKH) transactions, each association in the "Outputs" list must have the following entries:
  • "Amount"amount of bitcoins to be transferred
    "Address"destination P2PKH address for transfer
  • For general Bitcoin transactions, a custom locking script can be given, and each association in the "Outputs" list must have the following entries:
  • "Amount"amount of bitcoins to be transferred
    "ScriptString"Bitcoin script in the form of a string
  • BlockchainTransaction can represent Bitcoin mainnet (default) and testnet transactions. To specify these networks, use the "BlockchainBase" value inside the required association or the BlockchainBase option.

Examples

open allclose all

Basic Examples  (1)

Create a Bitcoin transaction object representing a Pay-to-Public-Key-Hash transaction:

Scope  (4)

Custom Nonstandard Scripts  (2)

Use a nonstandard script to lock a new output:

Use a nonstandard script to unlock a past output:

Signature Hashes  (1)

Use different values of "SignatureHash" in the transaction inputs:

Time-Locked Transactions  (1)

Create a transaction that will be locked until block 2000000:

Options  (2)

BlockchainBase  (2)

Mainnet  (1)

Create a mainnet transaction:

Testnet  (1)

Create a testnet transaction:

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  (2)

Insuficient Amount  (1)

Providing an input referencing an unspent transaction output with insufficient amount for the total output amount will return a $Failed output:

Incorrect Output Address  (1)

Providing an invalid address will return a $Failed output:

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

Text

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

CMS

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

APA

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

BibTeX

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

BibLaTeX

@online{reference.wolfram_2024_blockchaintransaction, organization={Wolfram Research}, title={BlockchainTransaction}, year={2019}, url={https://reference.wolfram.com/language/ref/blockchain/BlockchainTransaction-Bitcoin.html}, note=[Accessed: 22-December-2024 ]}