func (cl *OpencxRPC) SubmitOrder(args SubmitOrderArgs, reply *SubmitOrderReply) (err error) {

	// hash order.
	sha3 := sha3.New256()
	sha3.Write(args.Order.Serialize())
	e := sha3.Sum(nil)

	var sigPubKey *koblitz.PublicKey
	if sigPubKey, _, err = koblitz.RecoverCompact(koblitz.S256(), args.Signature, e); err != nil {
		err = fmt.Errorf("Error verifying order, invalid signature: \n%s", err)
		return
	}

	// try to parse the order pubkey into koblitz
	var orderPubkey *koblitz.PublicKey
	if orderPubkey, err = koblitz.ParsePubKey(args.Order.Pubkey[:], koblitz.S256()); err != nil {
		err = fmt.Errorf("Public Key failed parsing check: \n%s", err)
		return
	}

	if !sigPubKey.IsEqual(orderPubkey) {
		err = fmt.Errorf("Pubkey used with signature not equal to the one passed")
		return
	}

	// possible replay attack: if we're using the same pubkey for two exchanges and this is like a feature on the exchange, then an exchange could have you
	// place an order on their exchange, even with a nonce, and then send it over to the other exchange. When you submit an order on one exchange,
	// you essentially submit an order to all of them. But like once we have channels for orders then this isn't a thing anymore because the channel
	// tx's are signed and funding stuff is published on chain
	cl.Server.LockIngests()
	if reply.OrderID, err = cl.Server.OpencxDB.PlaceOrder(args.Order); err != nil {
		// gotta put these here cause if it errors out then oops just locked everything
		cl.Server.UnlockIngests()
		err = fmt.Errorf("Error placing order while submitting order: \n%s", err)
		return
	}
	cl.Server.UnlockIngests()

	logging.Infof("User %x submitted OrderID %s", sigPubKey.SerializeCompressed(), reply.OrderID)

	return
}
// SubmitOrder submits an order to the order book or throws an error
SubmitOrder submits an order to the order book or throws an error
// SubmitOrder submits an order to the order book or throws an error
func (cl *OpencxRPC) SubmitOrder(args SubmitOrderArgs, reply *SubmitOrderReply) (err error) {
	sha3 := sha3.New256()
	sha3.Write(args.Order.Serialize())
	e := sha3.Sum(nil)
	var sigPubKey *koblitz.PublicKey
	if sigPubKey, _, err = koblitz.RecoverCompact(koblitz.S256(), args.Signature, e); err != nil {
		err = fmt.Errorf("Error verifying order, invalid signature: \n%s", err)
		return
	}
	var orderPubkey *koblitz.PublicKey
	if orderPubkey, err = koblitz.ParsePubKey(args.Order.Pubkey[:], koblitz.S256()); err != nil {
		err = fmt.Errorf("Public Key failed parsing check: \n%s", err)
		return
	}
	if !sigPubKey.IsEqual(orderPubkey) {
		err = fmt.Errorf("Pubkey used with signature not equal to the one passed")
		return
	}
	cl.Server.LockIngests()
	if reply.OrderID, err = cl.Server.OpencxDB.PlaceOrder(args.Order); err != nil {
		cl.Server.UnlockIngests()
		err = fmt.Errorf("Error placing order while submitting order: \n%s", err)
		return
	}
	cl.Server.UnlockIngests()
	logging.Infof("User %x submitted OrderID %s", sigPubKey.SerializeCompressed(), reply.OrderID)
	return
}
func ( cl * OpencxRPC ) SubmitOrder ( args SubmitOrderArgs , reply * SubmitOrderReply ) ( err error ) { sha3 := sha3 . New256 ( ) sha3 . Write ( args . Order . Serialize ( ) ) e := sha3 . Sum ( nil ) var sigPubKey * koblitz . PublicKey if sigPubKey , _ , err = koblitz . RecoverCompact ( koblitz . S256 ( ) , args . Signature , e ) ; err != nil { err = fmt . Errorf ( " \n " , err ) return } var orderPubkey * koblitz . PublicKey if orderPubkey , err = koblitz . ParsePubKey ( args . Order . Pubkey [ : ] , koblitz . S256 ( ) ) ; err != nil { err = fmt . Errorf ( " \n " , err ) return } if ! sigPubKey . IsEqual ( orderPubkey ) { err = fmt . Errorf ( " " ) return } cl . Server . LockIngests ( ) if reply . OrderID , err = cl . Server . OpencxDB . PlaceOrder ( args . Order ) ; err != nil { cl . Server . UnlockIngests ( ) err = fmt . Errorf ( " \n " , err ) return } cl . Server . UnlockIngests ( ) logging . Infof ( " " , sigPubKey . SerializeCompressed ( ) , reply . OrderID ) return }
SubmitOrder submits an order to the order book or throws an error
SubmitOrder submits an order to the order book or throws an error
// hash order. // try to parse the order pubkey into koblitz // possible replay attack: if we're using the same pubkey for two exchanges and this is like a feature on the exchange, then an exchange could have you // place an order on their exchange, even with a nonce, and then send it over to the other exchange. When you submit an order on one exchange, // you essentially submit an order to all of them. But like once we have channels for orders then this isn't a thing anymore because the channel // tx's are signed and funding stuff is published on chain // gotta put these here cause if it errors out then oops just locked everything