BUYER SIDE LOGIC ParseLockOrder() parses a transaction for an embedded lock order messages in the memo field
(tx *lib.Transaction, deadlineBlocks uint64)
| 47 | |
| 48 | // ParseLockOrder() parses a transaction for an embedded lock order messages in the memo field |
| 49 | func (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 |
| 66 | func (s *StateMachine) ParseCloseOrder(tx *lib.Transaction) (co *lib.CloseOrder, ok bool) { |
no test coverage detected