Documentation ¶
Index ¶
- Constants
- Variables
- func BuildCloseTimeKey(unixTime int64, index int64) []byte
- func BuildCloseTimeQueueKey() []byte
- func BuildHashKey(randomNumberHash []byte) []byte
- func BuildSwapCreatorKey(addr sdk.AccAddress, index int64) []byte
- func BuildSwapCreatorQueueKey(addr sdk.AccAddress) []byte
- func BuildSwapRecipientKey(addr sdk.AccAddress, index int64) []byte
- func BuildSwapRecipientQueueKey(addr sdk.AccAddress) []byte
- func CalculateRandomHash(randomNumber []byte, timestamp int64) []byte
- func CalculateSwapID(randomNumberHash []byte, sender sdk.AccAddress, senderOtherChain string) []byte
- func ErrClaimExpiredSwap(msg string) sdk.Error
- func ErrDuplicatedSwapID(msg string) sdk.Error
- func ErrInvalidAddrOtherChain(msg string) sdk.Error
- func ErrInvalidExpectedIncome(msg string) sdk.Error
- func ErrInvalidHeightSpan(msg string) sdk.Error
- func ErrInvalidPaginationParameters(msg string) sdk.Error
- func ErrInvalidRandomNumber(msg string) sdk.Error
- func ErrInvalidRandomNumberHash(msg string) sdk.Error
- func ErrInvalidSingleChainSwap(msg string) sdk.Error
- func ErrInvalidSwapID(msg string) sdk.Error
- func ErrInvalidTimestamp(msg string) sdk.Error
- func ErrMismatchedRandomNumber(msg string) sdk.Error
- func ErrNonExistSwapID(msg string) sdk.Error
- func ErrRefundUnexpiredSwap(msg string) sdk.Error
- func ErrUnexpectedClaimSingleChainSwap(msg string) sdk.Error
- func ErrUnexpectedSwapStatus(msg string) sdk.Error
- func NewHandler(kp Keeper) sdk.Handler
- func NewQuerier(keeper Keeper) sdk.Querier
- type AtomicSwap
- type ClaimHTLTMsg
- func (msg ClaimHTLTMsg) GetInvolvedAddresses() []sdk.AccAddress
- func (msg ClaimHTLTMsg) GetSignBytes() []byte
- func (msg ClaimHTLTMsg) GetSigners() []sdk.AccAddress
- func (msg ClaimHTLTMsg) Route() string
- func (msg ClaimHTLTMsg) String() string
- func (msg ClaimHTLTMsg) Type() string
- func (msg ClaimHTLTMsg) ValidateBasic() sdk.Error
- type DepositHTLTMsg
- func (msg DepositHTLTMsg) GetInvolvedAddresses() []sdk.AccAddress
- func (msg DepositHTLTMsg) GetSignBytes() []byte
- func (msg DepositHTLTMsg) GetSigners() []sdk.AccAddress
- func (msg DepositHTLTMsg) Route() string
- func (msg DepositHTLTMsg) String() string
- func (msg DepositHTLTMsg) Type() string
- func (msg DepositHTLTMsg) ValidateBasic() sdk.Error
- type HTLTMsg
- type Keeper
- func (kp *Keeper) CloseSwap(ctx sdk.Context, swapID SwapBytes, swap *AtomicSwap) sdk.Error
- func (kp *Keeper) CreateSwap(ctx sdk.Context, swapID SwapBytes, swap *AtomicSwap) sdk.Error
- func (kp *Keeper) DeleteKey(ctx sdk.Context, key []byte)
- func (kp *Keeper) DeleteSwap(ctx sdk.Context, swapID SwapBytes, swap *AtomicSwap) sdk.Error
- func (kp *Keeper) GetSwap(ctx sdk.Context, swapID SwapBytes) *AtomicSwap
- func (kp *Keeper) GetSwapCloseTimeIterator(ctx sdk.Context) (iterator store.Iterator)
- func (kp *Keeper) GetSwapCreatorIterator(ctx sdk.Context, addr sdk.AccAddress) (iterator store.Iterator)
- func (kp *Keeper) GetSwapRecipientIterator(ctx sdk.Context, addr sdk.AccAddress) (iterator store.Iterator)
- func (kp *Keeper) UpdateSwap(ctx sdk.Context, swapID SwapBytes, swap *AtomicSwap) sdk.Error
- type QuerySwapByCreatorParams
- type QuerySwapByID
- type QuerySwapByRecipientParams
- type RefundHTLTMsg
- func (msg RefundHTLTMsg) GetInvolvedAddresses() []sdk.AccAddress
- func (msg RefundHTLTMsg) GetSignBytes() []byte
- func (msg RefundHTLTMsg) GetSigners() []sdk.AccAddress
- func (msg RefundHTLTMsg) Route() string
- func (msg RefundHTLTMsg) String() string
- func (msg RefundHTLTMsg) Type() string
- func (msg RefundHTLTMsg) ValidateBasic() sdk.Error
- type SwapBytes
- type SwapStatus
Constants ¶
View Source
const ( DefaultCodespace sdk.CodespaceType = 8 CodeInvalidAddrOtherChain sdk.CodeType = 1 CodeInvalidRandomNumberHash sdk.CodeType = 2 CodeInvalidRandomNumber sdk.CodeType = 3 CodeInvalidHeightSpan sdk.CodeType = 4 CodeInvalidSwapID sdk.CodeType = 5 CodeDuplicatedSwapID sdk.CodeType = 6 CodeClaimExpiredSwap sdk.CodeType = 7 CodeRefundUnexpiredSwap sdk.CodeType = 8 CodeMismatchedRandomNumber sdk.CodeType = 9 CodeNonExistSwapID sdk.CodeType = 10 CodeInvalidPaginationParameters sdk.CodeType = 11 CodeUnexpectedSwapStatus sdk.CodeType = 12 CodeInvalidTimestamp sdk.CodeType = 13 CodeInvalidSingleChainSwap sdk.CodeType = 14 CodeInvalidExpectedIncome sdk.CodeType = 15 CodeUnexpectedClaimSingleChainSwap sdk.CodeType = 16 )
View Source
const ( AtomicSwapRoute = "atomicSwap" HTLT = "HTLT" DepositHTLT = "depositHTLT" ClaimHTLT = "claimHTLT" RefundHTLT = "refundHTLT" RandomNumberHashLength = 32 RandomNumberLength = 32 SwapIDLength = 32 MaxOtherChainAddrLength = 64 MaxExpectedIncomeLength = 64 MinimumHeightSpan = 360 MaximumHeightSpan = 518400 )
View Source
const ( QuerySwapID = "swapid" QuerySwapCreator = "swapcreator" QuerySwapRecipient = "swaprecipient" )
View Source
const ( FifteenMinutes = 900 ThirtyMinutes = 1800 OneWeek = 86400 * 7 )
View Source
const (
Int64Size = 8
)
Variables ¶
View Source
var ( HashKey = []byte{0x01} SwapCreatorQueueKey = []byte{0x02} SwapRecipientQueueKey = []byte{0x03} SwapCloseTimeKey = []byte{0x04} SwapIndexKey = []byte{0x05} )
View Source
var ( // bnb prefix address: bnb1wxeplyw7x8aahy93w96yhwm7xcq3ke4f8ge93u // tbnb prefix address: tbnb1wxeplyw7x8aahy93w96yhwm7xcq3ke4ffasp3d AtomicSwapCoinsAccAddr = sdk.AccAddress(crypto.AddressHash([]byte("BinanceChainAtomicSwapCoins"))) )
Functions ¶
func BuildCloseTimeKey ¶
func BuildCloseTimeQueueKey ¶
func BuildCloseTimeQueueKey() []byte
func BuildHashKey ¶
func BuildSwapCreatorKey ¶
func BuildSwapCreatorKey(addr sdk.AccAddress, index int64) []byte
func BuildSwapCreatorQueueKey ¶
func BuildSwapCreatorQueueKey(addr sdk.AccAddress) []byte
func BuildSwapRecipientKey ¶
func BuildSwapRecipientKey(addr sdk.AccAddress, index int64) []byte
func BuildSwapRecipientQueueKey ¶
func BuildSwapRecipientQueueKey(addr sdk.AccAddress) []byte
func CalculateRandomHash ¶
func CalculateSwapID ¶
func CalculateSwapID(randomNumberHash []byte, sender sdk.AccAddress, senderOtherChain string) []byte
func ErrClaimExpiredSwap ¶
func ErrDuplicatedSwapID ¶
func ErrInvalidHeightSpan ¶
func ErrInvalidRandomNumber ¶
func ErrInvalidSwapID ¶
func ErrInvalidTimestamp ¶
func ErrNonExistSwapID ¶
func ErrRefundUnexpiredSwap ¶
func ErrUnexpectedSwapStatus ¶
func NewHandler ¶
func NewQuerier ¶
Types ¶
type AtomicSwap ¶
type AtomicSwap struct { From sdk.AccAddress `json:"from"` To sdk.AccAddress `json:"to"` OutAmount sdk.Coins `json:"out_amount"` InAmount sdk.Coins `json:"in_amount"` ExpectedIncome string `json:"expected_income"` RecipientOtherChain string `json:"recipient_other_chain"` RandomNumberHash SwapBytes `json:"random_number_hash"` // 32-length byte array, sha256(random_number, timestamp) RandomNumber SwapBytes `json:"random_number"` // random_number is a 32-length random byte array Timestamp int64 `json:"timestamp"` CrossChain bool `json:"cross_chain"` ExpireHeight int64 `json:"expire_height"` Index int64 `json:"index"` ClosedTime int64 `json:"closed_time"` Status SwapStatus `json:"status"` }
type ClaimHTLTMsg ¶
type ClaimHTLTMsg struct { From sdk.AccAddress `json:"from"` SwapID SwapBytes `json:"swap_id"` RandomNumber SwapBytes `json:"random_number"` }
func NewClaimHTLTMsg ¶
func NewClaimHTLTMsg(from sdk.AccAddress, swapID, randomNumber SwapBytes) ClaimHTLTMsg
func (ClaimHTLTMsg) GetInvolvedAddresses ¶
func (msg ClaimHTLTMsg) GetInvolvedAddresses() []sdk.AccAddress
func (ClaimHTLTMsg) GetSignBytes ¶
func (msg ClaimHTLTMsg) GetSignBytes() []byte
func (ClaimHTLTMsg) GetSigners ¶
func (msg ClaimHTLTMsg) GetSigners() []sdk.AccAddress
func (ClaimHTLTMsg) Route ¶
func (msg ClaimHTLTMsg) Route() string
func (ClaimHTLTMsg) String ¶
func (msg ClaimHTLTMsg) String() string
func (ClaimHTLTMsg) Type ¶
func (msg ClaimHTLTMsg) Type() string
func (ClaimHTLTMsg) ValidateBasic ¶
func (msg ClaimHTLTMsg) ValidateBasic() sdk.Error
type DepositHTLTMsg ¶
type DepositHTLTMsg struct { From sdk.AccAddress `json:"from"` Amount sdk.Coins `json:"amount"` SwapID SwapBytes `json:"swap_id"` }
func NewDepositHTLTMsg ¶
func NewDepositHTLTMsg(from sdk.AccAddress, amount sdk.Coins, swapID SwapBytes) DepositHTLTMsg
func (DepositHTLTMsg) GetInvolvedAddresses ¶
func (msg DepositHTLTMsg) GetInvolvedAddresses() []sdk.AccAddress
func (DepositHTLTMsg) GetSignBytes ¶
func (msg DepositHTLTMsg) GetSignBytes() []byte
func (DepositHTLTMsg) GetSigners ¶
func (msg DepositHTLTMsg) GetSigners() []sdk.AccAddress
func (DepositHTLTMsg) Route ¶
func (msg DepositHTLTMsg) Route() string
func (DepositHTLTMsg) String ¶
func (msg DepositHTLTMsg) String() string
func (DepositHTLTMsg) Type ¶
func (msg DepositHTLTMsg) Type() string
func (DepositHTLTMsg) ValidateBasic ¶
func (msg DepositHTLTMsg) ValidateBasic() sdk.Error
type HTLTMsg ¶
type HTLTMsg struct { From sdk.AccAddress `json:"from"` To sdk.AccAddress `json:"to"` RecipientOtherChain string `json:"recipient_other_chain"` SenderOtherChain string `json:"sender_other_chain"` RandomNumberHash SwapBytes `json:"random_number_hash"` Timestamp int64 `json:"timestamp"` Amount sdk.Coins `json:"amount"` ExpectedIncome string `json:"expected_income"` HeightSpan int64 `json:"height_span"` CrossChain bool `json:"cross_chain"` }
func NewHTLTMsg ¶
func (HTLTMsg) GetInvolvedAddresses ¶
func (msg HTLTMsg) GetInvolvedAddresses() []sdk.AccAddress
func (HTLTMsg) GetSignBytes ¶
func (HTLTMsg) GetSigners ¶
func (msg HTLTMsg) GetSigners() []sdk.AccAddress
func (HTLTMsg) ValidateBasic ¶
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
func (*Keeper) CreateSwap ¶
func (*Keeper) DeleteSwap ¶
func (*Keeper) GetSwapCloseTimeIterator ¶
func (*Keeper) GetSwapCreatorIterator ¶
func (*Keeper) GetSwapRecipientIterator ¶
func (*Keeper) UpdateSwap ¶
type QuerySwapByCreatorParams ¶
type QuerySwapByCreatorParams struct { Creator sdk.AccAddress Limit int64 Offset int64 }
Params for query 'custom/atomicswap/swapcreator'
type QuerySwapByID ¶
type QuerySwapByID struct {
SwapID SwapBytes
}
Params for query 'custom/atomicswap/swapid'
type QuerySwapByRecipientParams ¶
type QuerySwapByRecipientParams struct { Recipient sdk.AccAddress Limit int64 Offset int64 }
Params for query 'custom/atomicswap/swaprecipient'
type RefundHTLTMsg ¶
type RefundHTLTMsg struct { From sdk.AccAddress `json:"from"` SwapID SwapBytes `json:"swap_id"` }
func NewRefundHTLTMsg ¶
func NewRefundHTLTMsg(from sdk.AccAddress, swapID SwapBytes) RefundHTLTMsg
func (RefundHTLTMsg) GetInvolvedAddresses ¶
func (msg RefundHTLTMsg) GetInvolvedAddresses() []sdk.AccAddress
func (RefundHTLTMsg) GetSignBytes ¶
func (msg RefundHTLTMsg) GetSignBytes() []byte
func (RefundHTLTMsg) GetSigners ¶
func (msg RefundHTLTMsg) GetSigners() []sdk.AccAddress
func (RefundHTLTMsg) Route ¶
func (msg RefundHTLTMsg) Route() string
func (RefundHTLTMsg) String ¶
func (msg RefundHTLTMsg) String() string
func (RefundHTLTMsg) Type ¶
func (msg RefundHTLTMsg) Type() string
func (RefundHTLTMsg) ValidateBasic ¶
func (msg RefundHTLTMsg) ValidateBasic() sdk.Error
type SwapBytes ¶
type SwapBytes []byte
func (SwapBytes) MarshalJSON ¶
func (*SwapBytes) UnmarshalJSON ¶
type SwapStatus ¶
type SwapStatus int8
const ( NULL SwapStatus = 0x00 Open SwapStatus = 0x01 Completed SwapStatus = 0x02 Expired SwapStatus = 0x03 )
func NewSwapStatusFromString ¶
func NewSwapStatusFromString(str string) SwapStatus
func (SwapStatus) MarshalJSON ¶
func (status SwapStatus) MarshalJSON() ([]byte, error)
func (SwapStatus) String ¶
func (status SwapStatus) String() string
func (*SwapStatus) UnmarshalJSON ¶
func (status *SwapStatus) UnmarshalJSON(data []byte) error
Click to show internal directories.
Click to hide internal directories.