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 ¶
- type Amount
- type Client
- func (c *Client) Close() error
- func (c *Client) DataDepositFee(currentBlockHeight uint64, network Network) (Amount, error)
- func (c *Client) DecodePartiallySignedTransactionToJS(transaction []byte, network Network) (json.RawMessage, error)
- func (c *Client) DecodeSignedTransactionToJS(transaction []byte, network Network) (json.RawMessage, error)
- func (c *Client) EffectivePoolBalance(network Network, pledgeAmount, poolBalance Amount) (Amount, error)
- func (c *Client) EncodeCreateOrderOutput(askAmount Amount, askTokenID *string, giveAmount Amount, giveTokenID *string, ...) ([]byte, error)
- func (c *Client) EncodeDestination(address string, network Network) ([]byte, error)
- func (c *Client) EncodeInputForChangeTokenAuthority(tokenID, newAuthority string, nonce uint64, network Network) ([]byte, error)
- func (c *Client) EncodeInputForChangeTokenMetadataURI(tokenID, newMetadataURI string, nonce uint64, network Network) ([]byte, error)
- func (c *Client) EncodeInputForConcludeOrder(orderID string, nonce, currentBlockHeight uint64, network Network) ([]byte, error)
- func (c *Client) EncodeInputForFillOrder(orderID string, fillAmount Amount, destination string, ...) ([]byte, error)
- func (c *Client) EncodeInputForFreezeOrder(orderID string, currentBlockHeight uint64, network Network) ([]byte, error)
- func (c *Client) EncodeInputForFreezeToken(tokenID string, isTokenUnfreezable TokenUnfreezable, nonce uint64, ...) ([]byte, error)
- func (c *Client) EncodeInputForLockTokenSupply(tokenID string, nonce uint64, network Network) ([]byte, error)
- func (c *Client) EncodeInputForMintTokens(tokenID string, amount Amount, nonce uint64, network Network) ([]byte, error)
- func (c *Client) EncodeInputForUnfreezeToken(tokenID string, nonce uint64, network Network) ([]byte, error)
- func (c *Client) EncodeInputForUnmintTokens(tokenID string, nonce uint64, network Network) ([]byte, error)
- func (c *Client) EncodeInputForUtxo(outpointSourceID []byte, outputIndex uint32) ([]byte, error)
- func (c *Client) EncodeInputForWithdrawFromDelegation(delegationID string, amount Amount, nonce uint64, network Network) ([]byte, error)
- func (c *Client) EncodeLockForBlockCount(blockCount uint64) ([]byte, error)
- func (c *Client) EncodeLockForSeconds(seconds uint64) ([]byte, error)
- func (c *Client) EncodeLockUntilHeight(blockHeight uint64) ([]byte, error)
- func (c *Client) EncodeLockUntilTime(timestampSeconds uint64) ([]byte, error)
- func (c *Client) EncodeMultisigChallenge(pubkeys []byte, minRequiredSignatures uint32, network Network) ([]byte, error)
- func (c *Client) EncodeOutpointSourceId(id []byte, sourceId SourceId) ([]byte, error)
- func (c *Client) EncodeOutputCoinBurn(amount Amount) ([]byte, error)
- func (c *Client) EncodeOutputCreateDelegation(poolID, ownerAddress string, network Network) ([]byte, error)
- func (c *Client) EncodeOutputCreateStakePool(poolID string, poolData []byte, network Network) ([]byte, error)
- func (c *Client) EncodeOutputDataDeposit(data []byte) ([]byte, error)
- func (c *Client) EncodeOutputDelegateStaking(amount Amount, delegationID string, network Network) ([]byte, error)
- func (c *Client) EncodeOutputHTLC(amount Amount, tokenID *string, secretHash, spendAddress, refundAddress string, ...) ([]byte, error)
- func (c *Client) EncodeOutputIssueFungibleToken(authority, tokenTicker, metadataURI string, numberOfDecimals uint32, ...) ([]byte, error)
- func (c *Client) EncodeOutputIssueNFT(tokenID, authority, name, ticker, description string, mediaHash []byte, ...) ([]byte, error)
- func (c *Client) EncodeOutputLockThenTransfer(amount Amount, address string, lock []byte, network Network) ([]byte, error)
- func (c *Client) EncodeOutputProduceBlockFromStake(poolID, staker string, network Network) ([]byte, error)
- func (c *Client) EncodeOutputTokenBurn(amount Amount, tokenID string, network Network) ([]byte, error)
- func (c *Client) EncodeOutputTokenLockThenTransfer(amount Amount, address, tokenID string, lock []byte, network Network) ([]byte, error)
- func (c *Client) EncodeOutputTokenTransfer(amount Amount, address, tokenID string, network Network) ([]byte, error)
- func (c *Client) EncodeOutputTransfer(amount Amount, address string, network Network) ([]byte, error)
- func (c *Client) EncodePartiallySignedTransaction(transaction, signatures, inputUtxos, inputDestinations, htlcSecrets []byte, ...) ([]byte, error)
- func (c *Client) EncodeSignedTransaction(transaction, signatures []byte) ([]byte, error)
- func (c *Client) EncodeSignedTransactionIntent(signedMessage []byte, signatures [][]byte) ([]byte, error)
- func (c *Client) EncodeStakePoolData(value Amount, staker, vrfPublicKey, decommissionKey string, ...) ([]byte, error)
- func (c *Client) EncodeTransaction(inputs, outputs []byte, flags uint64) ([]byte, error)
- func (c *Client) EncodeWitness(sighashType SignatureHashType, privateKey []byte, inputOwnerDest string, ...) ([]byte, error)
- func (c *Client) EncodeWitnessHTLCRefundMultisig(sighashType SignatureHashType, privateKey []byte, keyIndex uint32, ...) ([]byte, error)
- func (c *Client) EncodeWitnessHTLCRefundSingleSig(sighashType SignatureHashType, privateKey []byte, inputOwnerDest string, ...) ([]byte, error)
- func (c *Client) EncodeWitnessHTLCSpend(sighashType SignatureHashType, privateKey []byte, inputOwnerDest string, ...) ([]byte, error)
- func (c *Client) EncodeWitnessNoSignature() ([]byte, error)
- func (c *Client) EstimateTransactionSize(inputs []byte, inputUtxosDests []string, outputs []byte, network Network) (uint32, error)
- func (c *Client) ExtendedPublicKeyFromExtendedPrivateKey(privkey []byte) ([]byte, error)
- func (c *Client) ExtractHTLCSecret(signedTx []byte, strictByteSize bool, htlcOutpointSourceId []byte, ...) ([]byte, error)
- func (c *Client) FungibleTokenIssuanceFee(currentBlockHeight uint64, network Network) (Amount, error)
- func (c *Client) GetDelegationId(inputs []byte, network Network) (string, error)
- func (c *Client) GetOrderId(inputs []byte, network Network) (string, error)
- func (c *Client) GetPoolId(inputs []byte, network Network) (string, error)
- func (c *Client) GetTokenId(inputs []byte, currentBlockHeight uint64, network Network) (string, error)
- func (c *Client) GetTransactionID(transaction []byte, strictByteSize bool) (string, error)
- func (c *Client) InternalVerifyWitness(sighashType SignatureHashType, inputOwnerDest *string, ...) error
- func (c *Client) MakeChangeAddress(accountPrivkey []byte, keyIndex uint32) ([]byte, error)
- func (c *Client) MakeChangeAddressPublicKey(accountPubkey []byte, keyIndex uint32) ([]byte, error)
- func (c *Client) MakeDefaultAccountPrivkey(mnemonic string, network Network) ([]byte, error)
- func (c *Client) MakePrivateKey() ([]byte, error)
- func (c *Client) MakeReceivingAddress(accountPrivkey []byte, keyIndex uint32) ([]byte, error)
- func (c *Client) MakeReceivingAddressPublicKey(accountPubkey []byte, keyIndex uint32) ([]byte, error)
- func (c *Client) MakeTransactionIntentMessageToSign(intent, transactionID string) ([]byte, error)
- func (c *Client) MultisigChallengeToAddress(challenge []byte, network Network) (string, error)
- func (c *Client) NftIssuanceFee(currentBlockHeight uint64, network Network) (Amount, error)
- func (c *Client) PubkeyToPubkeyHashAddress(pubkey []byte, network Network) (string, error)
- func (c *Client) PublicKeyFromPrivateKey(privkey []byte) ([]byte, error)
- func (c *Client) SignChallenge(privateKey, message []byte) ([]byte, error)
- func (c *Client) SignMessageForSpending(privateKey, message []byte) ([]byte, error)
- func (c *Client) StakingPoolSpendMaturityBlockCount(currentBlockHeight uint64, network Network) (uint64, error)
- func (c *Client) TokenChangeAuthorityFee(currentBlockHeight uint64, network Network) (Amount, error)
- func (c *Client) TokenFreezeFee(currentBlockHeight uint64, network Network) (Amount, error)
- func (c *Client) TokenSupplyChangeFee(currentBlockHeight uint64, network Network) (Amount, error)
- func (c *Client) VerifyChallenge(address string, network Network, signedChallenge, message []byte) (bool, error)
- func (c *Client) VerifySignatureForSpending(publicKey, signature, message []byte) (bool, error)
- func (c *Client) VerifyTransactionIntent(expectedSignedMessage, encodedSignedIntent []byte, inputDestinations []string, ...) error
- type FreezableToken
- type Network
- type OrderInfo
- type PoolInfo
- type SignatureHashType
- type SimpleCurrencyAmount
- type SourceId
- type TokenUnfreezable
- type TotalSupply
- type TxAdditionalInfo
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 NewAmountZero ¶
func NewAmountZero() Amount
NewAmountZero returns an Amount representing zero atoms.
func (Amount) MarshalJSON ¶
MarshalJSON serialises the amount as {"atoms":"<value>"}.
func (*Amount) UnmarshalJSON ¶
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 ¶
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) DataDepositFee ¶
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 ¶
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 ¶
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 ¶
EncodeLockForBlockCount encodes a "lock until N more blocks have passed" timelock.
func (*Client) EncodeLockForSeconds ¶
EncodeLockForSeconds encodes a "lock for N more seconds" timelock.
func (*Client) EncodeLockUntilHeight ¶
EncodeLockUntilHeight encodes a "lock until absolute block height" timelock.
func (*Client) EncodeLockUntilTime ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
GetDelegationId returns the delegation ID derived from a transaction's inputs.
func (*Client) GetOrderId ¶
GetOrderId returns the DEX order 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 ¶
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 ¶
MakeChangeAddress derives a change (internal) address key at the given index.
func (*Client) MakeChangeAddressPublicKey ¶
MakeChangeAddressPublicKey derives the change address public key from an extended public key at the given index.
func (*Client) MakeDefaultAccountPrivkey ¶
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 ¶
MakePrivateKey generates a new random private key.
func (*Client) MakeReceivingAddress ¶
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 ¶
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 ¶
MultisigChallengeToAddress converts a binary multisig challenge into its bech32m address.
func (*Client) NftIssuanceFee ¶
NftIssuanceFee returns the fee required to issue a new NFT at the given block height.
func (*Client) PubkeyToPubkeyHashAddress ¶
PubkeyToPubkeyHashAddress derives a pay-to-public-key-hash bech32m address.
func (*Client) PublicKeyFromPrivateKey ¶
PublicKeyFromPrivateKey derives the compressed public key for a private key.
func (*Client) SignChallenge ¶
SignChallenge signs an arbitrary message with the given private key for challenge verification. Use VerifyChallenge to verify the result.
func (*Client) SignMessageForSpending ¶
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 ¶
TokenFreezeFee returns the fee required to freeze or unfreeze a token at the given block height.
func (*Client) TokenSupplyChangeFee ¶
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 ¶
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 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.
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 )