Documentation
¶
Index ¶
- Constants
- Variables
- func AccountIDFromPublicKey(k PublicKey) xdr.AccountId
- func AppIDFromTextMemo(memo string) (appID string, ok bool)
- func FromQuarks(amount int64) string
- func GetClient() (client *horizon.Client, err error)
- func GetClientByKinNetwork(net network.KinNetwork) (client *horizon.Client, err error)
- func GetClientV2() (client *horizonclient.Client, err error)
- func GetKin2Client() (client *horizon.Client, err error)
- func GetKin2ClientV2() (client *horizonclient.Client, err error)
- func GetKin2Issuer() (issuer string, err error)
- func GetKin2Network() (network build.Network, err error)
- func GetNetwork() (network build.Network, err error)
- func GetNetworkByKinNetwork(net network.KinNetwork) (buildNetwork build.Network, err error)
- func IsValidAppID(appID string) bool
- func IsValidMemo(m Memo) bool
- func IsValidMemoStrict(m Memo) bool
- func MustToQuarks(val string) int64
- func ToQuarks(val string) (int64, error)
- type Creation
- type Memo
- type PrivateKey
- type PublicKey
- type Region
- type TransactionType
- type Tx
Constants ¶
const ( // KinAssetCode is the asset code for Kin 2 KinAssetCode = "KIN" // kin2ProdIssuer is the Kin 2 issuer address on the production Kin 2 network Kin2ProdIssuer = "GDF42M3IPERQCBLWFEZKQRK77JQ65SCKTU3CW36HZVCX7XX5A5QXZIVK" // kin2TestIssuer is the Kin 2 issuer address on the test Kin 2 network Kin2TestIssuer = "GBC3SG6NGTSZ2OMH3FFGB7UVRQWILW367U4GSOOF4TFSZONV42UJXUH7" )
const HighestVersion = 1
HighestVersion is the highest 'supported' memo version by the implementation.
const MaxTransactionType = TransactionTypeP2P
MaxTransactionType is the maximum transaction type 'supported' by the implementation.
Variables ¶
var ( // ErrInvalidKinNetwork occurs when an invalid KinNetwork is provided ErrInvalidKinNetwork = errors.New("KinNetwork was not 'mainnet' or 'testnet'") )
Functions ¶
func AccountIDFromPublicKey ¶ added in v0.67.0
func AppIDFromTextMemo ¶ added in v0.76.0
AppIDFromTextMemo returns the canonical string AppID given a memo string.
If the provided memo is in the incorrect format, ok will be false.
func FromQuarks ¶ added in v0.67.0
FromQuarks converts an int64 amount of quarks to the string representation of kin.
func GetClient ¶
GetClient returns the default Horizon client based on which environment the application is running in.
func GetClientByKinNetwork ¶
func GetClientByKinNetwork(net network.KinNetwork) (client *horizon.Client, err error)
GetClientByKinNetwork returns a Horizon client for the provided Kin network
func GetClientV2 ¶
func GetClientV2() (client *horizonclient.Client, err error)
GetClientV2 returns the default stellar based Horizon client based on which environment the application is running in.
The stellar based client offers some additional niceties, notably around retrieving transaction history. It's generally considered to be a better client, however, the functionality _may_ have some divergent behaviour from the kin fork. Therefore, any use of this client should be tested thoroughly.
func GetKin2Client ¶ added in v0.40.0
GetKin2Client returns the default Kin 2 Horizon client based on which environment the environment is running in
func GetKin2ClientV2 ¶ added in v0.40.0
func GetKin2ClientV2() (client *horizonclient.Client, err error)
GetKin2ClientV2 returns the default stellar-based Kin 2 Horizon client based on which environment the application is running in.
The stellar based client offers some additional niceties, notably around retrieving transaction history. It's generally considered to be a better client, however, the functionality _may_ have some divergent behaviour from the kin fork. Therefore, any use of this client should be tested thoroughly.
func GetKin2Issuer ¶ added in v0.40.0
GetKin2Issuer returns the Kin issuer address based on which environment the application is running in.
func GetKin2Network ¶ added in v0.40.0
GetKin2Network returns the default Kin 2 Network modifier based on which environment the application is running in.
func GetNetwork ¶
GetNetwork returns the default Network modifier based on which environment the application is running in.
func GetNetworkByKinNetwork ¶
func GetNetworkByKinNetwork(net network.KinNetwork) (buildNetwork build.Network, err error)
GetNetworkByKinNetwork returns a Network modifier for the provided Kin network
func IsValidAppID ¶ added in v0.76.0
IsValidAppID returns whether or not the provided string is a valid app ID.
func IsValidMemo ¶
IsValidMemo returns whether or not the memo is valid.
It should be noted that there are no guarantees if the memo is valid, only if the memo is invalid. That is, this function may return false positives.
Stricter validation can be done via the IsValidMemoStrict. However, IsValidMemoStrict is not as forward compatible as IsValidMemo.
func IsValidMemoStrict ¶
IsValidMemoStrict returns whether or not the memo is valid checking against this SDKs supported version and transaction types.
It should be noted that there are no guarantees if the memo is valid, only if the memo is invalid. That is, this function may return false positives.
func MustToQuarks ¶ added in v0.67.0
MustToQuarks calls ToQuarks, panicking if there's an error.
This should only be used if you know for sure this will not panic.
Types ¶
type Creation ¶ added in v0.76.0
type Creation struct { Create *system.DecompiledCreateAccount Initialize *token.DecompiledInitializeAccount CreateAssoc *token.DecompiledCreateAssociatedAccount CloseAuthority *token.DecompiledSetAuthority AccountHolder *token.DecompiledSetAuthority }
type Memo ¶
type Memo [32]byte
Memo is the 32 byte memo encoded into transactions, as defined in github.com/kinecosystem/agora-api.
func MemoFromBase64String ¶ added in v0.45.0
func MemoFromXDR ¶
MemoFromXDR returns a Memo from an xdr.Memo, provided it is a valid (or strictly valid) memo.
func MemoFromXDRString ¶
MemoFromXDRString returns a Memo from a standard base64 encoded xdr.Memo, provided it is valid (or strictly) valid memo.
func (Memo) ForeignKey ¶
ForeignKey returns the foreign key of the memo.
func (Memo) TransactionType ¶
func (m Memo) TransactionType() TransactionType
TransactionType returns the transaction type of the memo.
func (Memo) TransactionTypeRaw ¶
func (m Memo) TransactionTypeRaw() TransactionType
TransactionTypeRaw returns the transaction type of the memo, even if it is unsupported by this SDK. It should only be used as a fall back if the raw value is needed when TransactionType() yields TransactionTypeUnknown.
type PrivateKey ¶ added in v0.67.0
type PrivateKey ed25519.PrivateKey
PrivateKey is an ed25519.PrivateKey.
func NewPrivateKey ¶ added in v0.67.0
func NewPrivateKey() (PrivateKey, error)
NewPrivateKey returns a new PrivateKey from derived from crypto/rand. The public key can be accessed via key.Public().
func PrivateKeyFromString ¶ added in v0.67.0
func PrivateKeyFromString(seed string) (PrivateKey, error)
PrivateKeyFromString parses a provided address, returning a PublicKey if successful.
The address may be either a Stellar encoded seed, or a base58 encoded string.
func (PrivateKey) Base58 ¶ added in v0.67.0
func (k PrivateKey) Base58() string
Base58 returns the base58-encoded private key
func (PrivateKey) Public ¶ added in v0.67.0
func (k PrivateKey) Public() PublicKey
Public returns the corresponding PublicKey.
func (PrivateKey) StellarSeed ¶ added in v0.67.0
func (k PrivateKey) StellarSeed() string
type PublicKey ¶ added in v0.67.0
PublicKey is an ed25519.PublicKey.
func PublicKeyFromStellarXDR ¶ added in v0.67.0
func PublicKeyFromString ¶ added in v0.67.0
PublicKeyFromString parses a provided address, returning a PublicKey if successful.
The address may be either a Stellar encoded address, or a base58 encoded string.
func (PublicKey) StellarAddress ¶ added in v0.67.0
StellarAddress returns the stellar address representation of the public key.
type Region ¶ added in v0.76.0
type Region struct { MemoData []byte Memo *Memo Creations []Creation Transfers []*token.DecompiledTransfer Closures []*token.DecompiledCloseAccount }
Region is an abstract 'region' within a transaction.
See the documentation for SignTransaction in the transaction service API.
type TransactionType ¶
type TransactionType int16
TransactionType is the memo transaction type.
const ( TransactionTypeUnknown TransactionType = iota - 1 TransactionTypeNone TransactionTypeEarn TransactionTypeSpend TransactionTypeP2P )
type Tx ¶ added in v0.76.0
type Tx struct { AppIndex uint16 AppID string AdvanceNonce *system.DecompiledAdvanceNonce Regions []Region }
Tx represents a parsed kin solana transaction
func ParseTransaction ¶ added in v0.76.0
func ParseTransaction( tx solana.Transaction, il *commonpb.InvoiceList, ) (parsed Tx, err error)
ParseTransaction parses a (solana transaction, invoice list) pair.
The following invariants are checked while parsing:
- Each instruction is one of the following: - Memo::Memo - System::CreateAccount - System::AdvanceNonce - SplToken::InitializeAccount - SplAssociatedToken::CreateAssociatedAccount - SplToken::SetAuthority - SplToken::Transfer - SplToken::CloseAccount
- If an invoice is provided, it must match _exactly_ one region.
- Transfer instructions cannot use the subsidizer as a source.
- SetAuthority can only be related to a newly created account.
- SetAuthority can only be of the types AccountHolder and CloseAccount.
- SetAuthority must be related to a SplToken::Initialize/SplAssociatedToken::CreateAssociatedAccount instruction.
- There cannot be multiple values (excluding none) of AppIndex or AppID. - The link between AppIndex and AppID is not validated.
- Earns cannot be mixed with P2P/Spend payments.