Tradehub.Tx (Tradehub v0.1.7) View Source

Link to this section Summary

Functions

Build a package for broadcasting arcoss the chain, the package includes the given messages, and signed by using the private key of the given tradehub Wallet

Link to this section Functions

Link to this function

build(messages, wallet, tx_memo \\ "", mode \\ :block)

View Source

Build a package for broadcasting arcoss the chain, the package includes the given messages, and signed by using the private key of the given tradehub Wallet

Packaging messages consists steps as below:

  1. Given raw messages that constist of the message type and an object containing the message params.
  2. Construct signing messages
  3. Construct the digest by marshalling the signing message into a JSON format, and applying the hash algorithm SHA256
  4. Sign the digest with the private key
  5. Combine the messages with its signatur, set fee, and memo if any.
  6. Complete Tx, mode: block to wait for the txn to be accepted into the block.

Examples

iex> wallet = Tradehub.Wallet.create_wallet()
iex> message = %{
...>  type: "order/CreateOrder",
...>  value: %{
...>     Market: "swth_eth",
...>     Side: "sell",
...>     Quantity: "200",
...>     Price: "1.01",
...>     Originator: "swth1z2jz4uhz8zgt4lq9mq5slz3ukyp3grhl7nsr4x"
...>   }
...> }
iex> Tradehub.Tx.build(message, wallet)