MCPcopy
hub / github.com/canopy-network/canopy / ParseLockOrder

Method ParseLockOrder

fsm/swap.go:49–63  ·  view source on GitHub ↗

BUYER SIDE LOGIC ParseLockOrder() parses a transaction for an embedded lock order messages in the memo field

(tx *lib.Transaction, deadlineBlocks uint64)

Source from the content-addressed store, hash-verified

47
48// ParseLockOrder() parses a transaction for an embedded lock order messages in the memo field
49func (s *StateMachine) ParseLockOrder(tx *lib.Transaction, deadlineBlocks uint64) (bo *lib.LockOrder, ok bool) {
50 // create a new reference to a 'lock order' object in order to ensure a non-nil result
51 bo = new(lib.LockOrder)
52 // attempt to unmarshal the transaction memo into a 'lock order'
53 if err := lib.UnmarshalJSON([]byte(tx.Memo), bo); err == nil {
54 // sanity check some critical fields of the 'lock order' to ensure the unmarshal was successful
55 if len(bo.BuyerSendAddress) != 0 && len(bo.BuyerReceiveAddress) != 0 && bo.ChainId == s.Config.ChainId {
56 ok = true
57 }
58 // set the 'BuyerChainDeadline' in the 'lock order'
59 bo.BuyerChainDeadline = s.Height() + deadlineBlocks
60 }
61 // exit
62 return
63}
64
65// ParseCloseOrder() parses a transaction for an embedded close order messages in the memo field
66func (s *StateMachine) ParseCloseOrder(tx *lib.Transaction) (co *lib.CloseOrder, ok bool) {

Callers 1

Calls 2

HeightMethod · 0.95
UnmarshalJSONFunction · 0.92

Tested by

no test coverage detected