payments

package
v0.0.0-...-da90e6b Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const AsyncPaymentChannelCodeBoC = "" /* 4118-byte string literal not displayed */

AsyncPaymentChannelCodeBoC Taken from https://github.com/ton-blockchain/payment-channels/tree/master#compiled-code

Variables

View Source
var AsyncPaymentChannelCode = func() *cell.Cell {
	codeBoC, _ := hex.DecodeString(AsyncPaymentChannelCodeBoC)
	code, _ := cell.FromBOC(codeBoC)
	return code
}()
View Source
var AsyncPaymentChannelCodeHash = AsyncPaymentChannelCode.Hash()
View Source
var ErrVerificationNotPassed = fmt.Errorf("verification not passed")

Functions

This section is empty.

Types

type AsyncChannel

type AsyncChannel struct {
	Status  ChannelStatus
	Storage AsyncChannelStorageData
	// contains filtered or unexported fields
}

func (*AsyncChannel) Address

func (c *AsyncChannel) Address() *address.Address

type AsyncChannelStorageData

type AsyncChannelStorageData struct {
	Initialized     bool              `tlb:"bool"`
	BalanceA        tlb.Coins         `tlb:"."`
	BalanceB        tlb.Coins         `tlb:"."`
	KeyA            []byte            `tlb:"bits 256"`
	KeyB            []byte            `tlb:"bits 256"`
	ChannelID       ChannelID         `tlb:"bits 128"`
	ClosingConfig   ClosingConfig     `tlb:"^"`
	CommittedSeqnoA uint32            `tlb:"## 32"`
	CommittedSeqnoB uint32            `tlb:"## 32"`
	Quarantine      *QuarantinedState `tlb:"maybe ^"`
	Payments        PaymentConfig     `tlb:"^"`
}

type ChallengeQuarantinedState

type ChallengeQuarantinedState struct {
	IsChallengedByA bool      `tlb:"bool"`
	Signature       Signature `tlb:"."`
	Signed          struct {
		ChannelID ChannelID         `tlb:"bits 128"`
		A         SignedSemiChannel `tlb:"^"`
		B         SignedSemiChannel `tlb:"^"`
		// contains filtered or unexported fields
	} `tlb:"."`
	// contains filtered or unexported fields
}

type ChannelID

type ChannelID []byte

func RandomChannelID

func RandomChannelID() (ChannelID, error)

type ChannelStatus

type ChannelStatus int8
const (
	ChannelStatusUninitialized ChannelStatus = iota
	ChannelStatusOpen
	ChannelStatusClosureStarted
	ChannelStatusSettlingConditionals
	ChannelStatusAwaitingFinalization
)

type Client

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

func NewPaymentChannelClient

func NewPaymentChannelClient(api TonApi) *Client

func (*Client) GetAsyncChannel

func (c *Client) GetAsyncChannel(ctx context.Context, block *ton.BlockIDExt, addr *address.Address, verify bool) (*AsyncChannel, error)

func (*Client) GetDeployAsyncChannelParams

func (c *Client) GetDeployAsyncChannelParams(channelId ChannelID, isA bool, initialBalance tlb.Coins, ourKey ed25519.PrivateKey, theirKey ed25519.PublicKey, closingConfig ClosingConfig, paymentConfig PaymentConfig) (body, code, data *cell.Cell, err error)

func (*Client) ParseAsyncChannel

func (c *Client) ParseAsyncChannel(addr *address.Address, code, data *cell.Cell, verify bool) (*AsyncChannel, error)

type ClosingConfig

type ClosingConfig struct {
	QuarantineDuration       uint32    `tlb:"## 32"`
	MisbehaviorFine          tlb.Coins `tlb:"."`
	ConditionalCloseDuration uint32    `tlb:"## 32"`
}

type ConditionalPayment

type ConditionalPayment struct {
	Amount    tlb.Coins  `tlb:"."`
	Condition *cell.Cell `tlb:"."`
}

type CooperativeClose

type CooperativeClose struct {
	SignatureA Signature `tlb:"^"`
	SignatureB Signature `tlb:"^"`
	Signed     struct {
		ChannelID ChannelID `tlb:"bits 128"`
		BalanceA  tlb.Coins `tlb:"."`
		BalanceB  tlb.Coins `tlb:"."`
		SeqnoA    uint64    `tlb:"## 64"`
		SeqnoB    uint64    `tlb:"## 64"`
		// contains filtered or unexported fields
	} `tlb:"."`
	// contains filtered or unexported fields
}

type CooperativeCommit

type CooperativeCommit struct {
	IsA        bool      `tlb:"bool"`
	SignatureA Signature `tlb:"^"`
	SignatureB Signature `tlb:"^"`
	Signed     struct {
		ChannelID ChannelID `tlb:"bits 128"`
		SeqnoA    uint64    `tlb:"## 64"`
		SeqnoB    uint64    `tlb:"## 64"`
		// contains filtered or unexported fields
	} `tlb:"."`
	// contains filtered or unexported fields
}

type FinishUncooperativeClose

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

type InitChannel

type InitChannel struct {
	IsA       bool      `tlb:"bool"`
	Signature Signature `tlb:"."`
	Signed    struct {
		ChannelID ChannelID `tlb:"bits 128"`
		BalanceA  tlb.Coins `tlb:"."`
		BalanceB  tlb.Coins `tlb:"."`
		// contains filtered or unexported fields
	} `tlb:"."`
	// contains filtered or unexported fields
}

type PaymentConfig

type PaymentConfig struct {
	ExcessFee tlb.Coins        `tlb:"."`
	DestA     *address.Address `tlb:"addr"`
	DestB     *address.Address `tlb:"addr"`
}

type QuarantinedState

type QuarantinedState struct {
	StateA            SemiChannelBody `tlb:"."`
	StateB            SemiChannelBody `tlb:"."`
	QuarantineStarts  uint32          `tlb:"## 32"`
	StateCommittedByA bool            `tlb:"bool"`
	StateChallenged   bool            `tlb:"bool"`
}

type SemiChannel

type SemiChannel struct {
	Data             SemiChannelBody  `tlb:"."`
	CounterpartyData *SemiChannelBody `tlb:"maybe ^"`
	// contains filtered or unexported fields
}

type SemiChannelBody

type SemiChannelBody struct {
	Seqno        uint64           `tlb:"## 64"`
	Sent         tlb.Coins        `tlb:"."`
	Conditionals *cell.Dictionary `tlb:"dict 32"`
}

type SettleConditionals

type SettleConditionals struct {
	IsFromA   bool      `tlb:"bool"`
	Signature Signature `tlb:"."`
	Signed    struct {
		ChannelID            ChannelID         `tlb:"bits 128"`
		ConditionalsToSettle *cell.Dictionary  `tlb:"dict 32"`
		B                    SignedSemiChannel `tlb:"^"`
		// contains filtered or unexported fields
	} `tlb:"."`
	// contains filtered or unexported fields
}

type Signature

type Signature struct {
	Value []byte `tlb:"bits 512"`
}

type SignedSemiChannel

type SignedSemiChannel struct {
	Signature Signature   `tlb:"."`
	State     SemiChannel `tlb:"."`
}

type StartUncooperativeClose

type StartUncooperativeClose struct {
	IsSignedByA bool      `tlb:"bool"`
	Signature   Signature `tlb:"."`
	Signed      struct {
		ChannelID ChannelID         `tlb:"bits 128"`
		A         SignedSemiChannel `tlb:"^"`
		B         SignedSemiChannel `tlb:"^"`
		// contains filtered or unexported fields
	} `tlb:"."`
	// contains filtered or unexported fields
}

type TonApi

type TonApi interface {
	WaitForBlock(seqno uint32) ton.APIClientWrapped
	CurrentMasterchainInfo(ctx context.Context) (_ *ton.BlockIDExt, err error)
	RunGetMethod(ctx context.Context, blockInfo *ton.BlockIDExt, addr *address.Address, method string, params ...any) (*ton.ExecutionResult, error)
	SendExternalMessage(ctx context.Context, msg *tlb.ExternalMessage) error
	GetAccount(ctx context.Context, block *ton.BlockIDExt, addr *address.Address) (*tlb.Account, error)
}

type TopupBalance

type TopupBalance struct {
	AddA tlb.Coins `tlb:"."`
	AddB tlb.Coins `tlb:"."`
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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