Documentation ¶
Overview ¶
Package wire enables communication between go-perun and the Stellar blockchain. It defines the encoding of types required by go-perun and ensures the compatibility to the types used in Soroban smart contracts.
Index ¶
- Constants
- Variables
- func GetMapValue(key xdr.ScVal, m xdr.ScMap) (xdr.ScVal, error)
- func GetScMapEntry(key xdr.ScVal, m xdr.ScMap) (xdr.ScMapEntry, error)
- func GetScMapValueFromSymbol(key xdr.ScSymbol, m xdr.ScMap) (xdr.ScVal, error)
- func MakeInt128Parts(i *big.Int) (xdr.Int128Parts, error)
- func MakeNonce(nonce channel.Nonce) xdr.ScBytes
- func MakeSymbolScMap(keys []xdr.ScSymbol, values []xdr.ScVal) (xdr.ScMap, error)
- func ToAllocation(b Balances) (*channel.Allocation, error)
- func ToBigInt(i xdr.Int128Parts) (*big.Int, error)
- func ToNonce(bytes xdr.ScBytes) channel.Nonce
- func ToParams(params Params) (channel.Params, error)
- func ToParticipant(participant Participant) (types.Participant, error)
- func ToState(stellarState State) (channel.State, error)
- type Balances
- func (b *Balances) DecodeFrom(d *xdr3.Decoder) (int, error)
- func (b Balances) EncodeTo(e *xdr3.Encoder) error
- func (b *Balances) FromScVal(v xdr.ScVal) error
- func (b Balances) MarshalBinary() ([]byte, error)
- func (b Balances) ToScVal() (xdr.ScVal, error)
- func (b *Balances) UnmarshalBinary(data []byte) error
- type Channel
- func (c *Channel) DecodeFrom(d *xdr3.Decoder) (int, error)
- func (c Channel) EncodeTo(e *xdr3.Encoder) error
- func (c *Channel) FromScVal(v xdr.ScVal) error
- func (c Channel) MarshalBinary() ([]byte, error)
- func (c Channel) ToScVal() (xdr.ScVal, error)
- func (c *Channel) UnmarshalBinary(data []byte) error
- type Control
- func (c *Control) DecodeFrom(d *xdr3.Decoder) (int, error)
- func (c Control) EncodeTo(e *xdr3.Encoder) error
- func (c *Control) FromScVal(v xdr.ScVal) error
- func (c Control) MarshalBinary() ([]byte, error)
- func (c Control) ToScVal() (xdr.ScVal, error)
- func (c *Control) UnmarshalBinary(data []byte) error
- type Params
- type Participant
- func (p *Participant) DecodeFrom(d *xdr3.Decoder) (int, error)
- func (p Participant) EncodeTo(e *xdr3.Encoder) error
- func (p *Participant) FromScVal(v xdr.ScVal) error
- func (p Participant) MarshalBinary() ([]byte, error)
- func (p Participant) ToScVal() (xdr.ScVal, error)
- func (p *Participant) UnmarshalBinary(data []byte) error
- type State
Constants ¶
View Source
const ( SymbolBalancesBalA xdr.ScSymbol = "bal_a" SymbolBalancesBalB xdr.ScSymbol = "bal_b" SymbolBalancesToken xdr.ScSymbol = "token" )
View Source
const ( SymbolChannelParams = "params" SymbolChannelState = "state" SymbolChannelControl = "control" )
View Source
const ( SymbolControlFundedA = "funded_a" SymbolControlFundedB = "funded_b" SymbolControlClosed = "closed" SymbolControlWithdrawnA = "withdrawn_a" SymbolControlWithdrawnB = "withdrawn_b" SymbolControlDisputed = "disputed" SymbolControlTimestamp = "timestamp" )
View Source
const ( SymbolParamsA = "a" SymbolParamsB = "b" SymbolParamsNonce = "nonce" SymbolParamsChallengeDuration = "challenge_duration" )
View Source
const ( PubKeyLength = 32 SymbolParticipantAddr xdr.ScSymbol = "addr" SymbolParticipantPubKey xdr.ScSymbol = "pubkey" )
View Source
const ( SymbolStateChannelID xdr.ScSymbol = "channel_id" SymbolStateBalances xdr.ScSymbol = "balances" SymbolStateVersion xdr.ScSymbol = "version" SymbolStateFinalized xdr.ScSymbol = "finalized" )
View Source
const ChannelIDLength = 32
View Source
const NonceLength = 32
Variables ¶
Functions ¶
func GetScMapEntry ¶
func GetScMapValueFromSymbol ¶
func MakeInt128Parts ¶
func MakeInt128Parts(i *big.Int) (xdr.Int128Parts, error)
MakeInt128Parts converts a big.Int to xdr.Int128Parts. It returns an error if the big.Int is negative or too large.
func MakeSymbolScMap ¶
MakeSymbolScMap creates a xdr.ScMap from a slice of symbols and a slice of values. The entries are sorted lexicographically by symbol. We expect that keys does not contain duplicates.
func ToAllocation ¶
func ToAllocation(b Balances) (*channel.Allocation, error)
func ToParticipant ¶
func ToParticipant(participant Participant) (types.Participant, error)
Types ¶
type Balances ¶
type Balances struct { BalA xdr.Int128Parts BalB xdr.Int128Parts Token xdr.ScAddress }
func MakeBalances ¶
func MakeBalances(alloc channel.Allocation) (Balances, error)
func (Balances) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*Balances) UnmarshalBinary ¶
type Control ¶
type Control struct { FundedA bool FundedB bool Closed bool WithdrawnA bool WithdrawnB bool Disputed bool Timestamp xdr.Uint64 }
func (Control) MarshalBinary ¶
func (*Control) UnmarshalBinary ¶
type Params ¶
type Params struct { A Participant B Participant Nonce xdr.ScBytes ChallengeDuration xdr.Uint64 }
func MustMakeParams ¶
func (Params) MarshalBinary ¶
func (*Params) UnmarshalBinary ¶
type Participant ¶
func MakeParticipant ¶
func MakeParticipant(participant types.Participant) (Participant, error)
func ParticipantFromScVal ¶
func ParticipantFromScVal(v xdr.ScVal) (Participant, error)
func (*Participant) DecodeFrom ¶
func (p *Participant) DecodeFrom(d *xdr3.Decoder) (int, error)
func (Participant) MarshalBinary ¶
func (p Participant) MarshalBinary() ([]byte, error)
func (*Participant) UnmarshalBinary ¶
func (p *Participant) UnmarshalBinary(data []byte) error
Source Files ¶
Click to show internal directories.
Click to hide internal directories.