Documentation ¶
Index ¶
- Constants
- func DecodeMoneroAddress(addr string) ([]byte, error)
- func DecryptOutputPublicSpendKey(spendKey *PublicKey, outIndex uint32, outKey *PublicKey, amount string, ...) (bool, uint64, error)
- func DecryptOutputViewTag(viewTag string, outIndex uint32, amount string, txPub *PublicKey, ...) (bool, uint64, error)
- func EncodeMoneroAddress(addr []byte) ([]byte, error)
- func Float64ToXMR(xmr float64) uint64
- func GetNetworkTypeAndAddressType(prefix byte) (NetworkType, AddressType, error)
- func GetPaymentIdFromExtra(extra []byte) ([]byte, error)
- func GetPrefix(nt NetworkType, at AddressType) (byte, error)
- func Keccak256Hash(data []byte) ([]byte, error)
- func NewPaymentID256() []byte
- func NewPaymentID64() []byte
- func OutputBelongsPublicSpendKey(spendKey *PublicKey, outIndex uint32, outKey *PublicKey, txPub *PublicKey, ...) (bool, error)
- func OutputBelongsViewTag(viewTag string, outIndex uint32, txPub *PublicKey, viewKey *PrivateKey) (bool, error)
- func ParseJsonString[R any](str string) (*R, error)
- func ParseResponse[R any](body io.Reader) (*R, error)
- func XMRToDecimal(xmr uint64) string
- func XMRToFloat64(xmr uint64) float64
- type AddressType
- type FullKeyPair
- type IntegratedAddress
- func (a *IntegratedAddress) Address() string
- func (a *IntegratedAddress) AddressType() AddressType
- func (a *IntegratedAddress) NetworkType() NetworkType
- func (a *IntegratedAddress) PaymentId() []byte
- func (a *IntegratedAddress) PublicSpendKey() *PublicKey
- func (a *IntegratedAddress) PublicViewKey() *PublicKey
- type KeyPair
- type MnemonicLanguage
- type MoneroAddress
- type NetworkType
- type PrimaryAddress
- type PrivateKey
- type PublicKey
- type Seed
- type SubAddress
- type ViewOnlyKeyPair
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func DecodeMoneroAddress ¶
Decodes and validates if the given addr string is a valid Monero integrated/sub-/primary address
func DecryptOutputPublicSpendKey ¶
func DecryptOutputPublicSpendKey(spendKey *PublicKey, outIndex uint32, outKey *PublicKey, amount string, txPub *PublicKey, viewKey *PrivateKey) (bool, uint64, error)
Checks whether the output belongs to the specific private view and public spend keys and if so, returns a decrypted amount
func DecryptOutputViewTag ¶
func DecryptOutputViewTag(viewTag string, outIndex uint32, amount string, txPub *PublicKey, viewKey *PrivateKey) (bool, uint64, error)
Checks whether the output belongs to the specific private view key by comparing view tags and if so, returns a decrypted amount
func EncodeMoneroAddress ¶
Validates if the given addr []byte is a valid Monero integrated/sub-/primary decoded representation and encodes it
func GetNetworkTypeAndAddressType ¶
func GetNetworkTypeAndAddressType(prefix byte) (NetworkType, AddressType, error)
Returns a NetworkType and an AddressType base on the Monero address prefix
func GetPaymentIdFromExtra ¶
Parses the extra field and returns a payment id
func GetPrefix ¶
func GetPrefix(nt NetworkType, at AddressType) (byte, error)
Returns a NetworkType and an AddressType base on the Monero address prefix
func Keccak256Hash ¶
Returns a hash calculated by the Keccak256 hash algorithm
func NewPaymentID256 ¶
func NewPaymentID256() []byte
NewPaymentID256 generates a 256 bit payment ID (hex encoded).
func NewPaymentID64 ¶
func NewPaymentID64() []byte
NewPaymentID64 generates a 64 bit payment ID (hex encoded). With 64 bit IDs, there is a non-negligible chance of a collision if they are randomly generated. It is up to recipients generating them to sanity check for uniqueness.
1 million IDs at 64-bit (simplified): 1,000,000^2 / (2^64 * 2) = ~1/36,893,488 so there is a 50% chance a collision happens around 5.06 billion IDs generated.
func OutputBelongsPublicSpendKey ¶
func OutputBelongsPublicSpendKey(spendKey *PublicKey, outIndex uint32, outKey *PublicKey, txPub *PublicKey, viewKey *PrivateKey) (bool, error)
Checks whether the output belongs to the specific private view and public spend keys
func OutputBelongsViewTag ¶
func OutputBelongsViewTag(viewTag string, outIndex uint32, txPub *PublicKey, viewKey *PrivateKey) (bool, error)
Checks whether the output belongs to the specific private view key by comparing view tags
func ParseJsonString ¶
func XMRToDecimal ¶
Converts the raw atomic XMR balance to a more human readable format.
Types ¶
type FullKeyPair ¶ added in v0.2.0
type FullKeyPair struct {
// contains filtered or unexported fields
}
func NewFullKeyPair ¶ added in v0.2.0
func NewFullKeyPair(view *PrivateKey, spend *PrivateKey) *FullKeyPair
func NewFullKeyPairSpendPrivateKey ¶ added in v0.2.0
func NewFullKeyPairSpendPrivateKey(spend *PrivateKey) (*FullKeyPair, error)
func (*FullKeyPair) SpendKeyPair ¶ added in v0.2.0
func (p *FullKeyPair) SpendKeyPair() *KeyPair
func (*FullKeyPair) ViewKeyPair ¶ added in v0.2.0
func (p *FullKeyPair) ViewKeyPair() *KeyPair
func (*FullKeyPair) ViewOnlyKeyPair ¶ added in v0.2.0
func (p *FullKeyPair) ViewOnlyKeyPair() *ViewOnlyKeyPair
type IntegratedAddress ¶
type IntegratedAddress struct {
// contains filtered or unexported fields
}
func (*IntegratedAddress) Address ¶
func (a *IntegratedAddress) Address() string
Returns a string representation of the Monero integrated/sub-/primary address
func (*IntegratedAddress) AddressType ¶
func (a *IntegratedAddress) AddressType() AddressType
Returns an AddressType from the Monero integrated/sub-/primary address
func (*IntegratedAddress) NetworkType ¶
func (a *IntegratedAddress) NetworkType() NetworkType
Returns a NetworkType from the Monero integrated/sub-/primary address
func (*IntegratedAddress) PaymentId ¶
func (a *IntegratedAddress) PaymentId() []byte
Returns a PaymentId from the Monero integrated address
func (*IntegratedAddress) PublicSpendKey ¶
func (a *IntegratedAddress) PublicSpendKey() *PublicKey
Returns a Public Spend Key from the Monero integrated/sub-/primary address
func (*IntegratedAddress) PublicViewKey ¶
func (a *IntegratedAddress) PublicViewKey() *PublicKey
Returns a Public View Key from the Monero integrated/sub-/primary address
type KeyPair ¶ added in v0.2.0
type KeyPair struct {
// contains filtered or unexported fields
}
func NewKeyPair ¶ added in v0.2.0
func NewKeyPair(priv *PrivateKey) *KeyPair
func (*KeyPair) PrivateKey ¶ added in v0.2.0
func (k *KeyPair) PrivateKey() *PrivateKey
type MnemonicLanguage ¶ added in v0.2.0
type MnemonicLanguage uint8
const (
English MnemonicLanguage = iota
)
type MoneroAddress ¶
type MoneroAddress interface { PublicSpendKey() *PublicKey PublicViewKey() *PublicKey AddressType() AddressType NetworkType() NetworkType Address() string }
func NewAddress ¶
func NewAddress(addr string) (MoneroAddress, error)
Creates a Monero integrated/sub-/primary address
type PrimaryAddress ¶
type PrimaryAddress struct {
// contains filtered or unexported fields
}
func (*PrimaryAddress) Address ¶
func (a *PrimaryAddress) Address() string
Returns a string representation of the Monero integrated/sub-/primary address
func (*PrimaryAddress) AddressType ¶
func (a *PrimaryAddress) AddressType() AddressType
Returns an AddressType from the Monero integrated/sub-/primary address
func (*PrimaryAddress) NetworkType ¶
func (a *PrimaryAddress) NetworkType() NetworkType
Returns a NetworkType from the Monero integrated/sub-/primary address
func (*PrimaryAddress) PublicSpendKey ¶
func (a *PrimaryAddress) PublicSpendKey() *PublicKey
Returns a Public Spend Key from the Monero integrated/sub-/primary address
func (*PrimaryAddress) PublicViewKey ¶
func (a *PrimaryAddress) PublicViewKey() *PublicKey
Returns a Public View Key from the Monero integrated/sub-/primary address
type PrivateKey ¶
type PrivateKey struct {
// contains filtered or unexported fields
}
func GetPrivateViewKeyFromPrivateSpendKey ¶ added in v0.2.0
func GetPrivateViewKeyFromPrivateSpendKey(spend *PrivateKey) (*PrivateKey, error)
Derives the Private View Key from the Private Spend Key
func NewPrivateKey ¶
func NewPrivateKey(keyStr string) (*PrivateKey, error)
Creates Private Key from a hex string representation
func (*PrivateKey) Bytes ¶
func (k *PrivateKey) Bytes() []byte
type PublicKey ¶
type PublicKey struct {
// contains filtered or unexported fields
}
func GetPublicKeyFromPrivate ¶
func GetPublicKeyFromPrivate(privKey *PrivateKey) *PublicKey
Derives the public key from the private (either view or spend)
func GetTxPublicKeyFromExtra ¶
Parses the extra field and returns a tx pub key
func NewPublicKey ¶
Creates Public Key from a hex string representation
func ParseExtra ¶
Parses the extra field and returns a tx pub key (or nil if error) and a payment id (or nil if error)
type Seed ¶ added in v0.2.0
type Seed struct {
// contains filtered or unexported fields
}
func NewSeed ¶ added in v0.2.0
func NewSeed(lang MnemonicLanguage) (*Seed, error)
Generates a 25 words random mnemonic seed
func NewSeedMnemonic ¶ added in v0.2.0
func NewSeedMnemonic(m string, lang MnemonicLanguage) (*Seed, error)
Creates a Seed struct from a 25 words mnemonic seed
func (*Seed) FullKeyPair ¶ added in v0.2.0
func (s *Seed) FullKeyPair() *FullKeyPair
func (*Seed) MnemonicLanguage ¶ added in v0.2.0
func (s *Seed) MnemonicLanguage() MnemonicLanguage
type SubAddress ¶
type SubAddress struct {
// contains filtered or unexported fields
}
func GenerateSubaddress ¶
func GenerateSubaddress(viewKey *PrivateKey, spendKey *PublicKey, major, minor uint32, nt NetworkType) (*SubAddress, error)
Generates a Monero subaddress base on the primary private view and public spend keys, NetworkType, major and minor indices
func (*SubAddress) Address ¶
func (a *SubAddress) Address() string
Returns a string representation of the Monero integrated/sub-/primary address
func (*SubAddress) AddressType ¶
func (a *SubAddress) AddressType() AddressType
Returns an AddressType from the Monero integrated/sub-/primary address
func (*SubAddress) NetworkType ¶
func (a *SubAddress) NetworkType() NetworkType
Returns a NetworkType from the Monero integrated/sub-/primary address
func (*SubAddress) PublicSpendKey ¶
func (a *SubAddress) PublicSpendKey() *PublicKey
Returns a Public Spend Key from the Monero integrated/sub-/primary address
func (*SubAddress) PublicViewKey ¶
func (a *SubAddress) PublicViewKey() *PublicKey
Returns a Public View Key from the Monero integrated/sub-/primary address
type ViewOnlyKeyPair ¶ added in v0.2.0
type ViewOnlyKeyPair struct {
// contains filtered or unexported fields
}
func NewViewOnlyKeyPair ¶ added in v0.2.0
func NewViewOnlyKeyPair(view *PrivateKey, spend *PublicKey) *ViewOnlyKeyPair
func (*ViewOnlyKeyPair) SpendPublicKey ¶ added in v0.2.0
func (p *ViewOnlyKeyPair) SpendPublicKey() *PublicKey
func (*ViewOnlyKeyPair) ViewKeyPair ¶ added in v0.2.0
func (p *ViewOnlyKeyPair) ViewKeyPair() *KeyPair