Documentation ¶
Index ¶
- Constants
- Variables
- func GenerateWalletAddress(key ed25519.PublicKey, ver Version, workchain int, subWalletId *int) (tongo.AccountID, error)
- func GetCodeByVer(ver Version) *boc.Cell
- func GetCodeHashByVer(ver Version) tlb.Bits256
- func IsMessageModeSet(modeValue int, mode MessageMode) bool
- func RandomSeed() string
- func SeedToPrivateKey(seed string) (ed25519.PrivateKey, error)
- type DataV1V2
- type DataV3
- type DataV4
- type Message
- type MessageMode
- type MessageV3
- type MessageV4
- type PayloadV1toV4
- type RawMessage
- type Sendable
- type SimpleMockBlockchain
- func (b *SimpleMockBlockchain) GetAccountState(ctx context.Context, accountID tongo.AccountID) (tlb.ShardAccount, error)
- func (b *SimpleMockBlockchain) GetSeqno(ctx context.Context, account tongo.AccountID) (uint32, error)
- func (b *SimpleMockBlockchain) SendMessage(ctx context.Context, payload []byte) (uint32, error)
- type SimpleTransfer
- type SingedMsgBody
- type TextComment
- type Version
- type Wallet
- func (w *Wallet) GetAddress() tongo.AccountID
- func (w *Wallet) GetBalance(ctx context.Context) (uint64, error)
- func (w *Wallet) RawSend(ctx context.Context, seqno uint32, validUntil time.Time, ...) error
- func (w *Wallet) RawSendV2(ctx context.Context, seqno uint32, validUntil time.Time, ...) (tongo.Bits256, error)
- func (w *Wallet) Send(ctx context.Context, messages ...Sendable) error
- func (w *Wallet) SendV2(ctx context.Context, waitingConfirmation time.Duration, messages ...Sendable) (tongo.Bits256, error)
Constants ¶
const ( DefaultSubWalletIdV3V4 = 698983191 DefaultMessageLifetime = time.Minute * 3 DefaultMessageMode = 3 )
Variables ¶
var WORDLIST = []string{}/* 2048 elements not displayed */
Functions ¶
func GenerateWalletAddress ¶
func GenerateWalletAddress( key ed25519.PublicKey, ver Version, workchain int, subWalletId *int, ) (tongo.AccountID, error)
GenerateWalletAddress Generate wallet address from known workchain, public key and version. subWalletId is only used in V3 and V4 wallets. Use nil for default value. The version number is associated with a specific implementation of the wallet code (https://github.com/toncenter/tonweb/blob/master/src/contract/wallet/WalletSources.md)
func GetCodeByVer ¶
func GetCodeHashByVer ¶
func IsMessageModeSet ¶ added in v1.1.2
func IsMessageModeSet(modeValue int, mode MessageMode) bool
func RandomSeed ¶ added in v1.0.1
func RandomSeed() string
func SeedToPrivateKey ¶
func SeedToPrivateKey(seed string) (ed25519.PrivateKey, error)
Types ¶
type Message ¶
type MessageMode ¶ added in v1.1.2
type MessageMode int
const ( // AttachAllRemainingBalance means that a wallet will transfer all the remaining balance to the destination // instead of the value originally indicated in the message. AttachAllRemainingBalance MessageMode = 128 // AttachAllRemainingBalanceOfInboundMessage means that // a wallet will transfer all the remaining value of the inbound message in addition to the value initially indicated // in the new message AttachAllRemainingBalanceOfInboundMessage MessageMode = 64 // DestroyAccount means that current account must be destroyed if its resulting balance is zero (often used with Mode 128). DestroyAccount MessageMode = 32 )
For detailed information about message modes take a look at https://docs.ton.org/develop/smart-contracts/messages.
type MessageV3 ¶
type MessageV3 struct { SubWalletId uint32 ValidUntil uint32 Seqno uint32 RawMessages PayloadV1toV4 }
type MessageV4 ¶
type MessageV4 struct { // Op: 0 - simple send, 1 - deploy and install plugin, 2 - install plugin, 3 - remove plugin SubWalletId uint32 ValidUntil uint32 Seqno uint32 Op int8 RawMessages PayloadV1toV4 }
type PayloadV1toV4 ¶
type PayloadV1toV4 []RawMessage
func ExtractRawMessages ¶ added in v1.1.1
func ExtractRawMessages(ver Version, msg *boc.Cell) (PayloadV1toV4, error)
ExtractRawMessages extracts a list of RawMessages from an external message.
func (PayloadV1toV4) MarshalTLB ¶
func (*PayloadV1toV4) UnmarshalTLB ¶
type RawMessage ¶
RawMessage when received by a wallet contract will be resent as an outgoing message.
type SimpleMockBlockchain ¶
type SimpleMockBlockchain struct {
// contains filtered or unexported fields
}
SimpleMockBlockchain Very simple mock. It does not provide blockchain logic for calculating state and seqno for different addresses. Only for internal tests and demonstration purposes.
func NewMockBlockchain ¶
func NewMockBlockchain(seqno uint32, state tongo.AccountInfo) (*SimpleMockBlockchain, chan []byte)
func (*SimpleMockBlockchain) GetAccountState ¶
func (b *SimpleMockBlockchain) GetAccountState(ctx context.Context, accountID tongo.AccountID) (tlb.ShardAccount, error)
func (*SimpleMockBlockchain) SendMessage ¶ added in v1.0.1
type SimpleTransfer ¶ added in v1.0.1
type SimpleTransfer struct { Amount tlb.Grams Address tongo.AccountID Comment string Bounceable bool }
func (SimpleTransfer) ToInternal ¶ added in v1.0.1
func (m SimpleTransfer) ToInternal() (message tlb.Message, mode uint8, err error)
type SingedMsgBody ¶ added in v1.1.1
SingedMsgBody represents an external message's body sent by an offchain application to a wallet contract. The signature is created using the wallet's private key. So the wallet will verify that it is the recipient of the payload and accept the payload.
type TextComment ¶
type TextComment string
func (TextComment) MarshalTLB ¶
func (*TextComment) UnmarshalTLB ¶
type Version ¶
type Version int
func GetVerByCodeHash ¶
GetVerByCodeHash returns (Version, true) if there is code with the given hash. Otherwise, it returns (0, false).
type Wallet ¶
type Wallet struct {
// contains filtered or unexported fields
}
func DefaultWalletFromSeed ¶
func New ¶ added in v1.0.1
func New(key ed25519.PrivateKey, ver Version, workchain int, subWalletId *int, blockchain blockchain) (Wallet, error)
New Fill new Wallet struct from known workchain, public key and version. subWalletId is only used in V3 and V4 wallets. Use nil for default value. The version number is associated with a specific implementation of the wallet code (https://github.com/toncenter/tonweb/blob/master/src/contract/wallet/WalletSources.md)
func (*Wallet) GetAddress ¶
GetAddress returns current wallet address but you can also call function GenerateWalletAddress which returns same address but doesn't require blockchain connection for calling
func (*Wallet) GetBalance ¶
GetBalance Gets actual TON balance for wallet
func (*Wallet) RawSend ¶
func (w *Wallet) RawSend( ctx context.Context, seqno uint32, validUntil time.Time, internalMessages []RawMessage, init *tlb.StateInit, ) error
RawSend Generates a signed external message for wallet with custom internal messages, seqno, TTL and init The payload is serialized into bytes and sent by the method SendRawMessage