github.com/algorand/go-algorand-sdk@v1.24.0/types/basics.go (about) 1 package types 2 3 import ( 4 "encoding/base64" 5 "math" 6 7 "github.com/algorand/go-algorand-sdk/encoding/msgpack" 8 9 "golang.org/x/crypto/ed25519" 10 ) 11 12 // TxType identifies the type of the transaction 13 type TxType string 14 15 const ( 16 // PaymentTx is the TxType for payment transactions 17 PaymentTx TxType = "pay" 18 // KeyRegistrationTx is the TxType for key registration transactions 19 KeyRegistrationTx TxType = "keyreg" 20 // AssetConfigTx creates, re-configures, or destroys an asset 21 AssetConfigTx TxType = "acfg" 22 // AssetTransferTx transfers assets between accounts (optionally closing) 23 AssetTransferTx TxType = "axfer" 24 // AssetFreezeTx changes the freeze status of an asset 25 AssetFreezeTx TxType = "afrz" 26 // ApplicationCallTx allows creating, deleting, and interacting with an application 27 ApplicationCallTx TxType = "appl" 28 // StateProofTx records a state proof 29 StateProofTx TxType = "stpf" 30 ) 31 32 const masterDerivationKeyLenBytes = 32 33 34 // MaxTxGroupSize is max number of transactions in a single group 35 const MaxTxGroupSize = 16 36 37 // LogicSigMaxSize is a max TEAL program size (with args) 38 const LogicSigMaxSize = 1000 39 40 // LogicSigMaxCost is a max execution const of a TEAL program 41 const LogicSigMaxCost = 20000 42 43 // KeyStoreRootSize is the size, in bytes, of keyreg verifier 44 const KeyStoreRootSize = 64 45 46 // MicroAlgos are the base unit of currency in Algorand 47 type MicroAlgos uint64 48 49 // Round represents a round of the Algorand consensus protocol 50 type Round uint64 51 52 // VotePK is the participation public key used in key registration transactions 53 type VotePK [ed25519.PublicKeySize]byte 54 55 // VRFPK is the VRF public key used in key registration transactions 56 type VRFPK [ed25519.PublicKeySize]byte 57 58 // MasterDerivationKey is the secret key used to derive keys in wallets 59 type MasterDerivationKey [masterDerivationKeyLenBytes]byte 60 61 // Digest is a SHA512_256 hash 62 type Digest [hashLenBytes]byte 63 64 // MerkleVerifier is a state proof 65 type MerkleVerifier [KeyStoreRootSize]byte 66 67 const microAlgoConversionFactor = 1e6 68 69 // ToAlgos converts amount in microAlgos to Algos 70 func (microalgos MicroAlgos) ToAlgos() float64 { 71 return float64(microalgos) / microAlgoConversionFactor 72 } 73 74 // ToMicroAlgos converts amount in Algos to microAlgos 75 func ToMicroAlgos(algos float64) MicroAlgos { 76 return MicroAlgos(math.Round(algos * microAlgoConversionFactor)) 77 } 78 79 func (signedTxn *SignedTxn) FromBase64String(b64string string) error { 80 txnBytes, err := base64.StdEncoding.DecodeString(b64string) 81 if err != nil { 82 return err 83 } 84 err = msgpack.Decode(txnBytes, &signedTxn) 85 if err != nil { 86 return err 87 } 88 return nil 89 } 90 91 func (block *Block) FromBase64String(b64string string) error { 92 txnBytes, err := base64.StdEncoding.DecodeString(b64string) 93 if err != nil { 94 return err 95 } 96 err = msgpack.Decode(txnBytes, &block) 97 if err != nil { 98 return err 99 } 100 return nil 101 }