zanolib

package module
v0.0.0-...-1c80360 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2025 License: MIT Imports: 15 Imported by: 0

README

GoDoc

zanolib

Zano interactions library, including address manipulation.

Offline signatures

Compatible Zano version: 2.0.1.367

This library is able to load unsigned transactions. There are however a few caveats there:

  • Because the unsigned transaction is a binary format meant to be portable, it only work between specific versions of Zano. This library is tested against a specific version of Zano and may not work with newer versions. Blob files aren't versioned so it would be difficult to detect structure automatically as is.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deserialize

func Deserialize(rx io.Reader, target any) error

Deserialize implements epee deserializer (kind of)

func Serialize

func Serialize(w io.Writer, source any) error

Types

type Address

type Address struct {
	Type      AddressType
	Flags     uint8
	SpendKey  []byte
	ViewKey   []byte
	PaymentId []byte
}

func ParseAddress

func ParseAddress(addr string) (*Address, error)

ParseAddress will parse a zano address and return and Address object containing the address

func (*Address) Debug

func (addr *Address) Debug() string

func (*Address) SetPaymentId

func (addr *Address) SetPaymentId(paymentId []byte) error

SetPaymentId sets the payment ID for the given address, and updates the address type accordingly.

func (*Address) String

func (addr *Address) String() string

String returns the address encoded as a standard Zano address

type AddressType

type AddressType uint64
const (
	PublicAddress           AddressType = 0xc5   // Zx
	PublicIntegAddress      AddressType = 0x3678 // iZ
	PublicIntegAddressV2    AddressType = 0x36f8 // iZ (new format)
	PublicAuditAddress      AddressType = 0x98c8 // aZx
	PublicAuditIntegAddress AddressType = 0x8a49 // aiZX
)

func (AddressType) Auditable

func (a AddressType) Auditable() bool

func (AddressType) HasFlags

func (a AddressType) HasFlags() bool

func (AddressType) String

func (a AddressType) String() string

type FinalizeTxParam

type FinalizeTxParam struct {
	UnlockTime           uint64
	Extra                []*zanobase.Variant         // currency::extra_v
	Attachments          []*zanobase.Variant         // currency::attachment_v
	CryptAddress         *zanobase.AccountPublicAddr // currency::account_public_address
	TxOutsAttr           uint8
	Shuffle              bool
	Flags                uint8
	MultisigId           zanobase.Value256 // crypto::hash
	Sources              []*TxSource       // currency::tx_source_entry
	SelectedTransfers    []zanobase.Varint // not sure why, but this is encoded as "01 00" in the bytestream
	PreparedDestinations []*TxDest         // currency::tx_destination_entry
	ExpirationTime       uint64
	SpendPubKey          *zanobase.Point // only for validations
	TxVersion            uint64
	//TxHardforkId         uint64 // size_t; IN NEW VERSION FIXME
	ModeSeparateFee uint64
}

func ParseFTP

func ParseFTP(buf, viewSecretKey []byte) (*FinalizeTxParam, error)

type FinalizedTx

type FinalizedTx struct {
	Tx             *zanobase.Transaction     `json:"tx"`
	TxId           zanobase.Value256         `json:"txid"`         // might be zeroes?
	OneTimeKey     zanobase.Value256         `json:"one_time_key"` // crypto::secret_key
	FTP            *FinalizeTxParam          `json:"ftp"`
	HtlcOrigin     string                    `json:"htlc_origin"`
	OutsKeyImages  []*zanobase.KeyImageIndex `json:"outs_key_images,omitempty"` // pairs (out_index, key_image) for each change output
	Derivation     zanobase.Value256         `json:"derivation"`                // crypto::key_derivation, a ec_point
	WasNotPrepared bool                      `json:"was_not_prepared"`          // true if tx was not prepared/created for some good reason (e.g. not enough outs for UTXO defragmentation tx). Because we decided not to throw exceptions for non-error cases. -- sowle
}

func ParseFinalized

func ParseFinalized(buf, viewSecretKey []byte) (*FinalizedTx, error)

type GenContext

type GenContext struct {
}

type TxDest

type TxDest struct {
	Amount          uint64
	Addr            []*zanobase.AccountPublicAddr // account_public_address; destination address, in case of 1 address - txout_to_key, in case of more - txout_multisig
	MinimumSigs     uint64                        // if txout_multisig: minimum signatures that are required to spend this output (minimum_sigs <= addr.size())  IF txout_to_key - not used
	AmountToProvide uint64                        // amount money that provided by initial creator of tx, used with partially created transactions
	UnlockTime      uint64                        //
	HtlcOptions     *TxDestHtlcOut                // destination_option_htlc_out
	AssetId         zanobase.Value256             // not blinded, not premultiplied
	Flags           uint64                        // set of flags (see tx_destination_entry_flags)
	// contains filtered or unexported fields
}

func (*TxDest) AmountCommitment

func (dst *TxDest) AmountCommitment(scalar *edwards25519.Scalar) *edwards25519.Point

func (*TxDest) BlindedAssetId

func (dst *TxDest) BlindedAssetId(scalar *edwards25519.Scalar) *edwards25519.Point

func (*TxDest) ConcealingPoint

func (dst *TxDest) ConcealingPoint(scalar *edwards25519.Scalar) *edwards25519.Point

func (*TxDest) StealthAddress

func (dst *TxDest) StealthAddress(scalar *edwards25519.Scalar) *edwards25519.Point

type TxDestHtlcOut

type TxDestHtlcOut struct {
	Expiration uint64
	HtlcHash   zanobase.Value256 // crypto::hash
}

type TxSource

type TxSource struct {
	Outputs                    []*TxSourceOutputEntry
	RealOutput                 uint64
	RealOutTxKey               zanobase.Value256 // crypto::public_key
	RealOutAmountBlindingMask  zanobase.Value256 // crypto::scalar_t
	RealOutAssetIdBlindingMask zanobase.Value256 // crypto::scalar_t
	RealOutInTxIndex           uint64            // size_t, index in transaction outputs vector
	Amount                     uint64
	TransferIndex              uint64
	MultisigId                 zanobase.Value256 // crypto::hash if txin_multisig: multisig output id
	MsSigsCount                uint64            // size_t
	MsKeysCount                uint64            // size_t
	SeparatelySignedTxComplete bool
	HtlcOrigin                 string // for htlc, specify origin. len = 1, content = "\x00" ?
}

func (*TxSource) IsZC

func (src *TxSource) IsZC() bool

type TxSourceOutputEntry

type TxSourceOutputEntry struct {
	OutReference     *zanobase.Variant // TxOutRef // either global output index or ref_by_id
	StealthAddress   zanobase.Value256 // crypto::public_key, a.k.a output's one-time public key
	ConcealingPoint  zanobase.Value256 // only for ZC outputs
	AmountCommitment zanobase.Value256 // only for ZC outputs
	BlindedAssetID   zanobase.Value256 // only for ZC outputs
}

type Wallet

type Wallet struct {
	SpendPrivKey *edwards25519.Scalar
	SpendPubKey  *edwards25519.Point
	ViewPrivKey  *edwards25519.Scalar
	ViewPubKey   *edwards25519.Point
	Flags        uint8 // flag 1 = auditable
}

func LoadSpendSecret

func LoadSpendSecret(pk []byte, flags uint8) (*Wallet, error)

LoadSpendSecret initializesd a Wallet based on a spend secret as found in zano if you run spendkey. Note that zano's displayed key is in little endian so this function will reverse the bytes for you.

Set flags to zero for normal keys, or 1 for auditable keys.

func (*Wallet) Address

func (w *Wallet) Address() *Address

Address returns this wallet's address.

func (*Wallet) ParseFTP

func (w *Wallet) ParseFTP(buf []byte) (*FinalizeTxParam, error)

func (*Wallet) ParseFinalized

func (w *Wallet) ParseFinalized(buf []byte) (*FinalizedTx, error)

func (*Wallet) Sign

func (w *Wallet) Sign(ftp *FinalizeTxParam, oneTimeKey []byte) (*FinalizedTx, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳