Class: TxEncoder

tx_encoder~ TxEncoder


new TxEncoder(encryptKey, data, options)

A Transaction encoder object takes an arc obfuscation key and data, and can be used to construct an array of bitcoin output scripts which will store the provided data.

Parameters:
Name Type Description
encryptKey String

arc4 obfuscation key. Should be obtained from the output transactions first input's prevTxid

data Buffer
options Object
Properties
Name Type Description
prefix String

The ASCII prefix of this encoding. Defaults to 'CNTRPRTY'

senderPubkey String

The full public key of the sender. Only needed for toOpMultisig encoding.

senderAddr String

The address of the sender. This can be automatically calculated from the senderPubkey, and is not strictly necessary unless you'll be encoding to a non OpMulisig form.

receiverAddr String

The address of the receiver. This is not always necessary for some transactions (such as broadcasts)

network Network

The bitcore network to use for encoding senderPubkey. Defaults to bitcore.Network.livenet

disableChangeOutput Network

Whether to include the change return P2PKH_SCPT. Defaults to false.

Members


data :Buffer

Returns the data being encoded, as was passed in the constructor

Type:
  • Buffer

disableChangeOutput :Boolean

Returns whether this encoding will include an output to return the leftover allocation.

Type:
  • Boolean
Default Value:
  • true

encryptKey :String

Returns the arc4 obfuscation key that was passed in the constructor

Type:
  • String

network :Buffer

Returns the Bitcoin network that is being used for senderAddr processing

Type:
  • Buffer
Default Value:
  • Bitcore.Networks.livenet

prefix :String

Returns the data prefix of this encoding

Type:
  • String
Default Value:
  • CNTRPRTY

receiverAddr :String

Returns the receiverAddr of this encoding.

Type:
  • String
Default Value:
  • undefined

senderAddr :String

Returns the senderAddr of this encoding.

Type:
  • String

senderPubkey :String

Returns the senderPubkey that was passed in the constructor (if one was provided)

Type:
  • String

Methods


toOpMultisig()

Return an array of strings representing this data's encoding in the OpMultisig bitcoin output format

Returns:
Type
Array

toOpReturn()

Return an array of strings representing this data's encoding in the OpReturn bitcoin output format

Returns:
Type
Array

toPubKeyHash()

Return an array of strings representing this data's encoding in the PublicKeyHash bitcoin output format

Returns:
Type
Array