From 99a0421ed40641310495f48fd11a81838e65aa54 Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 25 Jul 2024 23:54:27 +0800 Subject: [PATCH 1/9] add extra cols for gui and version in MM2.db table --- .../tutorials/query-the-mm2-database/index.mdx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx b/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx index 401c755f..602fd8df 100644 --- a/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx +++ b/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx @@ -52,6 +52,11 @@ This table keeps a detailed record of all swaps performed (including failed) in | 14 | taker\_coin\_usd\_price | DECIMAL | USD price of taker coin at the time of the swap | | 15 | taker\_pubkey | DECIMAL | Taker pubkey | | 16 | maker\_pubkey | DECIMAL | Maker pubkey | +| 17 | maker\_gui | DECIMAL | Maker application | +| 18 | taker\_gui | DECIMAL | Taker application | +| 19 | maker\_version | DECIMAL | Maker KDF binary version | +| 20 | taker\_version | DECIMAL | Taker KDF binary version | + #### Query: @@ -60,7 +65,7 @@ This table keeps a detailed record of all swaps performed (including failed) in #### Response: ```bash -8|DGB|DOGE|c9515636-f5a4-4767-a0af-c69e59086899|1678815183|1678815631|200|28|1|DGB||DOGE||0.0108|0.07673|02d8064eece4fa5c0f8dc0267f68cee9bdd527f9e88f3594a323428718c391ecc2|03a93f666b9030958f282edd2904f0a33278c0c676ae132d2094840fe722f011c3 +8|DGB|DOGE|c9515636-f5a4-4767-a0af-c69e59086899|1678815183|1678815631|200|28|1|DGB||DOGE||0.0108|0.07673|02d8064eece4fa5c0f8dc0267f68cee9bdd527f9e88f3594a323428718c391ecc2|03a93f666b9030958f282edd2904f0a33278c0c676ae132d2094840fe722f011c3|mm2_777|web_dex web|2.1.0-beta_c5e0e00|2.1.0-beta_af571608c ``` ## my\_orders From 4d8deb3281a2fcd4efd236736c7cb6e58995d346 Mon Sep 17 00:00:00 2001 From: smk762 Date: Fri, 26 Jul 2024 00:10:54 +0800 Subject: [PATCH 2/9] fix column types --- .../tutorials/query-the-mm2-database/index.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx b/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx index 602fd8df..4f9ff097 100644 --- a/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx +++ b/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx @@ -52,10 +52,10 @@ This table keeps a detailed record of all swaps performed (including failed) in | 14 | taker\_coin\_usd\_price | DECIMAL | USD price of taker coin at the time of the swap | | 15 | taker\_pubkey | DECIMAL | Taker pubkey | | 16 | maker\_pubkey | DECIMAL | Maker pubkey | -| 17 | maker\_gui | DECIMAL | Maker application | -| 18 | taker\_gui | DECIMAL | Taker application | -| 19 | maker\_version | DECIMAL | Maker KDF binary version | -| 20 | taker\_version | DECIMAL | Taker KDF binary version | +| 17 | maker\_gui | VARCHAR(255) | Maker application | +| 18 | taker\_gui | VARCHAR(255) | Taker application | +| 19 | maker\_version | VARCHAR(255) | Maker KDF binary version | +| 20 | taker\_version | VARCHAR(255) | Taker KDF binary version | #### Query: From 17c4a6a6ec857f3ec470b854c6167d51f0735a18 Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 25 Jul 2024 16:28:32 +0000 Subject: [PATCH 3/9] [Bot] File and author data updated, validated and updated internal links, formatted md content, checked presence of file and dirs based on sidebar, checked presence of h1 in every file, update Komodo DeFi Framework methods table, adds/updates preview images when base is main --- .../tutorials/query-the-mm2-database/index.mdx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx b/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx index 4f9ff097..96554f52 100644 --- a/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx +++ b/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx @@ -57,7 +57,6 @@ This table keeps a detailed record of all swaps performed (including failed) in | 19 | maker\_version | VARCHAR(255) | Maker KDF binary version | | 20 | taker\_version | VARCHAR(255) | Taker KDF binary version | - #### Query: `sqlite3 ${PATH_TO_MM2_DB_FILE} "SELECT * FROM stats_swaps WHERE taker_coin = 'DOGE' and maker_coin = 'DGB' ORDER BY finished_at DESC LIMIT 1;"` From e0c3de621b957984eb669f73ccf5314619e556a3 Mon Sep 17 00:00:00 2001 From: smk762 Date: Tue, 30 Jul 2024 17:00:11 +0800 Subject: [PATCH 4/9] update DB path --- .../query-the-mm2-database/index.mdx | 66 ++++++++++++++----- 1 file changed, 51 insertions(+), 15 deletions(-) diff --git a/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx b/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx index 4f9ff097..079e0688 100644 --- a/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx +++ b/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx @@ -3,7 +3,20 @@ export const description = "This guide describes how to query the MM2 SQLite dat # How to Query the MM2 SQLite Database -The Komodo DeFi Framework API stores historical information such as swaps and orders within an SQLite database, located under the DB user data folder (e.g. {'{folder continaing mm2 binary}'}/DB/{'{wallet identifying hex string}'}/MM2.db'). +The Komodo DeFi Framework API stores historical information such as swaps and orders within an SQLite database, located under the DB user data folder with each wallet having its own subfolder represented by a hexideciaml string. +This string is shown in the runtime logs of the `kdf` binary as `Public key hash` when it starts up. + +``` +30 08:39:23, mm2:269] AtomicDEX API 2.1.0-beta_a81f2a101 DT 2024-07-26T23:24:52+03:00 +30 08:39:23, mm2_main::mm2::lp_native_dex:500] INFO Version: 2.1.0-beta_a81f2a101 DT 2024-07-26T23:24:52+03:00 +30 08:39:23, crypto::crypto_ctx:324] INFO Public key hash: 7d6cbdd91788df3b764247721fe12853ce36b03d +``` + +The location of this folder for each operating system is: +- Linux: $HOME/.kdf/DB/{'{wallet identifying hex string}'}/MM2.db' +- MacOS: $HOME/Library/Application Support/kdf/DB/{'{wallet identifying hex string}'}/MM2.db' +- Windows: %APPDATA%\kdf\DB\{'{wallet identifying hex string}'\MM2.db' + There are a variety of methods to query sqlite databases. Examples below show how to do a sqlite query in Linux terminal, but first you might need to install sqlite with `sudo apt install sqlite3`. @@ -121,26 +134,49 @@ This table stores a record of all nodes [added for stats collection](/komodo-def `37|dragonhound_DEV|104.238.221.61|12D3KooWEnrvbqvtTowYMR8FnBeKtryTj9RcXGx8EPpFZHou2ruP` -## stats\_nodes -This table stores a record of results returned by registered nodes [tracked for node stats collection](/komodo-defi-framework/api/v20/start_version_stat_collection/) in this pubkey's MM2.db +## Coin tables + +Additional tables are created for each coin to store supplementary details such as block headers and transaction history. Using KMD as an example, these tables are listed below: + +### KMD\_block\_headers\_cache | ID | Name | Type | Description | | -- | --------- | ------------ | -------------------------------------------- | | 0 | id | INTEGER | Primary Key | -| 1 | name | VARCHAR(255) | Node name | -| 2 | version | VARCHAR(255) | Node Komodo DeFi Framework API (mm2) version | -| 3 | timestamp | INTEGER | Timestamp | -| 4 | error | VARCHAR(255) | Error details | -#### Query: +### KMD\_tx\_address -`sqlite3 ${PATH_TO_MM2_DB_FILE} "SELECT * FROM stats_nodes WHERE name = 'dragonhound_DEV'" LIMIT 3` +1|ecfb45cc5d5fdf34dcc70b0db2a333b143f0b98f9a8470097e3a256c1760b6ff|RUYJYSTuCKm9gouWzQN1LirHFEYThwzA2d -#### Response: +| ID | Name | Type | Description | +| -- | ----------- | ------------ | -------------------------------------------- | +| 0 | id | INTEGER | Primary Key | +| 1 | internal_id | VARCHAR(255) | A hex string, representative of the address | +| 2 | address | VARCHAR(255) | The coin's wallet address | -```bash -540|dragonhound_DEV||1638542507|DialFailure -70638|dragonhound_DEV|2.1.4401_mm2.1_87837cb54_Linux_Release|1640270702| -70692|dragonhound_DEV||1640271615|Error on request the peer PeerId("12D3KooWEnrvbqvtTowYMR8FnBeKtryTj9RcXGx8EPpFZHou2ruP"): "Canceled". Request next peer -``` + + +### KMD\_tx\_cache + +tx_hash|tx_hex + +| ID | Name | Type | Description | +| -- | --------- | ------------ | -------------------------------------------- | +| 0 | tx_hash | VARCHAR(255) | A transaction hash | +| 1 | tx_hex | VARCHAR(255) | Raw hex for transaction | + + +### KMD\_tx\_history + +id|tx_hash|internal_id|block_height|confirmation_status|token_id|details_json + +| ID | Name | Type | Description | +| -- | -------------------- | ------------ | -------------------------------------------- | +| 0 | id | INTEGER | Primary Key | +| 1 | tx_hash | VARCHAR(255) | A transaction hash | +| 2 | internal_id | VARCHAR(255) | A hex string, representative of the transaction | +| 3 | block_height | INTEGER | Block height of transaction | +| 4 | confirmation_status | BOOLEAN | `True` if transaction has completed, `False` if it is pending | +| 5 | token_id | INTEGER | Number representing the coin type | +| 6 | details_json | VARCHAR(255) | Transaction details in JSON format | From e4448c510ed921e05a5fa8babd78bd5902b0571f Mon Sep 17 00:00:00 2001 From: smk762 Date: Wed, 31 Jul 2024 17:04:36 +0800 Subject: [PATCH 5/9] lint fix --- filepathSlugs.json | 8 ++- .../query-the-mm2-database/index.mdx | 60 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/filepathSlugs.json b/filepathSlugs.json index b6fbea9b..07e5ca24 100644 --- a/filepathSlugs.json +++ b/filepathSlugs.json @@ -3817,9 +3817,11 @@ "nodes", "query-4", "respose", - "stats-nodes", - "query-5", - "response-4" + "coin-tables", + "kmd-block-headers-cache", + "kmd-tx-address", + "kmd-tx-cache", + "kmd-tx-history" ], "src/pages/komodo-defi-framework/tutorials/setup-komodefi-api-aws/index.mdx": [ "how-to-setup-and-use-the-komodo-de-fi-framework-api-on-an-aws-ec-2-instance", diff --git a/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx b/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx index 6d4cd079..b9940e7e 100644 --- a/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx +++ b/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx @@ -6,17 +6,19 @@ export const description = "This guide describes how to query the MM2 SQLite dat The Komodo DeFi Framework API stores historical information such as swaps and orders within an SQLite database, located under the DB user data folder with each wallet having its own subfolder represented by a hexideciaml string. This string is shown in the runtime logs of the `kdf` binary as `Public key hash` when it starts up. -``` +```bash 30 08:39:23, mm2:269] AtomicDEX API 2.1.0-beta_a81f2a101 DT 2024-07-26T23:24:52+03:00 30 08:39:23, mm2_main::mm2::lp_native_dex:500] INFO Version: 2.1.0-beta_a81f2a101 DT 2024-07-26T23:24:52+03:00 30 08:39:23, crypto::crypto_ctx:324] INFO Public key hash: 7d6cbdd91788df3b764247721fe12853ce36b03d ``` The location of this folder for each operating system is: + +```bash - Linux: $HOME/.kdf/DB/{'{wallet identifying hex string}'}/MM2.db' - MacOS: $HOME/Library/Application Support/kdf/DB/{'{wallet identifying hex string}'}/MM2.db' -- Windows: %APPDATA%\kdf\DB\{'{wallet identifying hex string}'\MM2.db' - +- Windows: %APPDATA%\kdf\DB\{'{wallet identifying hex string}'}\MM2.db' +``` There are a variety of methods to query sqlite databases. Examples below show how to do a sqlite query in Linux terminal, but first you might need to install sqlite with `sudo apt install sqlite3`. @@ -133,49 +135,45 @@ This table stores a record of all nodes [added for stats collection](/komodo-def `37|dragonhound_DEV|104.238.221.61|12D3KooWEnrvbqvtTowYMR8FnBeKtryTj9RcXGx8EPpFZHou2ruP` - ## Coin tables Additional tables are created for each coin to store supplementary details such as block headers and transaction history. Using KMD as an example, these tables are listed below: ### KMD\_block\_headers\_cache -| ID | Name | Type | Description | -| -- | --------- | ------------ | -------------------------------------------- | -| 0 | id | INTEGER | Primary Key | +| ID | Name | Type | Description | +| -- | ---- | ------- | ----------- | +| 0 | id | INTEGER | Primary Key | ### KMD\_tx\_address 1|ecfb45cc5d5fdf34dcc70b0db2a333b143f0b98f9a8470097e3a256c1760b6ff|RUYJYSTuCKm9gouWzQN1LirHFEYThwzA2d -| ID | Name | Type | Description | -| -- | ----------- | ------------ | -------------------------------------------- | -| 0 | id | INTEGER | Primary Key | -| 1 | internal_id | VARCHAR(255) | A hex string, representative of the address | -| 2 | address | VARCHAR(255) | The coin's wallet address | - - +| ID | Name | Type | Description | +| -- | ------------ | ------------ | ------------------------------------------- | +| 0 | id | INTEGER | Primary Key | +| 1 | internal\_id | VARCHAR(255) | A hex string, representative of the address | +| 2 | address | VARCHAR(255) | The coin's wallet address | ### KMD\_tx\_cache -tx_hash|tx_hex - -| ID | Name | Type | Description | -| -- | --------- | ------------ | -------------------------------------------- | -| 0 | tx_hash | VARCHAR(255) | A transaction hash | -| 1 | tx_hex | VARCHAR(255) | Raw hex for transaction | +tx\_hash|tx\_hex +| ID | Name | Type | Description | +| -- | -------- | ------------ | ----------------------- | +| 0 | tx\_hash | VARCHAR(255) | A transaction hash | +| 1 | tx\_hex | VARCHAR(255) | Raw hex for transaction | ### KMD\_tx\_history -id|tx_hash|internal_id|block_height|confirmation_status|token_id|details_json - -| ID | Name | Type | Description | -| -- | -------------------- | ------------ | -------------------------------------------- | -| 0 | id | INTEGER | Primary Key | -| 1 | tx_hash | VARCHAR(255) | A transaction hash | -| 2 | internal_id | VARCHAR(255) | A hex string, representative of the transaction | -| 3 | block_height | INTEGER | Block height of transaction | -| 4 | confirmation_status | BOOLEAN | `True` if transaction has completed, `False` if it is pending | -| 5 | token_id | INTEGER | Number representing the coin type | -| 6 | details_json | VARCHAR(255) | Transaction details in JSON format | +id|tx\_hash|internal\_id|block\_height|confirmation\_status|token\_id|details\_json + +| ID | Name | Type | Description | +| -- | -------------------- | ------------ | ------------------------------------------------------------- | +| 0 | id | INTEGER | Primary Key | +| 1 | tx\_hash | VARCHAR(255) | A transaction hash | +| 2 | internal\_id | VARCHAR(255) | A hex string, representative of the transaction | +| 3 | block\_height | INTEGER | Block height of transaction | +| 4 | confirmation\_status | BOOLEAN | `True` if transaction has completed, `False` if it is pending | +| 5 | token\_id | INTEGER | Number representing the coin type | +| 6 | details\_json | VARCHAR(255) | Transaction details in JSON format | From ff4f839bb89228917806a579c0a1f65712f3a7b7 Mon Sep 17 00:00:00 2001 From: smk762 Date: Mon, 28 Oct 2024 17:56:42 +0800 Subject: [PATCH 6/9] add link to dbdir config param info --- .../tutorials/query-the-mm2-database/index.mdx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx b/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx index b9940e7e..f4d69f04 100644 --- a/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx +++ b/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx @@ -12,7 +12,7 @@ This string is shown in the runtime logs of the `kdf` binary as `Public key hash 30 08:39:23, crypto::crypto_ctx:324] INFO Public key hash: 7d6cbdd91788df3b764247721fe12853ce36b03d ``` -The location of this folder for each operating system is: +The default location of this folder for each operating system is: ```bash - Linux: $HOME/.kdf/DB/{'{wallet identifying hex string}'}/MM2.db' @@ -20,6 +20,11 @@ The location of this folder for each operating system is: - Windows: %APPDATA%\kdf\DB\{'{wallet identifying hex string}'}\MM2.db' ``` + +You can define a different location for the DB folder via the [`dbdir` configuration parameter](/komodo-defi-framework/setup/configure-mm2-json/) in your MM2.json file. + + + There are a variety of methods to query sqlite databases. Examples below show how to do a sqlite query in Linux terminal, but first you might need to install sqlite with `sudo apt install sqlite3`. The tables and columns available to query are as follows: From 8549f5104eb668fcfa17bb769342c3c4bcd5ffa5 Mon Sep 17 00:00:00 2001 From: smk762 Date: Mon, 28 Oct 2024 10:09:27 +0000 Subject: [PATCH 7/9] [Bot] File and author data updated, validated and updated internal links, formatted md content, checked presence of file and dirs based on sidebar, checked presence of h1 in every file, update Komodo DeFi Framework methods table, adds/updates preview images when base is main --- .../tutorials/query-the-mm2-database/index.mdx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx b/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx index f4d69f04..f8315923 100644 --- a/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx +++ b/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx @@ -21,10 +21,9 @@ The default location of this folder for each operating system is: ``` -You can define a different location for the DB folder via the [`dbdir` configuration parameter](/komodo-defi-framework/setup/configure-mm2-json/) in your MM2.json file. + You can define a different location for the DB folder via the [`dbdir` configuration parameter](/komodo-defi-framework/setup/configure-mm2-json/) in your MM2.json file. - There are a variety of methods to query sqlite databases. Examples below show how to do a sqlite query in Linux terminal, but first you might need to install sqlite with `sudo apt install sqlite3`. The tables and columns available to query are as follows: From 00babf1fabfed0ad94f620c0ea8d3369e1b3afcc Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 14 Nov 2024 14:38:16 +0800 Subject: [PATCH 8/9] update default macos db location --- .../tutorials/query-the-mm2-database/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx b/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx index f8315923..5c0edc4b 100644 --- a/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx +++ b/src/pages/komodo-defi-framework/tutorials/query-the-mm2-database/index.mdx @@ -16,7 +16,7 @@ The default location of this folder for each operating system is: ```bash - Linux: $HOME/.kdf/DB/{'{wallet identifying hex string}'}/MM2.db' -- MacOS: $HOME/Library/Application Support/kdf/DB/{'{wallet identifying hex string}'}/MM2.db' +- MacOS: $HOME/.kdf/DB/{'{wallet identifying hex string}'}/MM2.db' - Windows: %APPDATA%\kdf\DB\{'{wallet identifying hex string}'}\MM2.db' ``` From 125ac5581f1f0f9680bb394b22b5e916d71a1fe6 Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 14 Nov 2024 06:50:46 +0000 Subject: [PATCH 9/9] [Bot] File and author data updated, validated and updated internal links, formatted md content, checked presence of file and dirs based on sidebar, checked presence of h1 in every file, update Komodo DeFi Framework methods table, adds/updates preview images when base is main --- src/pages/komodo-defi-framework/api/index.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/komodo-defi-framework/api/index.mdx b/src/pages/komodo-defi-framework/api/index.mdx index a9255fb0..742f3c10 100644 --- a/src/pages/komodo-defi-framework/api/index.mdx +++ b/src/pages/komodo-defi-framework/api/index.mdx @@ -55,6 +55,7 @@ Below is a table of the currently available legacy, v2.0 and v2.0 (Dev) methods: | [get\_relay\_mesh](/komodo-defi-framework/api/legacy/get_relay_mesh/#get-relay-mesh) | | | | | [get\_staking\_infos](/komodo-defi-framework/api/v20/get_staking_infos/#get-staking-infos) | | | [get\_trade\_fee](/komodo-defi-framework/api/legacy/get_trade_fee/#get-trade-fee) | | | +| | [get\_wallet\_names](/komodo-defi-framework/api/v20/get_wallet_names/#get-wallet-names) | | | [import\_swaps](/komodo-defi-framework/api/legacy/import_swaps/#import-swaps) | | | | [kmd\_rewards\_info](/komodo-defi-framework/api/legacy/kmd_rewards_info/#kmd-rewards-info) | | | | | | [lightning::nodes::add\_trusted\_node](/komodo-defi-framework/api/v20-dev/lightning/nodes/#add-trusted-node) |