A utxo can either come from a transaction or a block reward. Given a source id, whether from a block reward or transaction, this function takes a generic id with it, and returns serialized binary data of the id with the given source id.
Generates a new, random private key from entropy
Create the default account's extended private key for a given mnemonic derivation path: 44'/mintlayer_coin_type'/0'
From an extended private key create a receiving private key for a given key index derivation path: current_derivation_path/0/key_index
From an extended private key create a change private key for a given key index derivation path: current_derivation_path/1/key_index
Given a public key (as bytes) and a network type (mainnet, testnet, etc), return the address public key hash from that public key as an address
Given a private key, as bytes, return the bytes of the corresponding public key
Return the extended public key from an extended private key
From an extended public key create a receiving public key for a given key index derivation path: current_derivation_path/0/key_index
From an extended public key create a change public key for a given key index derivation path: current_derivation_path/1/key_index
Given a message and a private key, sign the message with the given private key This kind of signature is to be used when signing spend requests, such as transaction input witness.
Given a digital signature, a public key and a message. Verify that the signature is produced by signing the message with the private key that derived the given public key. Note that this function is used for verifying messages related to spending, such as transaction input witness.
Given a message and a private key, create and sign a challenge with the given private key. This kind of signature is to be used when signing challenges.
Given a signed challenge, an address and a message, verify that the signature is produced by signing the message with the private key that derived the given public key. This function is used for verifying messages-related challenges.
Note: for signatures that were created by sign_challenge, the provided address must be
a 'pubkeyhash' address.
Note: currently this function never returns false - it either returns true or fails with an error.
Return the message that has to be signed to produce a signed transaction intent.
Return a SignedTransactionIntent object as bytes given the message and encoded signatures.
Note: to produce a valid signed intent one is expected to sign the corresponding message by private keys corresponding to each input of the transaction.
Parameters:
signed_message - this must have been produced by make_transaction_intent_message_to_sign.
signatures - this should be an array of Uint8Array, each of them representing an individual signature
of signed_message produced by sign_challenge using the private key for the corresponding input destination
of the transaction. The number of signatures must be equal to the number of inputs in the transaction.
Verify a signed transaction intent.
Parameters:
expected_signed_message - the message that is supposed to be signed; this must have been
produced by make_transaction_intent_message_to_sign.
encoded_signed_intent - the signed transaction intent produced by encode_signed_transaction_intent.
input_destinations - an array of addresses (strings), corresponding to the transaction's input destinations
(note that this function treats "pub key" and "pub key hash" addresses interchangeably, so it's ok to pass
one instead of the other).
network - the network being used (needed to decode the addresses).
Given the current block height and a network type (mainnet, testnet, etc), this function returns the number of blocks, after which a pool that decommissioned, will have its funds unlocked and available for spending. The current block height information is used in case a network upgrade changed the value.
Given a number of blocks, this function returns the output timelock which is used in locked outputs to lock an output for a given number of blocks since that output's transaction is included the blockchain
Given a number of clock seconds, this function returns the output timelock which is used in locked outputs to lock an output for a given number of seconds since that output's transaction is included in the blockchain
Given a timestamp represented by as unix timestamp, i.e., number of seconds since unix epoch, this function returns the output timelock which is used in locked outputs to lock an output until the given timestamp
Given a block height, this function returns the output timelock which is used in locked outputs to lock an output until that block height is reached.
This function returns the staking pool data needed to create a staking pool in an output as bytes, given its parameters and the network type (testnet, mainnet, etc).
Returns the fee that needs to be paid by a transaction for issuing a new fungible token
Given the current block height and a network type (mainnet, testnet, etc), this will return the fee that needs to be paid by a transaction for issuing a new NFT The current block height information is used in case a network upgrade changed the value.
Given the current block height and a network type (mainnet, testnet, etc), this will return the fee that needs to be paid by a transaction for changing the total supply of a token by either minting or unminting tokens The current block height information is used in case a network upgrade changed the value.
Given the current block height and a network type (mainnet, testnet, etc), this will return the fee that needs to be paid by a transaction for freezing/unfreezing a token The current block height information is used in case a network upgrade changed the value.
Given the current block height and a network type (mainnet, testnet, etc), this will return the fee that needs to be paid by a transaction for changing the authority of a token The current block height information is used in case a network upgrade changed the value.
Returns the Fungible/NFT Token ID for the given inputs of a transaction
Returns the Order ID for the given inputs of a transaction
Returns the Delegation ID for the given inputs of a transaction
Returns the Pool ID for the given inputs of a transaction
Returns the fee that needs to be paid by a transaction for issuing a data deposit
Given a signed transaction and input outpoint that spends an htlc utxo, extract a secret that is encoded in the corresponding input signature
Given the inputs, along each input's destination that can spend that input (e.g. If we are spending a UTXO in input number 1 and it is owned by address mtc1xxxx, then it is mtc1xxxx in element number 2 in the vector/list. for Account inputs that spend from a delegation it is the owning address of that delegation, and in the case of AccountCommand inputs which change a token it is the token's authority destination) and the outputs, estimate the transaction size. ScriptHash and ClassicMultisig destinations are not supported. Also, the function assumes that the input UTXOs are not HTLC.
Given inputs as bytes, outputs as bytes, and flags settings, this function returns the transaction that contains them all, as bytes.
Decodes a signed transaction from its binary encoding into a JavaScript object.
Encode an input witness of the variant that contains no signature.
Sign the specified input of the transaction and encode the signature as InputWitness.
input_utxos must be formed as follows: for each transaction input, emit byte 0 if it's a non-UTXO input,
otherwise emit 1 followed by the corresponding transaction output encoded via the appropriate "encode_output_"
function.
additional_info must contain the following:
- for each
ProduceBlockFromStakeinput of the transaction, the pool info for the pool referenced by that input; - for each
FillOrderandConcludeOrderinput of the transaction, the order info for the order referenced by that input. Note:
- It doesn't matter which input witness is currently being encoded. E.g. even if you are encoding a witness
for some UTXO-based input but another input of the same transaction is
FillOrder, you have to include the order info when encoding the witness for the UTXO-based input too. - After a certain hard fork, the produced signature will "commit" to the provided additional info, i.e. the info
will become a part of what is being signed. So, passing invalid additional info will result in an invalid signature
(with one small caveat: for
FillOrderwe only commit to order's initial balances and not the current ones; so if you only haveFillOrderinputs, you can technically pass bogus values for the current balances and the resulting signature will still be valid; though it's better to avoid doing this).
Sign the specified HTLC input of the transaction and encode the signature as InputWitness.
This function must be used for HTLC spending.
input_utxos and additional_info have the same format and requirements as in encode_witness.
Given an arbitrary number of public keys as bytes, number of minimum required signatures, and a network type, this function returns the multisig challenge, as bytes.
Produce a multisig address given a multisig challenge.
Sign the specified HTLC input of the transaction and encode the signature as InputWitness.
This function must be used for HTLC refunding when the refund address is a multisig one.
key_index parameter is an index of the public key in the multisig challenge corresponding to
the specified private key.
input_witness parameter can be either empty or a result of previous calls to this function.
input_utxos and additional_info have the same format and requirements as in encode_witness.
Sign the specified HTLC input of the transaction and encode the signature as InputWitness.
This function must be used for HTLC refunding when the refund address is a single-sig one.
input_utxos and additional_info have the same format and requirements as in encode_witness.
Given an unsigned transaction and signatures, this function returns a SignedTransaction object as bytes.
Return a PartiallySignedTransaction object as bytes.
transaction is an encoded Transaction (which can be produced via encode_transaction).
signatures, input_utxos, input_destinations and htlc_secrets are encoded lists of
optional objects of the corresponding type. To produce such a list, iterate over your
original list of optional objects and then:
- emit byte 0 if the current object is null;
- otherwise emit byte 1 followed by the object in its encoded form.
Each individual object in each of the lists corresponds to the transaction input with the same index and its meaning is as follows:
signatures- the signature for the input;input_utxos- the utxo for the input (if it's utxo-based);input_destinations- the destination (address) corresponding to the input; this determines the key(s) with which the input has to be signed. Note that for utxo-based inputs the corresponding destination can usually be extracted from the utxo itself (the exception being theProduceBlockFromStakeutxo, which doesn't contain the pool's decommission key). However, PartiallySignedTransaction requires that all input destinations are provided explicitly anyway.htlc_secrets- if the input is an HTLC one and if the transaction is spending the HTLC, this should be the HTLC secret. Otherwise it should be null.
The number of items in each list must be equal to the number of transaction inputs.
additional_info has the same meaning as in encode_witness.
Decodes a partially signed transaction from its binary encoding into a JavaScript object.
Convert the specified string address into a Destination object, encoded as bytes.
Given a Transaction encoded in bytes (not a signed transaction, but a signed transaction is tolerated by ignoring the extra bytes, by choice)
this function will return the transaction id.
The second parameter, the boolean, is provided as means of asserting that the given bytes exactly match a Transaction object.
When set to true, the bytes provided must exactly match a single Transaction object.
When set to false, extra bytes can exist, but will be ignored.
This is useful when the provided bytes are of a SignedTransaction instead of a Transaction,
since the signatures are appended at the end of the Transaction object as a vector to create a SignedTransaction.
It is recommended to use a strict Transaction size and set the second parameter to true.
Calculate the "effective balance" of a pool, given the total pool balance and pledge by the pool owner/staker. The effective balance is how the influence of a pool is calculated due to its balance.
Given an output source id as bytes, and an output index, together representing a utxo, this function returns the input that puts them together, as bytes.
Given a delegation id, an amount and a network type (mainnet, testnet, etc), this function creates an input that withdraws from a delegation. A nonce is needed because this spends from an account. The nonce must be in sequence for everything in that account.
Given a token_id, an amount of tokens to mint and nonce return an encoded mint tokens input
Given a token_id and nonce return an encoded unmint tokens input
Given a token_id and nonce return an encoded lock_token_supply input
Given a token_id, is token unfreezable and nonce return an encoded freeze token input
Given a token_id and nonce return an encoded unfreeze token input
Given a token_id, new authority destination and nonce return an encoded change token authority input
Given a token_id, new metadata uri and nonce return an encoded change token metadata uri input
Given an order id and an amount in the order's ask currency, create an input that fills the order.
Note:
- The nonce is only needed before the orders V1 fork activation. After the fork the nonce is ignored and any value can be passed for the parameter.
- FillOrder inputs should not be signed, i.e. use
encode_witness_no_signaturefor the inputs instead ofencode_witness). Note that in orders v0 FillOrder inputs can technically have a signature, it's just not checked. But in orders V1 we actually require that those inputs don't have signatures. Also, in orders V1 the provided destination is always ignored.
Given an order id create an input that freezes the order.
Note: order freezing is available only after the orders V1 fork activation.
Given an order id create an input that concludes the order.
Note: the nonce is only needed before the orders V1 fork activation. After the fork the nonce is ignored and any value can be passed for the parameter.
Given a destination address, an amount and a network type (mainnet, testnet, etc), this function creates an output of type Transfer, and returns it as bytes.
Given a destination address, an amount, token ID (in address form) and a network type (mainnet, testnet, etc), this function creates an output of type Transfer for tokens, and returns it as bytes.
Given a valid receiving address, and a locking rule as bytes (available in this file), and a network type (mainnet, testnet, etc), this function creates an output of type LockThenTransfer with the parameters provided.
Given a valid receiving address, token ID (in address form), a locking rule as bytes (available in this file), and a network type (mainnet, testnet, etc), this function creates an output of type LockThenTransfer with the parameters provided.
Given an amount, this function creates an output (as bytes) to burn a given amount of coins
Given an amount, token ID (in address form) and network type (mainnet, testnet, etc), this function creates an output (as bytes) to burn a given amount of tokens
Given a pool id as string, an owner address and a network type (mainnet, testnet, etc), this function returns an output (as bytes) to create a delegation to the given pool. The owner address is the address that is authorized to withdraw from that delegation.
Given a delegation id (as string, in address form), an amount and a network type (mainnet, testnet, etc), this function returns an output (as bytes) that would delegate coins to be staked in the specified delegation id.
Given a pool id, staking data as bytes and the network type (mainnet, testnet, etc), this function returns an output that creates that staking pool. Note that the pool id is mandated to be taken from the hash of the first input. It is not arbitrary.
Note: a UTXO of this kind is consumed when decommissioning a pool (provided that the pool never staked).
Given a pool id and a staker address, this function returns an output that is emitted when producing a block via that pool.
Note: a UTXO of this kind is consumed when decommissioning a pool (provided that the pool has staked at least once).
Given the parameters needed to issue a fungible token, and a network type (mainnet, testnet, etc), this function creates an output that issues that token.
Given the parameters needed to issue an NFT, and a network type (mainnet, testnet, etc), this function creates an output that issues that NFT.
Given data to be deposited in the blockchain, this function provides the output that deposits this data
Given the parameters needed to create hash timelock contract, and a network type (mainnet, testnet, etc), this function creates an output.
Given ask and give amounts and a conclude key create output that creates an order.
'ask_token_id': the parameter represents a Token if it's Some and coins otherwise. 'give_token_id': the parameter represents a Token if it's Some and coins otherwise.
The network, for which an operation to be done. Mainnet, testnet, etc.
Indicates whether a token can be frozen
Indicates whether a token can be unfrozen once frozen
The token supply of a specific token, set on issuance
A utxo can either come from a transaction or a block reward. This enum signifies that.
The part of the transaction that will be committed in the signature. Similar to bitcoin's sighash.
An amount of coins or some token,
Amount type abstraction. The amount type is stored in a string since JavaScript number type cannot fit 128-bit integers. The amount is given as an integer in units of "atoms". Atoms are the smallest, indivisible amount of a coin or token.
An alternative representation of Amount.
An amount of some token.
Additional information for a pool.
Additional information for an order.
Additional information for a transaction.