wallet

package
v0.0.0-...-bcde84c Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSubwallet = 698983191

Variables

View Source
var (
	ErrUnsupportedWalletVersion = errors.New("wallet version is not supported")
	ErrTxWasNotConfirmed        = errors.New("transaction was not confirmed in a given deadline, but it may still be confirmed later")
	ErrTxWasNotFound            = errors.New("requested transaction is not found")
)

Functions

func AddressFromPubKey

func AddressFromPubKey(key ed25519.PublicKey, ver Version, subwallet uint32) (*address.Address, error)

func CreateCommentCell

func CreateCommentCell(text string) (*cell.Cell, error)

func GetStateInit

func GetStateInit(pubKey ed25519.PublicKey, ver Version, subWallet uint32) (*tlb.StateInit, error)

func NewSeed

func NewSeed() []string

func NewSeedWithPassword

func NewSeedWithPassword(password string) []string

Types

type Message

type Message struct {
	Mode            uint8
	InternalMessage *tlb.InternalMessage
}

func SimpleMessage

func SimpleMessage(to *address.Address, amount tlb.Coins, payload *cell.Cell) *Message

type RegularBuilder

type RegularBuilder interface {
	BuildMessage(ctx context.Context, isInitialized bool, block *ton.BlockIDExt, messages []*Message) (*cell.Cell, error)
}

type SpecHighloadV2R2

type SpecHighloadV2R2 struct {
	SpecRegular
}

func (*SpecHighloadV2R2) BuildMessage

func (s *SpecHighloadV2R2) BuildMessage(_ context.Context, queryID uint32, messages []*Message) (*cell.Cell, error)

type SpecRegular

type SpecRegular struct {
	// contains filtered or unexported fields
}

func (*SpecRegular) SetMessagesTTL

func (s *SpecRegular) SetMessagesTTL(ttl uint32)

type SpecV3

type SpecV3 struct {
	SpecRegular
}

func (*SpecV3) BuildMessage

func (s *SpecV3) BuildMessage(ctx context.Context, isInitialized bool, block *ton.BlockIDExt, messages []*Message) (*cell.Cell, error)

type SpecV4R2

type SpecV4R2 struct {
	SpecRegular
}

func (*SpecV4R2) BuildMessage

func (s *SpecV4R2) BuildMessage(ctx context.Context, isInitialized bool, block *ton.BlockIDExt, messages []*Message) (*cell.Cell, error)

type TonAPI

type TonAPI interface {
	Client() ton.LiteClient
	CurrentMasterchainInfo(ctx context.Context) (*ton.BlockIDExt, error)
	GetAccount(ctx context.Context, block *ton.BlockIDExt, addr *address.Address) (*tlb.Account, error)
	SendExternalMessage(ctx context.Context, msg *tlb.ExternalMessage) error
	RunGetMethod(ctx context.Context, blockInfo *ton.BlockIDExt, addr *address.Address, method string, params ...interface{}) (*ton.ExecutionResult, error)
	ListTransactions(ctx context.Context, addr *address.Address, num uint32, lt uint64, txHash []byte) ([]*tlb.Transaction, error)
	WaitNextMasterBlock(ctx context.Context, master *ton.BlockIDExt) (*ton.BlockIDExt, error)
}

type Version

type Version int
const (
	V1R1         Version = 11
	V1R2         Version = 12
	V1R3         Version = 13
	V2R1         Version = 21
	V2R2         Version = 22
	V3R1         Version = 31
	V3R2         Version = 32
	V3                   = V3R2
	V4R1         Version = 41
	V4R2         Version = 42
	HighloadV2R2 Version = 122
	Lockup       Version = 200
	Unknown      Version = 0
)

func GetWalletVersion

func GetWalletVersion(account *tlb.Account) Version

func (Version) String

func (v Version) String() string

type Wallet

type Wallet struct {
	// contains filtered or unexported fields
}

func FromPrivateKey

func FromPrivateKey(api TonAPI, key ed25519.PrivateKey, version Version) (*Wallet, error)

func FromSeed

func FromSeed(api TonAPI, seed []string, version Version) (*Wallet, error)

func FromSeedWithPassword

func FromSeedWithPassword(api TonAPI, seed []string, password string, version Version) (*Wallet, error)

func (*Wallet) Address

func (w *Wallet) Address() *address.Address

func (*Wallet) BuildMessageForMany

func (w *Wallet) BuildMessageForMany(ctx context.Context, messages []*Message) (*tlb.ExternalMessage, error)

func (*Wallet) DeployContract

func (w *Wallet) DeployContract(ctx context.Context, amount tlb.Coins, msgBody, contractCode, contractData *cell.Cell, waitConfirmation ...bool) (*address.Address, error)

func (*Wallet) FindTransactionByInMsgHash

func (w *Wallet) FindTransactionByInMsgHash(ctx context.Context, msgHash []byte, maxTxNumToScan ...int) (*tlb.Transaction, error)

FindTransactionByInMsgHash returns transaction in wallet account with incoming message hash equal to msgHash.

func (*Wallet) GetBalance

func (w *Wallet) GetBalance(ctx context.Context, block *ton.BlockIDExt) (tlb.Coins, error)

func (*Wallet) GetSpec

func (w *Wallet) GetSpec() any

func (*Wallet) GetSubwallet

func (w *Wallet) GetSubwallet(subwallet uint32) (*Wallet, error)

func (*Wallet) PrivateKey

func (w *Wallet) PrivateKey() ed25519.PrivateKey

func (*Wallet) Send

func (w *Wallet) Send(ctx context.Context, message *Message, waitConfirmation ...bool) error

func (*Wallet) SendMany

func (w *Wallet) SendMany(ctx context.Context, messages []*Message, waitConfirmation ...bool) error

func (*Wallet) SendManyGetInMsgHash

func (w *Wallet) SendManyGetInMsgHash(ctx context.Context, messages []*Message, waitConfirmation ...bool) ([]byte, error)

SendManyGetInMsgHash returns hash of external incoming message payload.

func (*Wallet) SendManyWaitTxHash

func (w *Wallet) SendManyWaitTxHash(ctx context.Context, messages []*Message) ([]byte, error)

SendManyWaitTxHash always waits for tx block confirmation and returns found tx hash in block.

func (*Wallet) Transfer

func (w *Wallet) Transfer(ctx context.Context, to *address.Address, amount tlb.Coins, comment string, waitConfirmation ...bool) error

Transfer - safe transfer, in case of error on smart contract side, you will get coins back, cannot be used to transfer TON to not yet initialized contract/wallet

func (*Wallet) TransferNoBounce

func (w *Wallet) TransferNoBounce(ctx context.Context, to *address.Address, amount tlb.Coins, comment string, waitConfirmation ...bool) error

TransferNoBounce - can be used to transfer TON to not yet initialized contract/wallet

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL