mintlayer

package
v0.0.0-...-97165cf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package mintlayer provides Go bindings for the Mintlayer blockchain WASM library.

It wraps the compiled WebAssembly module from the Mintlayer wasm-wrappers project, exposing all cryptographic and transaction-building primitives as idiomatic Go functions.

Usage

ctx := context.Background()
client, err := mintlayer.New(ctx)
if err != nil {
    log.Fatal(err)
}
defer client.Close()

privKey, err := client.MakePrivateKey()
pubKey, err := client.PublicKeyFromPrivateKey(privKey)
addr, err := client.PubkeyToPubkeyHashAddress(pubKey, mintlayer.Mainnet)

Thread Safety

A Client instance is safe for concurrent use by multiple goroutines. For high-throughput workloads, consider creating a pool of Client instances.

Networks

Mintlayer supports four networks: Mainnet, Testnet, Regtest, and Signet. Most functions require a Network parameter that determines address prefixes and consensus parameters.

Amounts

All coin and token amounts are represented as Amount, which stores the value as a decimal string of "atoms" — the smallest indivisible unit. 1 ML = 100_000_000_000 atoms (11 decimal places).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Amount

type Amount struct {
	// contains filtered or unexported fields
}

Amount represents a coin or token quantity as a decimal atom count. Atoms are the smallest, indivisible unit. For ML coins, 1 ML = 1e11 atoms.

The zero value (empty atoms string) is invalid; use NewAmount or [NewAmountFromUint64].

func NewAmount

func NewAmount(atoms string) Amount

NewAmount creates an Amount from a decimal atom string (e.g. "100000000000").

func NewAmountZero

func NewAmountZero() Amount

NewAmountZero returns an Amount representing zero atoms.

func (Amount) Atoms

func (a Amount) Atoms() string

Atoms returns the decimal string representation of the atom count.

func (Amount) MarshalJSON

func (a Amount) MarshalJSON() ([]byte, error)

MarshalJSON serialises the amount as {"atoms":"<value>"}.

func (Amount) String

func (a Amount) String() string

String implements fmt.Stringer.

func (*Amount) UnmarshalJSON

func (a *Amount) UnmarshalJSON(data []byte) error

UnmarshalJSON deserialises {"atoms":"<value>"} into an Amount.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides access to all Mintlayer WASM functions. A Client instance is safe for concurrent use by multiple goroutines.

func New

func New(ctx context.Context) (*Client, error)

New creates a new Client, compiling and instantiating the embedded WASM module. The provided context is stored as the runtime's base context. Call Client.Close when done to free WASM resources.

func (*Client) Close

func (c *Client) Close() error

Close releases all WASM resources associated with this client.

func (*Client) DataDepositFee

func (c *Client) DataDepositFee(currentBlockHeight uint64, network Network) (Amount, error)

DataDepositFee returns the fee required to create a DataDeposit output at the given block height.

func (*Client) DecodePartiallySignedTransactionToJS

func (c *Client) DecodePartiallySignedTransactionToJS(transaction []byte, network Network) (json.RawMessage, error)

DecodePartiallySignedTransactionToJS decodes a partially signed transaction into a JSON object.

func (*Client) DecodeSignedTransactionToJS

func (c *Client) DecodeSignedTransactionToJS(transaction []byte, network Network) (json.RawMessage, error)

DecodeSignedTransactionToJS decodes a signed transaction into a JSON object.

func (*Client) EffectivePoolBalance

func (c *Client) EffectivePoolBalance(network Network, pledgeAmount, poolBalance Amount) (Amount, error)

EffectivePoolBalance computes the effective balance of a staking pool used for stake selection, given the pledge and total pool balance.

func (*Client) EncodeCreateOrderOutput

func (c *Client) EncodeCreateOrderOutput(
	askAmount Amount, askTokenID *string,
	giveAmount Amount, giveTokenID *string,
	concludeAddress string,
	network Network,
) ([]byte, error)

EncodeCreateOrderOutput creates an output that creates an order for token exchange. askTokenID and giveTokenID may be nil for coin amounts.

func (*Client) EncodeDestination

func (c *Client) EncodeDestination(address string, network Network) ([]byte, error)

EncodeDestination encodes a bech32m address string into a binary destination.

func (*Client) EncodeInputForChangeTokenAuthority

func (c *Client) EncodeInputForChangeTokenAuthority(tokenID, newAuthority string, nonce uint64, network Network) ([]byte, error)

EncodeInputForChangeTokenAuthority creates an input to change the token authority.

func (*Client) EncodeInputForChangeTokenMetadataURI

func (c *Client) EncodeInputForChangeTokenMetadataURI(tokenID, newMetadataURI string, nonce uint64, network Network) ([]byte, error)

EncodeInputForChangeTokenMetadataURI creates an input to change the token metadata URI.

func (*Client) EncodeInputForConcludeOrder

func (c *Client) EncodeInputForConcludeOrder(orderID string, nonce, currentBlockHeight uint64, network Network) ([]byte, error)

EncodeInputForConcludeOrder creates an input that concludes an order.

func (*Client) EncodeInputForFillOrder

func (c *Client) EncodeInputForFillOrder(orderID string, fillAmount Amount, destination string, nonce, currentBlockHeight uint64, network Network) ([]byte, error)

EncodeInputForFillOrder creates an input that fills an order. FillOrder inputs should not be signed (use EncodeWitnessNoSignature).

func (*Client) EncodeInputForFreezeOrder

func (c *Client) EncodeInputForFreezeOrder(orderID string, currentBlockHeight uint64, network Network) ([]byte, error)

EncodeInputForFreezeOrder creates an input that freezes an order. Order freezing is available only after the orders V1 fork.

func (*Client) EncodeInputForFreezeToken

func (c *Client) EncodeInputForFreezeToken(tokenID string, isTokenUnfreezable TokenUnfreezable, nonce uint64, network Network) ([]byte, error)

EncodeInputForFreezeToken creates an input to freeze a token.

func (*Client) EncodeInputForLockTokenSupply

func (c *Client) EncodeInputForLockTokenSupply(tokenID string, nonce uint64, network Network) ([]byte, error)

EncodeInputForLockTokenSupply creates an input to lock the token supply.

func (*Client) EncodeInputForMintTokens

func (c *Client) EncodeInputForMintTokens(tokenID string, amount Amount, nonce uint64, network Network) ([]byte, error)

EncodeInputForMintTokens creates an input to mint tokens.

func (*Client) EncodeInputForUnfreezeToken

func (c *Client) EncodeInputForUnfreezeToken(tokenID string, nonce uint64, network Network) ([]byte, error)

EncodeInputForUnfreezeToken creates an input to unfreeze a token.

func (*Client) EncodeInputForUnmintTokens

func (c *Client) EncodeInputForUnmintTokens(tokenID string, nonce uint64, network Network) ([]byte, error)

EncodeInputForUnmintTokens creates an input to unmint tokens.

func (*Client) EncodeInputForUtxo

func (c *Client) EncodeInputForUtxo(outpointSourceID []byte, outputIndex uint32) ([]byte, error)

EncodeInputForUtxo encodes a UTXO input from an outpoint source ID and output index.

func (*Client) EncodeInputForWithdrawFromDelegation

func (c *Client) EncodeInputForWithdrawFromDelegation(delegationID string, amount Amount, nonce uint64, network Network) ([]byte, error)

EncodeInputForWithdrawFromDelegation creates an input that withdraws from a delegation.

func (*Client) EncodeLockForBlockCount

func (c *Client) EncodeLockForBlockCount(blockCount uint64) ([]byte, error)

EncodeLockForBlockCount encodes a "lock until N more blocks have passed" timelock.

func (*Client) EncodeLockForSeconds

func (c *Client) EncodeLockForSeconds(seconds uint64) ([]byte, error)

EncodeLockForSeconds encodes a "lock for N more seconds" timelock.

func (*Client) EncodeLockUntilHeight

func (c *Client) EncodeLockUntilHeight(blockHeight uint64) ([]byte, error)

EncodeLockUntilHeight encodes a "lock until absolute block height" timelock.

func (*Client) EncodeLockUntilTime

func (c *Client) EncodeLockUntilTime(timestampSeconds uint64) ([]byte, error)

EncodeLockUntilTime encodes a "lock until absolute UNIX timestamp" timelock.

func (*Client) EncodeMultisigChallenge

func (c *Client) EncodeMultisigChallenge(pubkeys []byte, minRequiredSignatures uint32, network Network) ([]byte, error)

EncodeMultisigChallenge encodes a multisig challenge (script) into binary. pubkeys is the concatenated encoded public keys.

func (*Client) EncodeOutpointSourceId

func (c *Client) EncodeOutpointSourceId(id []byte, sourceId SourceId) ([]byte, error)

EncodeOutpointSourceId encodes a source ID (transaction hash or block reward ID) together with a SourceId discriminant into binary form for use in outpoints.

func (*Client) EncodeOutputCoinBurn

func (c *Client) EncodeOutputCoinBurn(amount Amount) ([]byte, error)

EncodeOutputCoinBurn creates a Burn output for coins.

func (*Client) EncodeOutputCreateDelegation

func (c *Client) EncodeOutputCreateDelegation(poolID, ownerAddress string, network Network) ([]byte, error)

EncodeOutputCreateDelegation creates an output that creates a staking delegation.

func (*Client) EncodeOutputCreateStakePool

func (c *Client) EncodeOutputCreateStakePool(poolID string, poolData []byte, network Network) ([]byte, error)

EncodeOutputCreateStakePool creates an output that creates a staking pool. poolData is the encoded stake pool data (see EncodeStakePoolData).

func (*Client) EncodeOutputDataDeposit

func (c *Client) EncodeOutputDataDeposit(data []byte) ([]byte, error)

EncodeOutputDataDeposit creates a DataDeposit output for arbitrary on-chain data.

func (*Client) EncodeOutputDelegateStaking

func (c *Client) EncodeOutputDelegateStaking(amount Amount, delegationID string, network Network) ([]byte, error)

EncodeOutputDelegateStaking creates an output that delegates coins to a staking pool.

func (*Client) EncodeOutputHTLC

func (c *Client) EncodeOutputHTLC(amount Amount, tokenID *string, secretHash, spendAddress, refundAddress string, refundTimelock []byte, network Network) ([]byte, error)

EncodeOutputHTLC creates a hash time-lock contract (HTLC) output for coins or tokens. tokenID may be nil for coin HTLCs. refundTimelock is an encoded timelock.

func (*Client) EncodeOutputIssueFungibleToken

func (c *Client) EncodeOutputIssueFungibleToken(
	authority, tokenTicker, metadataURI string,
	numberOfDecimals uint32,
	totalSupply TotalSupply,
	supplyAmount *Amount,
	isTokenFreezable FreezableToken,
	currentBlockHeight uint64,
	network Network,
) ([]byte, error)

EncodeOutputIssueFungibleToken creates an output that issues a new fungible token. supplyAmount may be nil unless totalSupply is TotalSupplyFixed.

func (*Client) EncodeOutputIssueNFT

func (c *Client) EncodeOutputIssueNFT(
	tokenID, authority, name, ticker, description string,
	mediaHash []byte,
	creator []byte,
	mediaURI, iconURI, additionalMetadataURI *string,
	currentBlockHeight uint64,
	network Network,
) ([]byte, error)

EncodeOutputIssueNFT creates an output that issues a new NFT. creator, mediaURI, iconURI, and additionalMetadataURI may be nil.

func (*Client) EncodeOutputLockThenTransfer

func (c *Client) EncodeOutputLockThenTransfer(amount Amount, address string, lock []byte, network Network) ([]byte, error)

EncodeOutputLockThenTransfer creates a LockThenTransfer output for coins. lock is the encoded timelock (see EncodeLockFor* functions).

func (*Client) EncodeOutputProduceBlockFromStake

func (c *Client) EncodeOutputProduceBlockFromStake(poolID, staker string, network Network) ([]byte, error)

EncodeOutputProduceBlockFromStake creates a ProduceBlockFromStake output. This UTXO is consumed when decommissioning a pool (if the pool has staked at least once).

func (*Client) EncodeOutputTokenBurn

func (c *Client) EncodeOutputTokenBurn(amount Amount, tokenID string, network Network) ([]byte, error)

EncodeOutputTokenBurn creates a Burn output for tokens.

func (*Client) EncodeOutputTokenLockThenTransfer

func (c *Client) EncodeOutputTokenLockThenTransfer(amount Amount, address, tokenID string, lock []byte, network Network) ([]byte, error)

EncodeOutputTokenLockThenTransfer creates a LockThenTransfer output for tokens.

func (*Client) EncodeOutputTokenTransfer

func (c *Client) EncodeOutputTokenTransfer(amount Amount, address, tokenID string, network Network) ([]byte, error)

EncodeOutputTokenTransfer creates a Transfer output sending tokens to an address.

func (*Client) EncodeOutputTransfer

func (c *Client) EncodeOutputTransfer(amount Amount, address string, network Network) ([]byte, error)

EncodeOutputTransfer creates a Transfer output sending coins to an address.

func (*Client) EncodePartiallySignedTransaction

func (c *Client) EncodePartiallySignedTransaction(
	transaction, signatures, inputUtxos, inputDestinations, htlcSecrets []byte,
	additionalInfo TxAdditionalInfo,
	network Network,
) ([]byte, error)

EncodePartiallySignedTransaction creates a PartiallySignedTransaction object. additionalInfo provides pool/order data required for signing.

func (*Client) EncodeSignedTransaction

func (c *Client) EncodeSignedTransaction(transaction, signatures []byte) ([]byte, error)

EncodeSignedTransaction combines an unsigned transaction with its witness signatures into a fully signed transaction.

func (*Client) EncodeSignedTransactionIntent

func (c *Client) EncodeSignedTransactionIntent(signedMessage []byte, signatures [][]byte) ([]byte, error)

EncodeSignedTransactionIntent combines a signed message with individual per-input signatures into an encoded SignedTransactionIntent. signedMessage must be produced by MakeTransactionIntentMessageToSign. signatures is an array of raw signature bytes, one per transaction input, each produced by SignChallenge.

func (*Client) EncodeStakePoolData

func (c *Client) EncodeStakePoolData(
	value Amount,
	staker, vrfPublicKey, decommissionKey string,
	marginRatioPerThousand uint32,
	costPerBlock Amount,
	network Network,
) ([]byte, error)

EncodeStakePoolData encodes the parameters of a staking pool into binary form suitable for use in EncodeOutputCreateStakePool.

staker is the bech32m address allowed to produce blocks. vrfPublicKey is the bech32m-encoded VRF public key for the pool. decommissionKey is the bech32m address that can decommission the pool. marginRatioPerThousand is the percentage of block rewards kept by the staker (0–1000). costPerBlock is a fixed amount subtracted from block rewards before margin calculation.

func (*Client) EncodeTransaction

func (c *Client) EncodeTransaction(inputs, outputs []byte, flags uint64) ([]byte, error)

EncodeTransaction encodes an unsigned transaction from its inputs and outputs. inputs and outputs must be concatenated encoded bytes from the respective Encode* functions.

func (*Client) EncodeWitness

func (c *Client) EncodeWitness(
	sighashType SignatureHashType,
	privateKey []byte,
	inputOwnerDest string,
	transaction, inputUtxos []byte,
	inputIndex uint32,
	additionalInfo TxAdditionalInfo,
	blockHeight uint64,
	network Network,
) ([]byte, error)

EncodeWitness signs a transaction input and returns the encoded InputWitness.

privateKey is the raw encoded private key. inputOwnerDest is the bech32m address that owns the input being signed. transaction is the encoded unsigned transaction. inputUtxos is a concatenated set of optional UTXO outputs (one per input; prefix 0 for non-UTXO, 1+encoded-output for UTXO). inputIndex is the index of the input being signed. additionalInfo provides pool/order data needed for signing.

func (*Client) EncodeWitnessHTLCRefundMultisig

func (c *Client) EncodeWitnessHTLCRefundMultisig(
	sighashType SignatureHashType,
	privateKey []byte,
	keyIndex uint32,
	inputWitness, multisigChallenge, transaction, inputUtxos []byte,
	inputIndex uint32,
	additionalInfo TxAdditionalInfo,
	blockHeight uint64,
	network Network,
) ([]byte, error)

EncodeWitnessHTLCRefundMultisig adds a partial signature to an HTLC refund witness for a multisig refund address. keyIndex is the index of privateKey within the multisig challenge. inputWitness may be empty (first signer) or a previous partial result.

func (*Client) EncodeWitnessHTLCRefundSingleSig

func (c *Client) EncodeWitnessHTLCRefundSingleSig(
	sighashType SignatureHashType,
	privateKey []byte,
	inputOwnerDest string,
	transaction, inputUtxos []byte,
	inputIndex uint32,
	additionalInfo TxAdditionalInfo,
	blockHeight uint64,
	network Network,
) ([]byte, error)

EncodeWitnessHTLCRefundSingleSig signs an HTLC input for refunding via a single-sig address.

func (*Client) EncodeWitnessHTLCSpend

func (c *Client) EncodeWitnessHTLCSpend(
	sighashType SignatureHashType,
	privateKey []byte,
	inputOwnerDest string,
	transaction, inputUtxos []byte,
	inputIndex uint32,
	secret []byte,
	additionalInfo TxAdditionalInfo,
	blockHeight uint64,
	network Network,
) ([]byte, error)

EncodeWitnessHTLCSpend signs an HTLC input for spending (revealing the secret).

func (*Client) EncodeWitnessNoSignature

func (c *Client) EncodeWitnessNoSignature() ([]byte, error)

EncodeWitnessNoSignature returns an InputWitness that carries no signature. Used for FillOrder inputs.

func (*Client) EstimateTransactionSize

func (c *Client) EstimateTransactionSize(inputs []byte, inputUtxosDests []string, outputs []byte, network Network) (uint32, error)

EstimateTransactionSize estimates the encoded size of a signed transaction in bytes. inputUtxosDests must contain one address string per input (the spending destination of each UTXO).

func (*Client) ExtendedPublicKeyFromExtendedPrivateKey

func (c *Client) ExtendedPublicKeyFromExtendedPrivateKey(privkey []byte) ([]byte, error)

ExtendedPublicKeyFromExtendedPrivateKey derives the extended public key from an extended private key.

func (*Client) ExtractHTLCSecret

func (c *Client) ExtractHTLCSecret(signedTx []byte, strictByteSize bool, htlcOutpointSourceId []byte, htlcOutputIndex uint32) ([]byte, error)

ExtractHTLCSecret extracts the pre-image secret from a signed HTLC-spend transaction.

func (*Client) FungibleTokenIssuanceFee

func (c *Client) FungibleTokenIssuanceFee(currentBlockHeight uint64, network Network) (Amount, error)

FungibleTokenIssuanceFee returns the fee required to issue a new fungible token at the given block height.

func (*Client) GetDelegationId

func (c *Client) GetDelegationId(inputs []byte, network Network) (string, error)

GetDelegationId returns the delegation ID derived from a transaction's inputs.

func (*Client) GetOrderId

func (c *Client) GetOrderId(inputs []byte, network Network) (string, error)

GetOrderId returns the DEX order ID derived from a transaction's inputs.

func (*Client) GetPoolId

func (c *Client) GetPoolId(inputs []byte, network Network) (string, error)

GetPoolId returns the pool ID derived from a transaction's inputs.

func (*Client) GetTokenId

func (c *Client) GetTokenId(inputs []byte, currentBlockHeight uint64, network Network) (string, error)

GetTokenId returns the fungible or NFT token ID derived from a transaction's inputs. currentBlockHeight is used to determine the token ID scheme for the active network upgrade.

func (*Client) GetTransactionID

func (c *Client) GetTransactionID(transaction []byte, strictByteSize bool) (string, error)

GetTransactionID returns the transaction ID (as a hex string) for the given encoded transaction. Set strictByteSize to true to require the bytes to represent exactly one Transaction object.

func (*Client) InternalVerifyWitness

func (c *Client) InternalVerifyWitness(
	sighashType SignatureHashType,
	inputOwnerDest *string,
	witness, transaction, inputUtxos []byte,
	inputIndex uint32,
	additionalInfo TxAdditionalInfo,
	blockHeight uint64,
	network Network,
) error

InternalVerifyWitness verifies an input witness against the transaction. inputOwnerDest may be nil for inputs where the destination is not required.

func (*Client) MakeChangeAddress

func (c *Client) MakeChangeAddress(accountPrivkey []byte, keyIndex uint32) ([]byte, error)

MakeChangeAddress derives a change (internal) address key at the given index.

func (*Client) MakeChangeAddressPublicKey

func (c *Client) MakeChangeAddressPublicKey(accountPubkey []byte, keyIndex uint32) ([]byte, error)

MakeChangeAddressPublicKey derives the change address public key from an extended public key at the given index.

func (*Client) MakeDefaultAccountPrivkey

func (c *Client) MakeDefaultAccountPrivkey(mnemonic string, network Network) ([]byte, error)

MakeDefaultAccountPrivkey derives the extended private key for the default account (account 0) from a BIP39 mnemonic and network. Derivation path: 44'/mintlayer_coin_type'/0'

func (*Client) MakePrivateKey

func (c *Client) MakePrivateKey() ([]byte, error)

MakePrivateKey generates a new random private key.

func (*Client) MakeReceivingAddress

func (c *Client) MakeReceivingAddress(accountPrivkey []byte, keyIndex uint32) ([]byte, error)

MakeReceivingAddress derives a receiving (external) address key at the given index.

func (*Client) MakeReceivingAddressPublicKey

func (c *Client) MakeReceivingAddressPublicKey(accountPubkey []byte, keyIndex uint32) ([]byte, error)

MakeReceivingAddressPublicKey derives the receiving address public key from an extended public key at the given index.

func (*Client) MakeTransactionIntentMessageToSign

func (c *Client) MakeTransactionIntentMessageToSign(intent, transactionID string) ([]byte, error)

MakeTransactionIntentMessageToSign returns the canonical message that must be signed to produce a valid transaction intent. transactionID should be a hex-encoded transaction ID returned by GetTransactionID.

func (*Client) MultisigChallengeToAddress

func (c *Client) MultisigChallengeToAddress(challenge []byte, network Network) (string, error)

MultisigChallengeToAddress converts a binary multisig challenge into its bech32m address.

func (*Client) NftIssuanceFee

func (c *Client) NftIssuanceFee(currentBlockHeight uint64, network Network) (Amount, error)

NftIssuanceFee returns the fee required to issue a new NFT at the given block height.

func (*Client) PubkeyToPubkeyHashAddress

func (c *Client) PubkeyToPubkeyHashAddress(pubkey []byte, network Network) (string, error)

PubkeyToPubkeyHashAddress derives a pay-to-public-key-hash bech32m address.

func (*Client) PublicKeyFromPrivateKey

func (c *Client) PublicKeyFromPrivateKey(privkey []byte) ([]byte, error)

PublicKeyFromPrivateKey derives the compressed public key for a private key.

func (*Client) SignChallenge

func (c *Client) SignChallenge(privateKey, message []byte) ([]byte, error)

SignChallenge signs an arbitrary message with the given private key for challenge verification. Use VerifyChallenge to verify the result.

func (*Client) SignMessageForSpending

func (c *Client) SignMessageForSpending(privateKey, message []byte) ([]byte, error)

SignMessageForSpending signs a message for use as a transaction input witness. Use VerifySignatureForSpending to verify the result.

func (*Client) StakingPoolSpendMaturityBlockCount

func (c *Client) StakingPoolSpendMaturityBlockCount(currentBlockHeight uint64, network Network) (uint64, error)

StakingPoolSpendMaturityBlockCount returns the number of blocks that must pass after a pool decommissions before its funds become spendable.

func (*Client) TokenChangeAuthorityFee

func (c *Client) TokenChangeAuthorityFee(currentBlockHeight uint64, network Network) (Amount, error)

TokenChangeAuthorityFee returns the fee required to change a token's authority at the given block height.

func (*Client) TokenFreezeFee

func (c *Client) TokenFreezeFee(currentBlockHeight uint64, network Network) (Amount, error)

TokenFreezeFee returns the fee required to freeze or unfreeze a token at the given block height.

func (*Client) TokenSupplyChangeFee

func (c *Client) TokenSupplyChangeFee(currentBlockHeight uint64, network Network) (Amount, error)

TokenSupplyChangeFee returns the fee required to mint or unmint tokens at the given block height.

func (*Client) VerifyChallenge

func (c *Client) VerifyChallenge(address string, network Network, signedChallenge, message []byte) (bool, error)

VerifyChallenge verifies a challenge signature produced by SignChallenge. address must be a pubkeyhash bech32m address.

func (*Client) VerifySignatureForSpending

func (c *Client) VerifySignatureForSpending(publicKey, signature, message []byte) (bool, error)

VerifySignatureForSpending verifies a spending signature produced by SignMessageForSpending.

func (*Client) VerifyTransactionIntent

func (c *Client) VerifyTransactionIntent(expectedSignedMessage, encodedSignedIntent []byte, inputDestinations []string, network Network) error

VerifyTransactionIntent verifies a signed transaction intent. expectedSignedMessage must have been produced by MakeTransactionIntentMessageToSign. encodedSignedIntent must have been produced by EncodeSignedTransactionIntent. inputDestinations contains one bech32m address per transaction input.

type FreezableToken

type FreezableToken int32

FreezableToken indicates whether a token can be frozen after issuance.

const (
	FreezableNo  FreezableToken = 0
	FreezableYes FreezableToken = 1
)

type Network

type Network int32

Network represents a Mintlayer blockchain network.

const (
	Mainnet Network = 0 // Production network.
	Testnet Network = 1 // Public test network.
	Regtest Network = 2 // Local regression-test network (instant block generation).
	Signet  Network = 3 // Signet (controlled-mining test network).
)

type OrderInfo

type OrderInfo struct {
	InitiallyAsked SimpleCurrencyAmount `json:"initially_asked"`
	InitiallyGiven SimpleCurrencyAmount `json:"initially_given"`
	AskBalance     Amount               `json:"ask_balance"`
	GiveBalance    Amount               `json:"give_balance"`
}

OrderInfo holds DEX order data required for transaction signing.

type PoolInfo

type PoolInfo struct {
	StakerBalance Amount `json:"staker_balance"`
}

PoolInfo holds pool-related data required for transaction signing.

type SignatureHashType

type SignatureHashType int32

SignatureHashType controls which parts of a transaction are covered by a signature. Similar to Bitcoin's sighash types.

const (
	// SigHashAll signs all inputs and all outputs. Most common; use this for normal transfers.
	SigHashAll SignatureHashType = 0
	// SigHashNone signs all inputs but no outputs, allowing outputs to be set by other parties.
	SigHashNone SignatureHashType = 1
	// SigHashSingle signs all inputs and the output at the same index as the signed input.
	SigHashSingle SignatureHashType = 2
	// SigHashAnyoneCanPay allows additional inputs to be added to the transaction by third parties.
	SigHashAnyoneCanPay SignatureHashType = 3
)

type SimpleCurrencyAmount

type SimpleCurrencyAmount struct {
	Atoms string `json:"atoms"`
}

SimpleCurrencyAmount is used inside TxAdditionalInfo to represent ask/give balances.

type SourceId

type SourceId int32

SourceId identifies whether a UTXO comes from a transaction output or a block reward.

const (
	// SourceTransaction indicates the UTXO was created by a regular transaction output.
	SourceTransaction SourceId = 0
	// SourceBlockReward indicates the UTXO was created by a block reward (coinbase).
	SourceBlockReward SourceId = 1
)

type TokenUnfreezable

type TokenUnfreezable int32

TokenUnfreezable indicates whether a frozen token can later be unfrozen.

const (
	TokenUnfreezableNo  TokenUnfreezable = 0
	TokenUnfreezableYes TokenUnfreezable = 1
)

type TotalSupply

type TotalSupply int32

TotalSupply describes the supply policy of a fungible token.

const (
	// TotalSupplyLockable means the supply is unlimited until explicitly locked.
	TotalSupplyLockable TotalSupply = 0
	// TotalSupplyUnlimited means the supply is always unlimited.
	TotalSupplyUnlimited TotalSupply = 1
	// TotalSupplyFixed means the supply is fixed at issuance.
	TotalSupplyFixed TotalSupply = 2
)

type TxAdditionalInfo

type TxAdditionalInfo struct {
	PoolInfo  map[string]PoolInfo  `json:"pool_info"`
	OrderInfo map[string]OrderInfo `json:"order_info"`
}

TxAdditionalInfo provides out-of-band data (pool/order state) needed when signing transactions that spend pool or order UTXOs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL