Documentation ¶
Overview ¶
nolint
nolint
Index ¶
- Constants
- Variables
- func ErrHashLockAlreadyExists(codespace sdk.CodespaceType, msg string) sdk.Error
- func ErrInvalidAddress(codespace sdk.CodespaceType, msg string) sdk.Error
- func ErrInvalidAmount(codespace sdk.CodespaceType, msg string) sdk.Error
- func ErrInvalidHashLock(codespace sdk.CodespaceType, msg string) sdk.Error
- func ErrInvalidSecret(codespace sdk.CodespaceType, msg string) sdk.Error
- func ErrInvalidTimeLock(codespace sdk.CodespaceType, msg string) sdk.Error
- func ErrStateIsNotExpired(codespace sdk.CodespaceType, msg string) sdk.Error
- func ErrStateIsNotOpen(codespace sdk.CodespaceType, msg string) sdk.Error
- func ParamTypeTable() params.TypeTable
- func RegisterCodec(cdc *codec.Codec)
- func ValidateParams(p Params) error
- type BankKeeper
- type GenesisState
- type HTLC
- type HTLCState
- func (state HTLCState) Format(s fmt.State, verb rune)
- func (state HTLCState) Marshal() ([]byte, error)
- func (state HTLCState) MarshalJSON() ([]byte, error)
- func (state HTLCState) String() string
- func (state *HTLCState) Unmarshal(data []byte) error
- func (state *HTLCState) UnmarshalJSON(data []byte) error
- type MsgClaimHTLC
- type MsgCreateHTLC
- type MsgRefundHTLC
- type Params
- func (p *Params) GetParamSpace() string
- func (p *Params) KeyValuePairs() params.KeyValuePairs
- func (p *Params) ReadOnly() bool
- func (p Params) String() string
- func (p *Params) StringFromBytes(cdc *codec.Codec, key string, bytes []byte) (string, error)
- func (p *Params) Validate(key string, value string) (interface{}, sdk.Error)
- type QueryHTLCParams
Constants ¶
const ( DefaultCodespace sdk.CodespaceType = "htlc" CodeInvalidAddress sdk.CodeType = 100 CodeInvalidAmount sdk.CodeType = 101 CodeInvalidHashLock sdk.CodeType = 102 CodeHashLockAlreadyExists sdk.CodeType = 103 CodeInvalidTimeLock sdk.CodeType = 104 CodeInvalidSecret sdk.CodeType = 105 CodeStateIsNotOpen sdk.CodeType = 106 CodeStateIsNotExpired sdk.CodeType = 107 )
Rand errors reserve 100 ~ 199.
const ( // MsgRoute identifies transaction types MsgRoute = "htlc" // type for MsgCreateHTLC TypeMsgCreateHTLC = "create_htlc" // type for MsgClaimHTLC TypeMsgClaimHTLC = "claim_htlc" // type for MsgRefundHTLC TypeMsgRefundHTLC = "refund_htlc" SecretLength = 32 // the length for the secret HashLockLength = 32 // the length for the hash lock MaxLengthForAddressOnOtherChain = 128 // maximal length for the address on other chains MinTimeLock = 50 // minimal time span for HTLC MaxTimeLock = 25480 // maximal time span for HTLC )
const (
DefaultParamSpace = "htlc"
)
const (
QueryHTLC = "htlc"
)
Variables ¶
var ( HTLCStateToStringMap = map[HTLCState]string{ OPEN: "open", COMPLETED: "completed", EXPIRED: "expired", REFUNDED: "refunded", } StringToHTLCStateMap = map[string]HTLCState{ "open": OPEN, "completed": COMPLETED, "expired": EXPIRED, "refunded": REFUNDED, } )
var ( TagSender = "sender" TagReceiver = "receiver" TagReceiverOnOtherChain = "receiver-on-other-chain" TagAmount = "amount" TagHashLock = "hash-lock" TagSecret = "secret" )
Functions ¶
func ErrHashLockAlreadyExists ¶
func ErrHashLockAlreadyExists(codespace sdk.CodespaceType, msg string) sdk.Error
func ErrInvalidAddress ¶
func ErrInvalidAddress(codespace sdk.CodespaceType, msg string) sdk.Error
func ErrInvalidAmount ¶
func ErrInvalidAmount(codespace sdk.CodespaceType, msg string) sdk.Error
func ErrInvalidHashLock ¶
func ErrInvalidHashLock(codespace sdk.CodespaceType, msg string) sdk.Error
func ErrInvalidSecret ¶
func ErrInvalidSecret(codespace sdk.CodespaceType, msg string) sdk.Error
func ErrInvalidTimeLock ¶
func ErrInvalidTimeLock(codespace sdk.CodespaceType, msg string) sdk.Error
func ErrStateIsNotExpired ¶
func ErrStateIsNotExpired(codespace sdk.CodespaceType, msg string) sdk.Error
func ErrStateIsNotOpen ¶
func ErrStateIsNotOpen(codespace sdk.CodespaceType, msg string) sdk.Error
func ValidateParams ¶
Types ¶
type BankKeeper ¶
type BankKeeper interface { AddCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, sdk.Tags, sdk.Error) SetTotalSupply(ctx sdk.Context, totalSupply sdk.Coin) GetTotalSupply(ctx sdk.Context, denom string) (coin sdk.Coin, found bool) IncreaseTotalSupply(ctx sdk.Context, amt sdk.Coin) sdk.Error BurnCoins(ctx sdk.Context, fromAddr sdk.AccAddress, amt sdk.Coins) (sdk.Tags, sdk.Error) SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) (sdk.Tags, sdk.Error) }
expected bank keeper
type GenesisState ¶
GenesisState contains all HTLC state that must be provided at genesis
type HTLC ¶
type HTLC struct { Sender sdk.AccAddress `json:"sender"` // the initiator address To sdk.AccAddress `json:"to"` // the destination address ReceiverOnOtherChain string `json:"receiver_on_other_chain"` // the claim receiving address on the other chain Amount sdk.Coins `json:"amount"` // the amount to be transferred Secret []byte `json:"secret"` // the random secret which is of 32 bytes Timestamp uint64 `json:"timestamp"` // the timestamp, if provided, used to generate the hash lock together with secret ExpireHeight uint64 `json:"expire_height"` // the block height by which the HTLC expires State HTLCState `json:"state"` // the state of the HTLC }
HTLC represents an HTLC
func NewHTLC ¶
func NewHTLC( sender sdk.AccAddress, to sdk.AccAddress, receiverOnOtherChain string, amount sdk.Coins, secret []byte, timestamp uint64, expireHeight uint64, state HTLCState, ) HTLC
NewHTLC constructs an HTLC
func (HTLC) HumanString ¶
func (h HTLC) HumanString(converter sdk.CoinsConverter) string
HumanString implements human
type HTLCState ¶
type HTLCState byte
HTLCState represents the state of an HTLC
func HTLCStateFromString ¶
func (HTLCState) MarshalJSON ¶
Marshals to JSON using string
func (*HTLCState) UnmarshalJSON ¶
Unmarshals from JSON
type MsgClaimHTLC ¶
type MsgClaimHTLC struct { Sender sdk.AccAddress `json:"sender"` // the initiator address HashLock []byte `json:"hash_lock"` // the hash lock identifying the HTLC to be claimed Secret []byte `json:"secret"` // the secret with which to claim }
MsgClaimHTLC represents a msg for claiming an HTLC
func NewMsgClaimHTLC ¶
func NewMsgClaimHTLC( sender sdk.AccAddress, hashLock []byte, secret []byte, ) MsgClaimHTLC
NewMsgClaimHTLC constructs a MsgClaimHTLC
func (MsgClaimHTLC) GetSigners ¶
func (msg MsgClaimHTLC) GetSigners() []sdk.AccAddress
Implements Msg.
func (MsgClaimHTLC) ValidateBasic ¶
func (msg MsgClaimHTLC) ValidateBasic() sdk.Error
Implements Msg.
type MsgCreateHTLC ¶
type MsgCreateHTLC struct { Sender sdk.AccAddress `json:"sender"` // the initiator address To sdk.AccAddress `json:"to"` // the destination address ReceiverOnOtherChain string `json:"receiver_on_other_chain"` // the claim receiving address on the other chain Amount sdk.Coins `json:"amount"` // the amount to be transferred HashLock []byte `json:"hash_lock"` // the hash lock generated from secret (and timestamp if provided) Timestamp uint64 `json:"timestamp"` // if provided, used to generate the hash lock together with secret TimeLock uint64 `json:"time_lock"` // the time span after which the HTLC will expire }
MsgCreateHTLC represents a msg for creating an HTLC
func NewMsgCreateHTLC ¶
func NewMsgCreateHTLC( sender sdk.AccAddress, to sdk.AccAddress, receiverOnOtherChain string, amount sdk.Coins, hashLock []byte, timestamp uint64, timeLock uint64, ) MsgCreateHTLC
NewMsgCreateHTLC constructs a MsgCreateHTLC
func (MsgCreateHTLC) GetSigners ¶
func (msg MsgCreateHTLC) GetSigners() []sdk.AccAddress
Implements Msg.
func (MsgCreateHTLC) ValidateBasic ¶
func (msg MsgCreateHTLC) ValidateBasic() sdk.Error
Implements Msg.
type MsgRefundHTLC ¶
type MsgRefundHTLC struct { Sender sdk.AccAddress `json:"sender"` // the initiator address HashLock []byte `json:"hash_lock"` // the hash lock identifying the HTLC to be refunded }
MsgRefundHTLC represents a msg for refund an HTLC
func NewMsgRefundHTLC ¶
func NewMsgRefundHTLC( sender sdk.AccAddress, hashLock []byte, ) MsgRefundHTLC
NewMsgClaimHTLC constructs a MsgClaimHTLC
func (MsgRefundHTLC) GetSigners ¶
func (msg MsgRefundHTLC) GetSigners() []sdk.AccAddress
Implements Msg.
func (MsgRefundHTLC) ValidateBasic ¶
func (msg MsgRefundHTLC) ValidateBasic() sdk.Error
Implements Msg.
type Params ¶
type Params struct { }
HTLC params
func (*Params) KeyValuePairs ¶
func (p *Params) KeyValuePairs() params.KeyValuePairs
func (*Params) StringFromBytes ¶
type QueryHTLCParams ¶
type QueryHTLCParams struct {
HashLock []byte
}
QueryHTLCParams is the query parameters for 'custom/htlc/htlc'