Skip to content

Wallet JSON RPC API Guide

MrT edited this page May 17, 2020 · 1 revision

RECENT CHANGES:

  • (16 May 2020) Creation for mwc Wallet v3.2.1

MWC Wallet API Guide

General Information

This doc is for the MWC Wallet API practical usage guide, NOT for the wallet API doc. For detailed wallet APIs reference, please read the DOCS.RS, and be careful to read the docs of proper version.

Wallet Configuration

By default, the wallet configuration file ~/.mwc/main/mwc-wallet.toml will be automatically generated on the 1st run of mwc-wallet. Floonet configuration is stored in a separate directory (~/.mwc/floo).

Note: On all following introductions, I will only write floo for floonet (the MWC Testnet). If you're running mainnet, please remember to remove --floo in command line, or replace floo as main in some URLs.

Some default configuration need to be modified according to your practical requirements:

1. Listen Interface:

#host IP for wallet listener, change to "0.0.0.0" to receive mwcs
api_listen_interface = "0.0.0.0"

And remember to double check the listening interface after you start wallet listening:

netstat -tlna | grep 13415

For example, my output is:

tcp        0      0 127.0.0.1:13415          0.0.0.0:*               LISTEN 

that means my wallet's listening on localhost only.

Note: For send-only wallet, it's OK to keep api_listen_interface = "127.0.0.1" as the default configuration for it.

2. API Secrets

On the 1st time running of MWC, a random API secret will be generated into ~/.mwc/floo/.api_secret file. You can use your own secret but please make sure using some kinds of password generator to ensure this secret has enough complexity.

#path of the secret token used by the API to authenticate the calls
#comment it to disable basic auth
api_secret_path = "/home/garyyu/.mwc/floo/.api_secret"

#location of the node api secret for basic auth on the MWC API
node_api_secret_path = "/home/garyyu/.mwc/floo/.api_secret"

#where the wallet should find a running node
check_node_api_http_addr = "http://127.0.0.1:13413"

These are my configurations, and yours should be different on the home directory name.

Regarding the check_node_api_http_addr, in my case I have a MWC server running on same server, so I can use "http://127.0.0.1:13413". If you're using an external MWC server, you can modify this to point to your MWC server. 3413 is the default node API port.

3. Owner API Port

#port for wallet owner api
owner_api_listen_port = 13420

You can change this owner API listening port as you want. On all the following examples, I will use 13420 as the port.

4. Owner API Include Foreign

#include the foreign API endpoints on the same port as the owner
#API. Useful for networking environments like AWS ECS that make
#it difficult to access multiple ports on a single service.
owner_api_include_foreign = true

I propose to change this as true for the convenience, if you don't want to run another process to run a listening wallet.

5. HTTPS

For the wallet which is listening on external network interface, it's a MUST to enable the https, unless you know exactly what you're doing by HTTP!

To enable https, for example we can configure the following TLS certificate files:

#path of TLS certificate file, self-signed certificates are not supported
tls_certificate_file = "/your/tls/certificate/file/fullchain.pem"
#private key for the TLS certificate
tls_certificate_key =  "/your/tls/certificate/key/privkey.pem"

Please replace these files with your own TLS certificate files.

If you want to use letsencrypt, you can refer to the Wallet TLS Setup Guide.

6. Wallet Data File Directory

By default, mwc wallet will create wallet data folder in ~/.mwc/floo/wallet_data. And you can modify this folder as you want, to put wallet_data into any location.

#where to find wallet files (seed, data, etc)
data_file_dir = "/home/garyyu/.mwc/floo/wallet_data"

In this wallet_data, you will find 3 types of files:

  • wallet database files: lmdb database.
  • wallet.seed: the encrypted wallet seed file.
  • saved_txs: the folder to save those raw transaction data, in file format, with the Shared Transaction Id (i.e. an UUID) as the file name. Note: only those sending transactions have the corresponding saved_txs file, and the purpose of this saved raw transaction data is for reposting, in case any failure of previous post_tx.
Here is an example in this `wallet_data` folder: (Click to expand)

$ tree  ~/.mwc/floo/wallet_data/
/home/garyyu/.mwc/floo/wallet_data/
├── db
│   └── lmdb
│       ├── data.mdb
│       └── lock.mdb
├── saved_txs
│   ├── 205d9cde-af28-44ff-b425-3be4a7e939dd.mwctx
│   ├── 4caee644-f8d1-4f5c-b3af-f11de5a41586.mwctx
│   ├── 507aa335-246d-4d6c-84bb-2516fb8e44ac.mwctx
│   ├── 78efaa87-f7c2-4fde-a14b-68338f9c32fd.mwctx
│   ├── 8ba033b6-3e05-4cad-81ec-937f3056b1e8.mwctx
│   ├── 8d2fc370-b442-41a5-b889-715a1dae9cf2.mwctx
│   ├── 8e298bd0-2bd5-4184-a810-3d0a9f6086b8.mwctx
│   ├── a063be0e-7523-4a1c-a993-ae3592c10191.mwctx
│   ├── b55a062a-32b4-45d1-b4d9-f921f922555a.mwctx
│   └── edea1387-a797-4a50-92b5-4cdadfae6052.mwctx
└── wallet.seed

7. Log Output

I suggest to enable both stdout and file log, as follows. And stdout_log_level = "Info", the "Info" level is better than "Warning" level for stdout, because with this you will get some immediate useful feedbacks when using some MWC wallet command.

#whether to log to stdout
log_to_stdout = true

#log level for stdout: Error, Warning, Info, Debug, Trace
stdout_log_level = "Info"

#whether to log to a file
log_to_file = true

#log level for file: Error, Warning, Info, Debug, Trace
file_log_level = "Info"

Wallet Query APIs

Note: For easiness of demo these APIs usage, I use curl to simulate JSON-RPC API calls, for all the following demo examples.

Wallet Summary Query

To get the same info as the mwc-wallet --floonet info command, we can use retrieve_summary_info API.

$ curl -0 -XPOST -u mwc:`cat ~/.mwc/floo/.api_secret` --data '{"jsonrpc":"2.0","method":"retrieve_summary_info","params":[true, 10],"id":1}' http://127.0.0.1:13420/v2/owner

An example output:

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "Ok": [
      true,
      {
        "amount_awaiting_confirmation": "0",
        "amount_awaiting_finalization": "40000000",
        "amount_currently_spendable": "7065600700000",
        "amount_immature": "0",
        "amount_locked": "0",
        "last_confirmed_height": "193352",
        "minimum_confirmations": "10",
        "total": "7065600700000"
      }
    ]
  }
}

Transaction Query

Transactions Query

We can use retrieve_txs API for transactions query.

Let's simulate this API call with curl:

$ curl -0 -XPOST -u mwc:`cat ~/.mwc/floo/.api_secret` --data '{ "jsonrpc": "2.0", "method": "retrieve_txs", "params": [true,null,null], "id": 1}' http://127.0.0.1:13420/v2/owner
The output example for above command: (Click to expand)

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "Ok": [
      true,
      [
        {
          "amount_credited": "60000000000",
          "amount_debited": "0",
          "confirmation_ts": "2019-06-21T12:03:43.109049686Z",
          "confirmed": true,
          "creation_ts": "2019-06-21T12:03:43.109048286Z",
          "fee": null,
          "id": 1,
          "messages": null,
          "num_inputs": 0,
          "num_outputs": 1,
          "parent_key_id": "0200000000000000000000000000000000",
          "stored_tx": null,
          "tx_slate_id": null,
          "tx_type": "ConfirmedCoinbase"
        },
        {
          "amount_credited": "60000000000",
          "amount_debited": "0",
          "confirmation_ts": "2019-06-21T12:03:43.129818991Z",
          "confirmed": true,
          "creation_ts": "2019-06-21T12:03:43.129817253Z",
          "fee": null,
          "id": 2,
          "messages": null,
          "num_inputs": 0,
          "num_outputs": 1,
          "parent_key_id": "0200000000000000000000000000000000",
          "stored_tx": null,
          "tx_slate_id": null,
          "tx_type": "ConfirmedCoinbase"
        },
        ... ...

        {
          "amount_credited": "1000000000",
          "amount_debited": "0",
          "confirmation_ts": "2019-06-21T12:43:18.359234610Z",
          "confirmed": true,
          "creation_ts": "2019-06-21T12:11:43.496157164Z",
          "fee": null,
          "id": 3,
          "messages": {
            "messages": [
              {
                "id": "0",
                "message": null,
                "message_sig": null,
                "public_key": "038642a1e00094b68d795bee4b3afb6bb8e4e0a6ffb081736f10a960649bc02236"
              },
              {
                "id": "1",
                "message": null,
                "message_sig": null,
                "public_key": "028f5cbb9f8b4a6c1b3453dbb462fe654d1a5e9630a84158a04d5d08ae1e00db8b"
              }
            ]
          },
          "num_inputs": 0,
          "num_outputs": 1,
          "parent_key_id": "0200000000000000000000000000000000",
          "stored_tx": null,
          "tx_slate_id": "5047360b-a744-42f1-8289-f991476335b4",
          "tx_type": "TxReceived"
        },
        {
          "amount_credited": "6964549700000",
          "amount_debited": "6965557700000",
          "confirmation_ts": "2019-06-30T09:52:49.801889070Z",
          "confirmed": true,
          "creation_ts": "2019-06-30T09:16:09.417729041Z",
          "fee": "8000000",
          "id": 558,
          "messages": {
            "messages": [
              {
                "id": "0",
                "message": "I love mwc, and you?",
                "message_sig": "a164ba9743ee8c22253abc3367b80c5a10aa5b7361adb71435e13595852d02eab2d20f25bad01409b8de9cc0360d194ba45382334742dc785cea6a7a036e8990",
                "public_key": "03cb478958608cffc7f20c82bc29762d7527c51924ce3fc0a514009d3fe106413d"
              },
              {
                "id": "1",
                "message": "Me too! Thanks for sending me these mwc/s.",
                "message_sig": "32397817d00d66e42581f269314f0dba752c73763b47d637b613d265d4b14bed0f889c10a848cdadc82b08a81c806895af71dea3d43b508236ec55a4cf7da217",
                "public_key": "029e95ab3cd5f1b3db5b8546cbd44cde631eb7a4f7a2c7815c1ce079f33eb5d1c3"
              }
            ]
          },
          "num_inputs": 1,
          "num_outputs": 1,
          "parent_key_id": "0200000000000000000000000000000000",
          "stored_tx": "1c2e8455-44a6-445e-a36d-d90c7b9b0825.mwctx",
          "tx_slate_id": "1c2e8455-44a6-445e-a36d-d90c7b9b0825",
          "tx_type": "TxSent"
        }
      ]
    ]
  }
}

Note:

  1. The tx_slate_id here is the Shared Transaction Id for wallet, it's a local generated random UUID, and this UUID is not stored in the blockchain (please don't mix it with Bitcoin/Ethereum TxId concept).
  2. When using wallet API for payment, it's important to cache this UUID, so as to query the transaction status with this UUID, for example using it here.

Single Transaction Query

Let's take another example here for a single transaction query, with its tx_slate_id:

$ curl -0 -XPOST -u mwc:`cat ~/.mwc/floo/.api_secret` --data '{ "jsonrpc": "2.0", "method": "retrieve_txs", "params": [true,null,"8ca6ffeb-3210-41db-86d8-ea206acf3263"], "id": 1}' http://127.0.0.1:13420/v2/owner
The output example for above command: (Click to expand)

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "Ok": [
      true,
      [
        {
          "amount_credited": "6965619700000",
          "amount_debited": "6965633700000",
          "confirmation_ts": null,
          "confirmed": false,
          "creation_ts": "2019-06-30T05:36:53.960744964Z",
          "fee": "4000000",
          "id": 555,
          "messages": {
            "messages": [
              {
                "id": "0",
                "message": null,
                "message_sig": null,
                "public_key": "0277946b150a05cf2884ea0f4bd3ad603497096f542e82713483f600a86f6b4a7a"
              },
              {
                "id": "1",
                "message": null,
                "message_sig": null,
                "public_key": "0329b4d61c64a4d5a44d6863b68aa2293a1256885b1cd1d25ec684eb5cbda04714"
              }
            ]
          },
          "num_inputs": 5,
          "num_outputs": 1,
          "parent_key_id": "0200000000000000000000000000000000",
          "stored_tx": "8ca6ffeb-3210-41db-86d8-ea206acf3263.mwctx",
          "tx_slate_id": "8ca6ffeb-3210-41db-86d8-ea206acf3263",
          "tx_type": "TxSentCancelled"
        }
      ]
    ]
  }
}

Outputs Query

UTXOs Query

We can use retrieve_outputs API for outputs query.

To simulate this API call with curl:

$ curl -0 -XPOST -u mwc:`cat ~/.mwc/floo/.api_secret` --data '{ "jsonrpc": "2.0", "method": "retrieve_outputs", "params": [false,true,null], "id": 1}' http://127.0.0.1:13420/v2/owner

In this example, we query the all UTXOs.

The output example for above command: (Click to expand)

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "Ok": [
      true,
      [
        {
          "commit": "08681123f8dd54db5a368eaae8b20864e86c116da302c8f69ef070dbe938e6b493",
          "output": {
            "commit": "08681123f8dd54db5a368eaae8b20864e86c116da302c8f69ef070dbe938e6b493",
            "height": "193360",
            "is_coinbase": false,
            "key_id": "0300000000000000000000010800000000",
            "lock_height": "0",
            "mmr_index": null,
            "n_child": 264,
            "root_key_id": "0200000000000000000000000000000000",
            "status": "Locked",
            "tx_log_entry": 556,
            "value": "6965593700000"
          }
        },
        {
          "commit": "098fc7bce4622e5629bba79418eb23b7d714eefb1ef8fb0fbfe15691920b469f51",
          "output": {
            "commit": "098fc7bce4622e5629bba79418eb23b7d714eefb1ef8fb0fbfe15691920b469f51",
            "height": "193396",
            "is_coinbase": false,
            "key_id": "0300000000000000000000010a00000000",
            "lock_height": "0",
            "mmr_index": null,
            "n_child": 266,
            "root_key_id": "0200000000000000000000000000000000",
            "status": "Unconfirmed",
            "tx_log_entry": 556,
            "value": "6965575700000"
          }
        }
      ]
    ]
  }
}

Query All Outputs

We can query all outputs (spent included) with same API, but remember, only those spent outputs stored in THIS wallet instance included. MimbleWimble / mwc doesn't always keep the spent outputs on chain (thanks to the cut-through feature).

For example:

$ curl -0 -XPOST -u mwc:`cat ~/.mwc/floo/.api_secret` --data '{ "jsonrpc": "2.0", "method": "retrieve_outputs", "params": [true,true,null], "id": 1}' http://127.0.0.1:13420/v2/owner

part of the query result:

The output example for above command: (Click to expand)

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "Ok": [
      true,
      [
        {
          "commit": "080c38d19b79f98366468d47061ce9de2340f880ea075b9f4373fa593964c47deb",
          "output": {
            "commit": "080c38d19b79f98366468d47061ce9de2340f880ea075b9f4373fa593964c47deb",
            "height": "399",
            "is_coinbase": true,
            "key_id": "0300000000000000000000000000000000",
            "lock_height": "1839",
            "mmr_index": "793",
            "n_child": 0,
            "root_key_id": "0200000000000000000000000000000000",
            "status": "Spent",
            "tx_log_entry": 352,
            "value": "60000000000"
          }
        },
        {
          "commit": "09401d14f7d0cc72e9373070332dfc4c7c7bc61b26e8759dff59e83e72fe1ece71",
          "output": {
            "commit": "09401d14f7d0cc72e9373070332dfc4c7c7bc61b26e8759dff59e83e72fe1ece71",
            "height": "400",
            "is_coinbase": true,
            "key_id": "0300000000000000000000000100000000",
            "lock_height": "1840",
            "mmr_index": "798",
            "n_child": 1,
            "root_key_id": "0200000000000000000000000000000000",
            "status": "Spent",
            "tx_log_entry": 352,
            "value": "60000000000"
          }
        },

        ... ...
        {
          "commit": "098fc7bce4622e5629bba79418eb23b7d714eefb1ef8fb0fbfe15691920b469f51",
          "output": {
            "commit": "098fc7bce4622e5629bba79418eb23b7d714eefb1ef8fb0fbfe15691920b469f51",
            "height": "193398",
            "is_coinbase": false,
            "key_id": "0300000000000000000000010a00000000",
            "lock_height": "0",
            "mmr_index": null,
            "n_child": 266,
            "root_key_id": "0200000000000000000000000000000000",
            "status": "Unspent",
            "tx_log_entry": 556,
            "value": "6965575700000"
          }
        },
        ... ...

        {
          "commit": "0864e11b3081e047aadcdcff34f9a2b4030fdb03dd8acfc549dede7565e859c563",
          "output": {
            "commit": "0864e11b3081e047aadcdcff34f9a2b4030fdb03dd8acfc549dede7565e859c563",
            "height": "182207",
            "is_coinbase": false,
            "key_id": "030000000000000000000002ea00000000",
            "lock_height": "0",
            "mmr_index": null,
            "n_child": 746,
            "root_key_id": "0200000000000000000000000000000000",
            "status": "Spent",
            "tx_log_entry": 518,
            "value": "11459721700000"
          }
        }
      ]
    ]
  }
}

Query Outputs of a Single Transaction

We can query all outputs in a one single transaction, but only transaction Input/s and Change Output/s.

For example, here is a query for transaction with tx_log_entry as 556:

$ curl -0 -XPOST -u mwc:`cat ~/.mwc/floo/.api_secret` --data '{ "jsonrpc": "2.0", "method": "retrieve_outputs", "params": [true,true,556], "id": 1}' http://127.0.0.1:13420/v2/owner

part of the query result:

The output example for above command: (Click to expand)

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "Ok": [
      true,
      [
        {
          "commit": "08681123f8dd54db5a368eaae8b20864e86c116da302c8f69ef070dbe938e6b493",
          "output": {
            "commit": "08681123f8dd54db5a368eaae8b20864e86c116da302c8f69ef070dbe938e6b493",
            "height": "193360",
            "is_coinbase": false,
            "key_id": "0300000000000000000000010800000000",
            "lock_height": "0",
            "mmr_index": null,
            "n_child": 264,
            "root_key_id": "0200000000000000000000000000000000",
            "status": "Spent",
            "tx_log_entry": 556,
            "value": "6965593700000"
          }
        },
        {
          "commit": "098fc7bce4622e5629bba79418eb23b7d714eefb1ef8fb0fbfe15691920b469f51",
          "output": {
            "commit": "098fc7bce4622e5629bba79418eb23b7d714eefb1ef8fb0fbfe15691920b469f51",
            "height": "193398",
            "is_coinbase": false,
            "key_id": "0300000000000000000000010a00000000",
            "lock_height": "0",
            "mmr_index": null,
            "n_child": 266,
            "root_key_id": "0200000000000000000000000000000000",
            "status": "Unspent",
            "tx_log_entry": 556,
            "value": "6965575700000"
          }
        }
      ]
    ]
  }
}

Wallet Sending via API

Http/s Method

For example:

$ curl -0 -XPOST -u mwc:`cat ~/.mwc/floo/.api_secret` --data '{ "jsonrpc": "2.0", "method": "init_send_tx", "params": {"args":{"src_acct_name":null, "amount":10000000, "minimum_confirmations":10, "max_outputs":500, "num_change_outputs":1, "selection_strategy_is_use_all":true, "message":null, "target_slate_version":null, "estimate_only":null, "send_args": {"method":"http", "dest":"https://demo.mwc.icu:13415", "finalize":true, "post_tx":true, "fluff":false}}}, "id": 1}' http://127.0.0.1:13420/v2/owner

Some additional notes on above parameters:

  1. amount is using Nano MWC as unit, i.e. 10^-9 MWC. For example, the amount 10000000 here means 0.01 MWC coins.
  2. both https and https share the same method name: http.
  3. "dest": "https://demo.mwc.icu:13415" here is using https. If you need use http, just modify the url as http://....
  4. For a simple case, normally we have one change output for self and another output for payee, that's why in this example I set "num_change_outputs": 1.
  5. "selection_strategy_is_use_all": true is the proposed setting (to make the chain has the minimum UTXO sets).
  6. "max_outputs" here means the maximum UTXOs can be used for this transaction. And it's a soft limit, when this is not enough to cover the whole output amount, the wallet will include more outputs. The proposed value here is 500.

The return result example for above call:

The output example for above command: (Click to expand)

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "Ok": {
      "amount": "10000000",
      "fee": "8000000",
      "height": "193396",
      "id": "3167a47b-ea6e-4e72-8f26-09eee4f0175d",
      "lock_height": "0",
      "num_participants": 2,
      "participant_data": [
        {
          "id": "0",
          "message": null,
          "message_sig": null,
          "part_sig": "7d20f79984b604dc721701f4f6627f246624932dcb3e9715a2897ed42eb5325623c1518e341b706f78e2faf509de2d1e6051f58d835400f12bfcc52659c3c02d",
          "public_blind_excess": "03dfa9872752d83d3ea47d5a27770649e5e4bae1a2cde2d3741efc2c0f74a2fd58",
          "public_nonce": "035632b52ed47e89a215973ecb2d932466247f62f6f4011772dc04b68499f7207d"
        },
        {
          "id": "1",
          "message": null,
          "message_sig": null,
          "part_sig": "361ca4cff12948c49af5a7e5b839ed0446637ca8633e80c11c79153f1c3637a44242f4602fb5801da122d829a4516c0b442ad5c32fc9834607a9db5ef1601a23",
          "public_blind_excess": "02cf834afd4d0afbb47c5b354b48cd20b15e50c5d22b66b84f243e484bf78ccd50",
          "public_nonce": "03a437361c3f15791cc1803e63a87c634604ed39b8e5a7f59ac44829f1cfa41c36"
        }
      ],
      "tx": {
        "body": {
          "inputs": [
            {
              "commit": "08681123f8dd54db5a368eaae8b20864e86c116da302c8f69ef070dbe938e6b493",
              "features": "Plain"
            }
          ],
          "kernels": [
            {
              "excess": "08ce4c54ef3fc20b06c2c6c8fb783cddd34f652aeb205bfaa3a222616ef2e90cf1",
              "excess_sig": "ee570aa64cef799c4490cc262bfea680b7d66b21c58a42a3564b9ba2a5c42ff5650346ef63d0f08c1905d31fae2f9a29a47bca51b31d843733a5a1854a24db50",
              "features": "Plain",
              "fee": "8000000",
              "lock_height": "0"
            }
          ],
          "outputs": [
            {
              "commit": "098fc7bce4622e5629bba79418eb23b7d714eefb1ef8fb0fbfe15691920b469f51",
              "features": "Plain",
              "proof": "ae78c8913ce9fc2543037f3336239c8c271af91aed2cd39020d33379aac0f6f36da0431f8e0bd628bfce8712f0f9d08d4b592597245eea657b9cfaabd45879bd01562e22278e98167e6ec775a92a8780ce31c9d11db7e63ec0101befa8e284e41db563282d86806a9cc8619ff64292c74757508d1254e3bf9f923c63a654129e13d8b106b0194c0975c741b9b800cb8287d56a46924a26d6552271aa15b2d7320735674d9d54a1ae6089eced69245a86fb2579d92195970608d3b8a5db71414d02aba9f0c31dae62b023ee63246738d49d3b7b2c416d78071ba4512d622f8059d40df6559d0a8fc4a97a8a3c2bbc3004fd17c1d4ac1bd2fc4fb05f8291da1e16b774014cad2b86ccd0d6ce8fd5e347198d9defdb4fdf5e7ea2a6c369e73d60cbb96e4af2ed631eb3da8dc18920b68d59a95cbc126c2d38f2fce2d4db2f1e9f000f6676c39ce39299e1e214fff4b365d28ad6456494788ddd19dba4f7a3dc2d15978c01d800a456a5e38a854416fa7554bc29c3615619e051b056ddbc13b5749814861af8d6afb6ed7b3385c8e5d6ee9aee6e424dca58e573f74029ec0210b0719e7374d2eb86ccd55f5e1bc3b52dadfda0ae3f088c380209cf131b7bb7f4f0ddd9e0bef0ff7578e214584fe6c789ff8559bb258f16b9eb55b7b27ad3cdfb99dcc846c50e0003292a4671689241a67f4ea482932d7b2c36e2385f009505a3cb747f55dc63ae649b3e29e12908c2071919e6c26453ac93a1cced36f4b18ee0abb73b89fb237db8963294c10b0c852843a5f55de4b26bcc3fd1e845f6cbb55e6e58f2a6d7c6c16a946ec3b93f3be0116ae61679ac029836124f5856a8d3eead5908e02b9aaaecd63c4fb64391a30eae6d55eb28aa3bb127727376b3dced38ae23c24230d90e70da6c326540e65171b43171794ecd972547898981a67cdc03ca75c74f4916"
            },
            {
              "commit": "085b19abbbe90304a65938fa919789f444ad289636d20a248c19fbfee571fd2b84",
              "features": "Plain",
              "proof": "9962ddc94844712aadbf16c56efeb114add9fbb4b62fde912c70277cd9a52903327e6c19afa43d887d9f25c2f7306a0c18ce63c00e81f1d25041c3dfdc3634390058f3c313e10538d2841eb2709dbfd05a03f86dcd44458c0b21ad4052b7ff2135ba854ca80d379f2e0f70711086f8659da3ae819fe5fc58d6daa6ea897157ea559f59b86591d2cbfcc9442368e75f0a07332c3ad08be27800a430c04c8e45e79f51db3064c6f743b9499d2466a99c7942e67da7a989bdb39c45ffb23512d4c79c714bafac27499cb68847b98d7245f477c6e739a6201a43d0b19adb5c98781c8af07d23dec31cb1eefe20a624d905715245cb016bd335bce8caf88870f1a5236c05fb0a4c535032436c0e255f4a3c45d865b4d8be82ed8a4cf7c1e3084e1b339c57b06a46c360037cda36f14a45b0861a75390b7465b7e94c453f819f780240a74154b616d7b4671cff14233656a19f02edace4724f0e2dac2b3e63b7271d64d47a037872cdf2398fbe220d3165c71dd9228805389934b3b2f3127450ab5a0dbbb6aa0498ab7b0be62ab04b8ec443ca8f3f98c03b054f71e55047ff84ae20d9b4813760f536ee64e498b5ff3a0a9012d521e2f95ca61ebd7c1c09c77abcf9cf19b2d559468500fbdbda9811670eeca97550f76d9ddd83054424c7001d2ec0e32856fb3063dfc9624be002ac73b2f7d64582ee0f08cda257249dd6d37866dc34028c6e4c9e330bc50307e47b77e046148bcf64b809f94ddfbdb15abdf62d5caae9ee33011f41ff1890d1b335e98c78c5555f443679e159be8275d6835085dea5606610651575657ef270d74ed409659ddb0871a3775ce139ae8521c852abd4147bdfe284551f91bd6cc184f552c88196f972e677215e057838dc1563fb7524b9745a5239188b564d9c7cbad808adf4226ed152988c1f20e6863e011ab4ff56ab0ee246"
            }
          ]
        },
        "offset": "6f74066e2f32fc622342de903aaf821de4053702f9aaa3ec006a28797de66215"
      },
      "version_info": {
        "block_header_version": 2,
        "orig_version": 2,
        "version": 2
      }
    }
  }
}

File Method

For some use cases, the file method is useful. For example, payment by email, or by file download/upload plus a finalize step, in which case the user will login to the website and request a payout, and then download a raw transaction file, then execute a receive on his/her local MWC wallet, and then upload the output file, and the website will call the finalize once the uploading is completed, and call the last step post. Payment by email is similar.

1st Step

The payer create a slate with init_send_tx API:

For example:

$ curl -0 -XPOST -u mwc:`cat ~/.mwc/floo/.api_secret` --data '{ "jsonrpc": "2.0", "method": "init_send_tx", "params": {"args":{"src_acct_name":null, "amount":1000000000, "minimum_confirmations":10, "max_outputs":100, "num_change_outputs":1, "selection_strategy_is_use_all":true, "message":"I love mwc, and you?", "target_slate_version":null, "estimate_only":null, "send_args": null}}, "id": 1}' http://127.0.0.1:13420/v2/owner  > init.result.json 2>/dev/null && cat init.result.json | jq '.result .Ok' > slate.init.json && cat init.result.json

The return result example for above call:

The output example for above command: (Click to expand)

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "Ok": {
      "amount": "1000000000",
      "fee": "8000000",
      "height": "193590",
      "id": "1c2e8455-44a6-445e-a36d-d90c7b9b0825",
      "lock_height": "0",
      "num_participants": 2,
      "participant_data": [
        {
          "id": "0",
          "message": "I love mwc, and you?",
          "message_sig": "a164ba9743ee8c22253abc3367b80c5a10aa5b7361adb71435e13595852d02eab2d20f25bad01409b8de9cc0360d194ba45382334742dc785cea6a7a036e8990",
          "part_sig": null,
          "public_blind_excess": "03cb478958608cffc7f20c82bc29762d7527c51924ce3fc0a514009d3fe106413d",
          "public_nonce": "0256f15f9f1cdbb3671ee5b56809619e0754745300744e6c8817987b08340a0cfa"
        }
      ],
      "tx": {
        "body": {
          "inputs": [
            {
              "commit": "081f591e1882b8615e1f170dd61298477ecb6f4d39c95cf320fcd27826adc3df0a",
              "features": "Plain"
            }
          ],
          "kernels": [
            {
              "excess": "000000000000000000000000000000000000000000000000000000000000000000",
              "excess_sig": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
              "features": "Plain",
              "fee": "8000000",
              "lock_height": "0"
            }
          ],
          "outputs": [
            {
              "commit": "09736b1291f209589f874fd33e93833b68523af9b6c284b55c02692fd6831f199d",
              "features": "Plain",
              "proof": "4adbd1de0fdb25ea6fbf0efdc7b21b1f8c2e2380f6f0f56ed2be5bc67a9a0c1c1d7522f050d053d893da31f6df657b922c8399bf78ace1a422e7f86f06967b060bdc5299fbea5d6995ddcefc4ad5fae8c1b13ee66a98e4011c94140df71c3a421f47a87d375d847fe553c4027323c1b4ee6246835a9edb9af71e31681208dcf26a34d9cf5e0ba860f1888fe22208cd7edbc7a7d80ef27d648c34a9b216cf033a9ed802d23c0f426eb50035f55632a060a8ca7ab7a5b98fa3a77390ebddc7db3f499957036083bb1def746c62592217ea0ab3d395b06c46f5d527b443e02a7879b1ca4df4414ce06031019db04bba917aeea068ae7aa7c73d21a49a0bfd8b8f020235230c3b7306f65d8d96a06323cbdd2442494adc3c75d4eaac0487af08827decdcc3748e20e4f85ea90cb4ebf8a07ddbdeea1ad30177fb4b24cff7b9358f03a90e172f8096d4d2758bae1e0b07ec37a2eb36c0e125d6e72863eccdfd0f22c22622037aa0bc09c402a5f27fa07ddc92e9f8cfe84b946a2dee49a03d94c2819c3667323d9915c281603a509af6d15dc44a021318632c568cfac146e944e8e6b22267d50986af586f335c3f570596fc048deb54699dfdab55276bfe748523f5b083daef4682bf57a9b6bdda421ef87695ad7ec13b53b1cd00fdcdb0e08129139a03e0a52494838eb71099a61207e51b1b5122a9c4156bcef0230a2d6a3e88fede4366fb8824f1491a21e0914afcbc07d5e73fafe626ff91949f8df34254581ab6bdcbe0c80bfa910090055c0cede8c94b6a4864c48c8517bda0624bb8b833b3fd75b727e2f529a3e33ca52603f625b023550e46bc71a16a70d3d2fc9a847f119f9c2de978bab7ca4f2f05e876e884f7fc5e0f1906bd350fd91a2fb6f76c06191e6aed1182de4df902cd7d6c6bd98cc25e57a6a266d5fda44ef2c0d8ab0e37ecb9330333"
            }
          ]
        },
        "offset": "58802ba1a28cf85f5cbce6609136ec52face77dfd50f043ccb5fa4875964f746"
      },
      "version_info": {
        "block_header_version": 2,
        "orig_version": 2,
        "version": 2
      }
    }
  }
}

2nd Step

The payer need call a tx_lock_outputs API to lock the transaction Input/s.

For example:

$ slate=$(cat slate.init.json | jq --compact-output .) ; curl -0 -XPOST -u mwc:`cat ~/.mwc/floo/.api_secret` --data '{ "jsonrpc": "2.0", "method": "tx_lock_outputs", "params": ['"$slate"', 0], "id": 1}' http://127.0.0.1:13420/v2/owner

And the result of above call:

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "Ok": null
  }
}

As optional, you can query this transaction at this time. The call looks like this for above example:

$ curl -0 -XPOST -u mwc:`cat ~/.mwc/floo/.api_secret` --data '{ "jsonrpc": "2.0", "method": "retrieve_txs", "params": [true,null,"1c2e8455-44a6-445e-a36d-d90c7b9b0825"], "id": 1}' http://127.0.0.1:13420/v2/owner

3rd Step

This should be executed by the payment receiver! Remember that the mwc transaction is an interactive procedure.

Suppose the payee already downloaded the file slate.init.json, and ask him/her to run following command on his local wallet:

$ mwc-wallet --floonet receive -i slate.init.json

and this command will generate file slate.init.json.response, in the same folder as slate.init.json.

Then the payee need upload this slate.init.json.response file to the payer.

In case the receiver (payee) is also using the owner API, the following will introduce the API usage to do the same thing.

Verify Slate Messages

Firstly, as an optional step, the receiver can call a verify_slate_messages API to verify the slate message signature (if have):

$ slate=$(cat slate.init.json | jq --compact-output .); curl -0 -XPOST -u mwc:`cat ~/.mwc/floo/.api_secret` --data '{ "jsonrpc": "2.0", "method": "verify_slate_messages", "params": ['"$slate"'], "id": 1}' http://127.0.0.1:13420/v2/foreign

The wallet log and the returned result of above call looks like:

20190630 17:33:43.235 INFO mwc_wallet_libwallet::slate - verify_messages - signature verified ok. Participant message: "I love mwc, and you?"

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "Ok": null
  }
}

Receive Tx

And then, the receiver can call the receive_tx API:

For example:

$ slate=$(cat slate.init.json | jq --compact-output .); curl -0 -XPOST -u mwc:`cat ~/.mwc/floo/.api_secret` --data '{ "jsonrpc": "2.0", "method": "receive_tx", "params": ['"$slate"',"default","Me too! Thanks for sending me these mwc/s."], "id": 1}' http://127.0.0.1:13420/v2/foreign > recv.result.json 2>/dev/null && cat recv.result.json | jq '.result .Ok' > slate.rx.json && cat recv.result.json

The return of above example:

The output example for above command: (Click to expand)

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "Ok": {
      "amount": "1000000000",
      "fee": "8000000",
      "height": "193590",
      "id": "1c2e8455-44a6-445e-a36d-d90c7b9b0825",
      "lock_height": "0",
      "num_participants": 2,
      "participant_data": [
        {
          "id": "0",
          "message": "I love mwc, and you?",
          "message_sig": "a164ba9743ee8c22253abc3367b80c5a10aa5b7361adb71435e13595852d02eab2d20f25bad01409b8de9cc0360d194ba45382334742dc785cea6a7a036e8990",
          "part_sig": null,
          "public_blind_excess": "03cb478958608cffc7f20c82bc29762d7527c51924ce3fc0a514009d3fe106413d",
          "public_nonce": "0256f15f9f1cdbb3671ee5b56809619e0754745300744e6c8817987b08340a0cfa"
        },
        {
          "id": "1",
          "message": "Me too! Thanks for sending me these mwc/s.",
          "message_sig": "32397817d00d66e42581f269314f0dba752c73763b47d637b613d265d4b14bed0f889c10a848cdadc82b08a81c806895af71dea3d43b508236ec55a4cf7da217",
          "part_sig": "9aac184e622085872de3ee3c5faea71b4c43c251c8c0cbb8f5ce30b5895be1b4e322c2fc81be3dfef68718b2a474a10c2c0a9c1e23f08e79f01c887d1d413222",
          "public_blind_excess": "029e95ab3cd5f1b3db5b8546cbd44cde631eb7a4f7a2c7815c1ce079f33eb5d1c3",
          "public_nonce": "02b4e15b89b530cef5b8cbc0c851c2434c1ba7ae5f3ceee32d878520624e18ac9a"
        }
      ],
      "tx": {
        "body": {
          "inputs": [
            {
              "commit": "081f591e1882b8615e1f170dd61298477ecb6f4d39c95cf320fcd27826adc3df0a",
              "features": "Plain"
            }
          ],
          "kernels": [
            {
              "excess": "000000000000000000000000000000000000000000000000000000000000000000",
              "excess_sig": "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
              "features": "Plain",
              "fee": "8000000",
              "lock_height": "0"
            }
          ],
          "outputs": [
            {
              "commit": "089bff920a0a84baf5a7b4635759cdcf8d48c9f95bd7f96c40aeb858b4a70ffb4b",
              "features": "Plain",
              "proof": "21fe767fc29a710e9f693a40eee519378cfe528829511af2da2f792cdaa62ab44f039808a5472e463ea81eb42dcae74a6519201c86565546a041a897186cbc56012c5abacfdc08cf93644d096fdf10d01002e5baa19f7e226490a74e9c9610f1873baf2606bd97fa79c8e60e79e33ff78f882d5e2b8f2e3652e1981f82c7a10e44a2997a11a36bb50f8c8229d0869db597458c292b8c48c56c3a21cae22cfc82e7a97a9a0a3b204202e0767e5a562cd98a76277bb380866d50ff36b30bf8eb7673bd9daa5fe66f92a7e7a3cbb378cd2a7ff09f1840a20caf3c5c05157e06af6795cb0632994ab245dd8b24b739f7bc9252e8689551248605c4cf249098a1b64e6ee44cec49d0aad5680ab833db5cc9d91074437fb3dac5bbbd2a5b5c2f8745ba6a50de299f80311a0472d9f16ab3fc28f3379ff26400b8d57f641ce715442ed922c052fad93c343b9d4934994ab192d92f93b459c7fab6ddea85188c67dee9a055e401e5542686fa2710fbf662df27fbc47b6ee9a8b14c671eef1e92582d65f08aa1245d206e92e9813ac4447f1215196e986d447268a38d74f20a3cfd9f22f766e49823aac3d83f71f59c6208f8cbbc09fbc6ec798d53d16c3d474e73b0c7f85bbc49b7aeefe838e20b5a4ed29ead2e29e799599788f8a508d2db615f59e93f457e2e900eed3b8bda2d6461f2e07cbcb2a41a49ac8dbae571898a1832bd2f4a2c4340ff64b94e500b73a29b4cbab9b9c639edb492c70bef049c59525463a8c0d8faf1847d6ca7561bffbae56f1879f94c17ec3562a70eb1d774e6c7a7307e606d91ea365f74e640135bff29d3f91bb537cc8eb47b444a98442b678784014d08b653b5b1bfb272c698be4d26df6c45d556e962f8fde2c2c9442fc4aa109f752c562cbccdee74c329fd96b9b8752b9d21a329a27593c351b816a13c26709b926ed3a63f"
            },
            {
              "commit": "09736b1291f209589f874fd33e93833b68523af9b6c284b55c02692fd6831f199d",
              "features": "Plain",
              "proof": "4adbd1de0fdb25ea6fbf0efdc7b21b1f8c2e2380f6f0f56ed2be5bc67a9a0c1c1d7522f050d053d893da31f6df657b922c8399bf78ace1a422e7f86f06967b060bdc5299fbea5d6995ddcefc4ad5fae8c1b13ee66a98e4011c94140df71c3a421f47a87d375d847fe553c4027323c1b4ee6246835a9edb9af71e31681208dcf26a34d9cf5e0ba860f1888fe22208cd7edbc7a7d80ef27d648c34a9b216cf033a9ed802d23c0f426eb50035f55632a060a8ca7ab7a5b98fa3a77390ebddc7db3f499957036083bb1def746c62592217ea0ab3d395b06c46f5d527b443e02a7879b1ca4df4414ce06031019db04bba917aeea068ae7aa7c73d21a49a0bfd8b8f020235230c3b7306f65d8d96a06323cbdd2442494adc3c75d4eaac0487af08827decdcc3748e20e4f85ea90cb4ebf8a07ddbdeea1ad30177fb4b24cff7b9358f03a90e172f8096d4d2758bae1e0b07ec37a2eb36c0e125d6e72863eccdfd0f22c22622037aa0bc09c402a5f27fa07ddc92e9f8cfe84b946a2dee49a03d94c2819c3667323d9915c281603a509af6d15dc44a021318632c568cfac146e944e8e6b22267d50986af586f335c3f570596fc048deb54699dfdab55276bfe748523f5b083daef4682bf57a9b6bdda421ef87695ad7ec13b53b1cd00fdcdb0e08129139a03e0a52494838eb71099a61207e51b1b5122a9c4156bcef0230a2d6a3e88fede4366fb8824f1491a21e0914afcbc07d5e73fafe626ff91949f8df34254581ab6bdcbe0c80bfa910090055c0cede8c94b6a4864c48c8517bda0624bb8b833b3fd75b727e2f529a3e33ca52603f625b023550e46bc71a16a70d3d2fc9a847f119f9c2de978bab7ca4f2f05e876e884f7fc5e0f1906bd350fd91a2fb6f76c06191e6aed1182de4df902cd7d6c6bd98cc25e57a6a266d5fda44ef2c0d8ab0e37ecb9330333"
            }
          ]
        },
        "offset": "58802ba1a28cf85f5cbce6609136ec52face77dfd50f043ccb5fa4875964f746"
      },
      "version_info": {
        "block_header_version": 2,
        "orig_version": 2,
        "version": 2
      }
    }
  }
}

4th Step

Once the payer received above uploaded file slate.rx.json, call the finalize_tx API with the file.

But before that, we can still use an optional step to verify the slate message signature. For example:

$ slate=$(cat slate.rx.json | jq --compact-output .); curl -0 -XPOST -u mwc:`cat ~/.mwc/floo/.api_secret` --data '{ "jsonrpc": "2.0", "method": "verify_slate_messages", "params": ['"$slate"'], "id": 1}' http://127.0.0.1:13420/v2/owner

The wallet log and returned result of above call will look like this:

20190630 09:41:08.263 INFO mwc_wallet_libwallet::slate - verify_messages - signature verified ok. Participant message: "I love mwc, and you?"
20190630 09:41:08.264 INFO mwc_wallet_libwallet::slate - verify_messages - signature verified ok. Participant message: "Me too! Thanks for sending me these mwc/s."

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "Ok": null
  }
}

But we can also skip above verification and directly call finalize_tx. For example:

$ slate=$(cat slate.rx.json | jq --compact-output .) ; curl -0 -XPOST -u mwc:`cat ~/.mwc/floo/.api_secret` --data '{ "jsonrpc": "2.0", "method": "finalize_tx", "params": ['"$slate"'], "id": 1}' http://127.0.0.1:13420/v2/owner > finalize.result.json 2>/dev/null && cat finalize.result.json | jq '.result .Ok .tx' > slate.final.json && cat finalize.result.json

The return of above example:

The output example for above command: (Click to expand)

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "Ok": {
      "amount": "1000000000",
      "fee": "8000000",
      "height": "193590",
      "id": "1c2e8455-44a6-445e-a36d-d90c7b9b0825",
      "lock_height": "0",
      "num_participants": 2,
      "participant_data": [
        {
          "id": "0",
          "message": "I love mwc, and you?",
          "message_sig": "a164ba9743ee8c22253abc3367b80c5a10aa5b7361adb71435e13595852d02eab2d20f25bad01409b8de9cc0360d194ba45382334742dc785cea6a7a036e8990",
          "part_sig": "fa0c0a34087b9817886c4e7400537454079e610968b5e51e67b3db1c9f5ff1563bcb3d4550639bb5ad773ff90839d05d2163c434b16fe2afa56aa11080ccea9f",
          "public_blind_excess": "03cb478958608cffc7f20c82bc29762d7527c51924ce3fc0a514009d3fe106413d",
          "public_nonce": "0256f15f9f1cdbb3671ee5b56809619e0754745300744e6c8817987b08340a0cfa"
        },
        {
          "id": "1",
          "message": "Me too! Thanks for sending me these mwc/s.",
          "message_sig": "32397817d00d66e42581f269314f0dba752c73763b47d637b613d265d4b14bed0f889c10a848cdadc82b08a81c806895af71dea3d43b508236ec55a4cf7da217",
          "part_sig": "9aac184e622085872de3ee3c5faea71b4c43c251c8c0cbb8f5ce30b5895be1b4e322c2fc81be3dfef68718b2a474a10c2c0a9c1e23f08e79f01c887d1d413222",
          "public_blind_excess": "029e95ab3cd5f1b3db5b8546cbd44cde631eb7a4f7a2c7815c1ce079f33eb5d1c3",
          "public_nonce": "02b4e15b89b530cef5b8cbc0c851c2434c1ba7ae5f3ceee32d878520624e18ac9a"
        }
      ],
      "tx": {
        "body": {
          "inputs": [
            {
              "commit": "081f591e1882b8615e1f170dd61298477ecb6f4d39c95cf320fcd27826adc3df0a",
              "features": "Plain"
            }
          ],
          "kernels": [
            {
              "excess": "08266e05ce76d75dab770d278f7c59062a1d4e707a3a914f56852e3a63ce30123c",
              "excess_sig": "1cc7781a51004bfbc7bfca192b2fde8004d8b4a59559ee711d849c2b927181251eeeff41d221d9b3a4ff57abadad716a4d6d6053d45f71299687298e9d0d1dc2",
              "features": "Plain",
              "fee": "8000000",
              "lock_height": "0"
            }
          ],
          "outputs": [
            {
              "commit": "089bff920a0a84baf5a7b4635759cdcf8d48c9f95bd7f96c40aeb858b4a70ffb4b",
              "features": "Plain",
              "proof": "21fe767fc29a710e9f693a40eee519378cfe528829511af2da2f792cdaa62ab44f039808a5472e463ea81eb42dcae74a6519201c86565546a041a897186cbc56012c5abacfdc08cf93644d096fdf10d01002e5baa19f7e226490a74e9c9610f1873baf2606bd97fa79c8e60e79e33ff78f882d5e2b8f2e3652e1981f82c7a10e44a2997a11a36bb50f8c8229d0869db597458c292b8c48c56c3a21cae22cfc82e7a97a9a0a3b204202e0767e5a562cd98a76277bb380866d50ff36b30bf8eb7673bd9daa5fe66f92a7e7a3cbb378cd2a7ff09f1840a20caf3c5c05157e06af6795cb0632994ab245dd8b24b739f7bc9252e8689551248605c4cf249098a1b64e6ee44cec49d0aad5680ab833db5cc9d91074437fb3dac5bbbd2a5b5c2f8745ba6a50de299f80311a0472d9f16ab3fc28f3379ff26400b8d57f641ce715442ed922c052fad93c343b9d4934994ab192d92f93b459c7fab6ddea85188c67dee9a055e401e5542686fa2710fbf662df27fbc47b6ee9a8b14c671eef1e92582d65f08aa1245d206e92e9813ac4447f1215196e986d447268a38d74f20a3cfd9f22f766e49823aac3d83f71f59c6208f8cbbc09fbc6ec798d53d16c3d474e73b0c7f85bbc49b7aeefe838e20b5a4ed29ead2e29e799599788f8a508d2db615f59e93f457e2e900eed3b8bda2d6461f2e07cbcb2a41a49ac8dbae571898a1832bd2f4a2c4340ff64b94e500b73a29b4cbab9b9c639edb492c70bef049c59525463a8c0d8faf1847d6ca7561bffbae56f1879f94c17ec3562a70eb1d774e6c7a7307e606d91ea365f74e640135bff29d3f91bb537cc8eb47b444a98442b678784014d08b653b5b1bfb272c698be4d26df6c45d556e962f8fde2c2c9442fc4aa109f752c562cbccdee74c329fd96b9b8752b9d21a329a27593c351b816a13c26709b926ed3a63f"
            },
            {
              "commit": "09736b1291f209589f874fd33e93833b68523af9b6c284b55c02692fd6831f199d",
              "features": "Plain",
              "proof": "4adbd1de0fdb25ea6fbf0efdc7b21b1f8c2e2380f6f0f56ed2be5bc67a9a0c1c1d7522f050d053d893da31f6df657b922c8399bf78ace1a422e7f86f06967b060bdc5299fbea5d6995ddcefc4ad5fae8c1b13ee66a98e4011c94140df71c3a421f47a87d375d847fe553c4027323c1b4ee6246835a9edb9af71e31681208dcf26a34d9cf5e0ba860f1888fe22208cd7edbc7a7d80ef27d648c34a9b216cf033a9ed802d23c0f426eb50035f55632a060a8ca7ab7a5b98fa3a77390ebddc7db3f499957036083bb1def746c62592217ea0ab3d395b06c46f5d527b443e02a7879b1ca4df4414ce06031019db04bba917aeea068ae7aa7c73d21a49a0bfd8b8f020235230c3b7306f65d8d96a06323cbdd2442494adc3c75d4eaac0487af08827decdcc3748e20e4f85ea90cb4ebf8a07ddbdeea1ad30177fb4b24cff7b9358f03a90e172f8096d4d2758bae1e0b07ec37a2eb36c0e125d6e72863eccdfd0f22c22622037aa0bc09c402a5f27fa07ddc92e9f8cfe84b946a2dee49a03d94c2819c3667323d9915c281603a509af6d15dc44a021318632c568cfac146e944e8e6b22267d50986af586f335c3f570596fc048deb54699dfdab55276bfe748523f5b083daef4682bf57a9b6bdda421ef87695ad7ec13b53b1cd00fdcdb0e08129139a03e0a52494838eb71099a61207e51b1b5122a9c4156bcef0230a2d6a3e88fede4366fb8824f1491a21e0914afcbc07d5e73fafe626ff91949f8df34254581ab6bdcbe0c80bfa910090055c0cede8c94b6a4864c48c8517bda0624bb8b833b3fd75b727e2f529a3e33ca52603f625b023550e46bc71a16a70d3d2fc9a847f119f9c2de978bab7ca4f2f05e876e884f7fc5e0f1906bd350fd91a2fb6f76c06191e6aed1182de4df902cd7d6c6bd98cc25e57a6a266d5fda44ef2c0d8ab0e37ecb9330333"
            }
          ]
        },
        "offset": "58802ba1a28cf85f5cbce6609136ec52face77dfd50f043ccb5fa4875964f746"
      },
      "version_info": {
        "block_header_version": 2,
        "orig_version": 2,
        "version": 2
      }
    }
  }
}

The last Step

The sender need call the post_tx API with the finalize_tx API outputs from above step.

Suppose we save the final slate as a file slate.final.json, then, let's still use curl to simulate this API call:

$ slate=$(cat slate.final.json | jq --compact-output .) ; curl -0 -XPOST -u mwc:`cat ~/.mwc/floo/.api_secret` --data '{ "jsonrpc": "2.0", "method": "post_tx", "params": ['"$slate"', false], "id": 1}' http://127.0.0.1:13420/v2/owner

The example output of above call:

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "Ok": null
  }
}

Cancel a Transaction

When a transaction is not posted yet, we can cancel it via cancel_tx API.

For example, with the known transaction slate id, we can call it with:

$ curl -0 -XPOST -u mwc:`cat ~/.mwc/floo/.api_secret` --data '{ "jsonrpc": "2.0", "method": "cancel_tx", "params": [null, "8ca6ffeb-3210-41db-86d8-ea206acf3263"], "id": 1}' http://127.0.0.1:13420/v2/owner

{
  "id": 1,
  "jsonrpc": "2.0",
  "result": {
    "Ok": null
  }
}
Clone this wiki locally