Documentation ¶
Index ¶
- Variables
- func BuildCredentialList(ins []*avax.TransferableInput, signatures []*types.Signature) ([]verify.Verifiable, error)
- func BuildPayloads(txBuilder TxBuilder, req *types.ConstructionPayloadsRequest) (*types.ConstructionPayloadsResponse, *types.Error)
- func BuildSingletonCredentialList(signatures []*types.Signature) ([]verify.Verifiable, error)
- func Combine(combiner TxCombiner, rosettaTx *RosettaTx, signatures []*types.Signature) (*types.ConstructionCombineResponse, *types.Error)
- func DeriveBech32Address(chainIDAlias constants.ChainIDAlias, req *types.ConstructionDeriveRequest) (*types.ConstructionDeriveResponse, *types.Error)
- func HashTx(rosettaTx *RosettaTx) (*types.TransactionIdentifierResponse, *types.Error)
- func MatchOperations(operations []*types.Operation) ([]*parser.Match, error)
- func Parse(parser TxParser, payloadsTx *RosettaTx, isSigned bool) (*types.ConstructionParseResponse, *types.Error)
- func SortUnique(coins []*types.Coin) []*types.Coin
- func SubmitTx(ctx context.Context, issuer TransactionIssuer, rosettaTx *RosettaTx) (*types.TransactionIdentifierResponse, *types.Error)
- type AvaxTx
- type RosettaTx
- type Signer
- type TransactionIssuer
- type TxBuilder
- type TxCombiner
- type TxParser
Constants ¶
This section is empty.
Variables ¶
var ErrNoTxGiven = errors.New("no transaction was given")
Functions ¶
func BuildCredentialList ¶
func BuildCredentialList(ins []*avax.TransferableInput, signatures []*types.Signature) ([]verify.Verifiable, error)
BuildCredentialList builds a list of *secp256k1fx.Credentials using the given signatures
Based on tx inputs, we can determine the number of signatures required by each input and put correct number of signatures to construct the signed tx.
See https://github.com/ava-labs/avalanchego/blob/v1.9.0/vms/platformvm/txs/tx.go#L104 for more details.
func BuildPayloads ¶
func BuildPayloads( txBuilder TxBuilder, req *types.ConstructionPayloadsRequest, ) (*types.ConstructionPayloadsResponse, *types.Error)
BuildPayloads performs transaction construction in /construction/payloads call and returns the unsigned transaction as well as the signing payloads. Chain specific logic is abstracted using the TxBuilder interface's BuildTx method.
func BuildSingletonCredentialList ¶
func BuildSingletonCredentialList(signatures []*types.Signature) ([]verify.Verifiable, error)
BuildSingletonCredentialList builds a list of a single *secp256k1fx.Credential using the given signatures
func Combine ¶
func Combine( combiner TxCombiner, rosettaTx *RosettaTx, signatures []*types.Signature, ) (*types.ConstructionCombineResponse, *types.Error)
Combine combines unsigned transactions with the provided signatures as part of /construction/combine call. Chain spacific logic is abstracted in TxCombiner interface's CombineTx method.
func DeriveBech32Address ¶
func DeriveBech32Address(chainIDAlias constants.ChainIDAlias, req *types.ConstructionDeriveRequest) (*types.ConstructionDeriveResponse, *types.Error)
DeriveBech32Address derives Bech32 addresses for the given chain using public key and hrp provided in the request
func HashTx ¶
func HashTx(rosettaTx *RosettaTx) (*types.TransactionIdentifierResponse, *types.Error)
HashTx generates a transaction id for the given RosettaTx
func MatchOperations ¶
MatchOperations defines the operation Rosetta parser matching rules and parses the input operations
We require 2 types of operations; inputs with negative amounts and outputs with positive amounts parser guarantees there will be 2 matches.
func Parse ¶
func Parse(parser TxParser, payloadsTx *RosettaTx, isSigned bool) (*types.ConstructionParseResponse, *types.Error)
Parse contains transaction parsing logic for /construction/parse endpoint Chain specific logic is abstracted using TxParser interface's ParseTx method
func SortUnique ¶
SortUnique deduplicates given slice of coins and sorts them by UTXO id in ascending order for consistency
Per https://docs.avax.network/apis/avalanchego/apis/p-chain#platformgetutxos and https://docs.avax.network/apis/avalanchego/apis/c-chain#avaxgetutxos paginated getUTXOs calls may have duplicate UTXOs in different pages, this helper eliminates them.
func SubmitTx ¶
func SubmitTx( ctx context.Context, issuer TransactionIssuer, rosettaTx *RosettaTx, ) (*types.TransactionIdentifierResponse, *types.Error)
SubmitTx broadcasts given Rosetta tx on chain and returns the transaction id. Chain specific logic is abstracted using the TransactionIssuer interface's IssueTx method.
Types ¶
type AvaxTx ¶
type AvaxTx interface { Initialize() error Marshal() ([]byte, error) Unmarshal([]byte) error SigningPayload() []byte Hash() ids.ID }
AvaxTx encapsulates P-chain and C-chain atomic transactions in order to reuse common logic between them
type RosettaTx ¶
type RosettaTx struct { Tx AvaxTx AccountIdentifierSigners []Signer DestinationChain string DestinationChainID *ids.ID }
RosettaTx wraps a transaction along with the input addresses and destination chain information. It is used during construction between /construction/payloads and /construction/parse since parse needs this information but C-chain atomic and P-chain tx formats strip this information and only retain UTXO ids.
func (*RosettaTx) GetAccountIdentifiers ¶
func (t *RosettaTx) GetAccountIdentifiers(operations []*types.Operation) ([]*types.AccountIdentifier, error)
GetAccountIdentifiers extracts input account identifiers from given Rosetta operations
func (*RosettaTx) MarshalJSON ¶
func (*RosettaTx) UnmarshalJSON ¶
type Signer ¶
type Signer struct { CoinIdentifier string `json:"coin_identifier,omitempty"` AccountIdentifier *types.AccountIdentifier `json:"account_identifier"` }
Signer contains details of coin identifiers and the accounts signing those coins
type TransactionIssuer ¶
type TransactionIssuer interface {
IssueTx(ctx context.Context, txByte []byte, options ...rpc.Option) (ids.ID, error)
}
TransactionIssuer implements chain specific transaction submission logic
type TxBuilder ¶
type TxBuilder interface {
BuildTx(matches []*types.Operation, rawMetadata map[string]interface{}) (AvaxTx, []*types.AccountIdentifier, *types.Error)
}
TxBuilder implements backend specific transaction construction logic