Skip to content
This repository was archived by the owner on Nov 14, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions go/extensions/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@ func RegisterCodec(codec *amino.Codec) {
codec.RegisterConcrete(&MsgAddLiquidity{}, "irismod/coinswap/MsgAddLiquidity", nil)
codec.RegisterConcrete(&MsgRemoveLiquidity{}, "irismod/coinswap/MsgRemoveLiquidity", nil)
codec.RegisterConcrete(&CoinswapParams{}, "irismod/coinswap/Params", nil)
codec.RegisterConcrete(&MsgCreateHTLC{}, "irishub/htlc/MsgCreateHTLC", nil)
codec.RegisterConcrete(&MsgClaimHTLC{}, "irishub/htlc/MsgClaimHTLC", nil)
codec.RegisterConcrete(&MsgRefundHTLC{}, "irishub/htlc/MsgRefundHTLC", nil)

}
26 changes: 26 additions & 0 deletions go/extensions/htlc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package extensions

import (
sdk "github.com/cosmos/amino-js/go/lib/cosmos/cosmos-sdk/types"
)

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
}

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
}

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
}