Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R2R] Add draft docs for sign_raw_transaction #161

Merged
merged 25 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4ef9805
add draft docs for `sign_raw_transaction`
smk762 Oct 27, 2023
07fb278
update sign_raw_tx method
smk762 Nov 28, 2023
38a7b4a
Merge branch 'dev' into v2-signrawtx
smk762 Nov 28, 2023
0a8af0c
fix title and sidebar
smk762 Nov 28, 2023
67f8bc3
Merge branch 'v2-signrawtx' of https://github.com/KomodoPlatform/komo…
smk762 Nov 28, 2023
579496d
update metadata
smk762 Nov 28, 2023
e52c56b
fix example labels
smk762 Nov 28, 2023
e8c088d
add error responses
smk762 Dec 2, 2023
a199c15
lint recent changes
smk762 Dec 2, 2023
b885d07
[Bot] File and author data updated, validated and updated internal li…
smk762 Dec 2, 2023
5882581
Merge pull request #166 from KomodoPlatform/lint-fix-patches/v2-signr…
gcharang Dec 4, 2023
cd6ac7b
Merge branch 'dev' into v2-signrawtx
gcharang Dec 4, 2023
6533bac
Merge branch 'v2-signrawtx' of https://github.com/KomodoPlatform/komo…
gcharang Dec 4, 2023
976c3f4
[Bot] File and author data updated, validated and updated internal li…
gcharang Dec 4, 2023
e8ff43d
Merge pull request #170 from KomodoPlatform/lint-fix-patches/v2-signr…
gcharang Dec 4, 2023
1d3addf
Merge branch 'dev' into v2-signrawtx
smk762 Dec 22, 2023
7061521
linted
smk762 Dec 22, 2023
86d3dbb
[Bot] File and author data updated, validated and updated internal li…
smk762 Dec 22, 2023
906a3ab
Merge pull request #186 from KomodoPlatform/lint-fix-patches/v2-signr…
gcharang Jan 29, 2024
ea71660
Merge branch 'dev' into v2-signrawtx
smk762 Feb 20, 2024
04c2369
Merge branch 'dev' into v2-signrawtx
gcharang Feb 21, 2024
210cb54
[Bot] File and author data updated, validated and updated internal li…
gcharang Feb 21, 2024
82a333c
Merge pull request #194 from KomodoPlatform/lint-fix-patches/v2-signr…
gcharang Feb 21, 2024
dd9e042
resolve conflicts
gcharang Mar 4, 2024
dc73b29
Merge branch 'dev' into v2-signrawtx
gcharang Mar 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
276 changes: 276 additions & 0 deletions data-for-gpts/all-content.txt

Large diffs are not rendered by default.

276 changes: 276 additions & 0 deletions data-for-gpts/atomicdex-content.txt

Large diffs are not rendered by default.

276 changes: 276 additions & 0 deletions data-for-gpts/komodefi-api/all-api-content.txt

Large diffs are not rendered by default.

210 changes: 210 additions & 0 deletions data-for-gpts/komodefi-api/v20-api-content.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4581,6 +4581,216 @@ The `remove_node_from_version_stat` method removes a Node (by name) from the loc
}
```
</CollapsibleSection>
export const title = "AtomicDEX: Sign Raw Transaction";
export const description = "The methods in this document allow you to sign raw transactions.";

# Sign Raw Transaction

This method allows users to:

* Create a signed UTXO raw transaction given unsigned hex, and optionally a set of prior transaction inputs.
* Create a signed EVM raw transaction, given the destination address, amount and gas limit.

The transaction can then be broadcasted to the network using the [`send_raw_transaction`](/atomicdex/api/legacy/send_raw_transaction/) to complete the process.

<Note>
This method is used to sign a raw transaction that has already been created.
For UTXO coins, the unsigned hex is required to sign the transaction.
If `prev_txns` is not provided, it will be sourced via electrums.
</Note>

### Request Parameters

| Structure | Type | Description |
| --------- | ------ | ----------------------------------------------------------------------------------- |
| coin | string | The coin to sign the raw transaction with |
| type | string | The operation type. Accepted values: UTXO ( for utxo coins), ETH (for emv coins) |
| tx | object | A standard [RawTxInfo object](/atomicdex/api/common_structures/wallet/#raw-tx-info) |

### Response Parameters

| Structure | Type | Description |
| --------- | ------ | ----------------------------------------------- |
| tx\_hex | string | The signed transaction hex, ready for broadcast |

#### Sign UTXO raw transaction hex

<CodeGroup title="" tag="POST" label="sign_raw_transaction" mm2MethodDecorate="true">
```json
{
"userpass": "testpsw",
"mmrpc": "2.0",
"method": "sign_raw_transaction",
"params": {
"coin": "KMD",
"type": "UTXO",
"tx": {
"tx_hex": "0400008085202f8901c8d6d8764e51bbadc0592b99f37b3b7d8c9719686d5a9bf63652a0802a1cd0360200000000feffffff0100dd96d8080000001976a914d346067e3c3c3964c395fee208594790e29ede5d88ac46366665000000000000000000000000000000"
}
},
"id": 0
}
```
</CodeGroup>

<CollapsibleSection expandedText="Hide Response" collapsedText="Show Response">
#### Response (success)

```json
{
"mmrpc": "2.0",
"result": {
"tx_hex": "0400008085202f8901c8d6d8764e51bbadc0592b99f37b3b7d8c9719686d5a9bf63652a0802a1cd036020000006a47304402206b40df6d7b1d87622ea1eba0cdce09dfaf21556a408b2bd245920c2f3e9ff5e702201bd7bcc9587a9731cfd7c57057f173cbf635d2818263a96f211c413f6e83d187012103d8064eece4fa5c0f8dc0267f68cee9bdd527f9e88f3594a323428718c391ecc2feffffff0100dd96d8080000001976a914d346067e3c3c3964c395fee208594790e29ede5d88ac46366665000000000000000000000000000000"
},
"id":0
}
```
</CollapsibleSection>

#### Sign UTXO raw transaction hex with inputs

<CodeGroup title="" tag="POST" label="sign_raw_transaction" mm2MethodDecorate="true">
```json
{
"userpass": "testpsw",
"mmrpc": "2.0",
"id": 0,
"method": "sign_raw_transaction",
"params": {
"coin": "KMD",
"type": "UTXO",
"tx": {
"tx_hex": "0400008085202f8901c8d6d8764e51bbadc0592b99f37b3b7d8c9719686d5a9bf63652a0802a1cd0360200000000feffffff0100dd96d8080000001976a914d346067e3c3c3964c395fee208594790e29ede5d88ac46366665000000000000000000000000000000",
"prev_txns": [
{
"tx_hash": "36d01c2a80a05236f69b5a6d6819978c7d3b7bf3992b59c0adbb514e76d8d6c8",
"index": 2,
"script_pub_key": "76a914d346067e3c3c3964c395fee208594790e29ede5d88ac",
"amount": 0.00001
}
]
}
}
}
```
</CodeGroup>

#### Response (success)

<CollapsibleSection expandedText="Hide Response" collapsedText="Show Response">
```json
{
"mmrpc": "2.0",
"result": {
"tx_hex": "020000000001010d23d763f12d77a337cc16df2696ac3f48552dda373c9977fa1f5dd8d5025cb20100000000fdffffff01f40100000000000016001488accd2145b7232b958db5cdf09336ad619541e2024730440220156d185b3fb21725c040b7ddcf84bf862b46f079bb66067eef1941023b8451e602204d877ac51b74932dea34c20874fa8112b3636eb506ac429548f7c05fe54e3faf0121039ad38f67dbc22cf5a6bd48b26920d9fac71681836faf80a9a678ddbaa0fe92f800000000"
},
"id":0
}
```
</CollapsibleSection>

#### Signed an ETH/EVM raw transaction

<CodeGroup title="" tag="POST" label="sign_raw_transaction" mm2MethodDecorate="true">
```json
{
"userpass": "testpsw",
"mmrpc": "2.0",
"id": 0,
"method": "sign_raw_transaction",
"params": {
"coin": "MATIC",
"type": "ETH",
"tx": {
"to": "0x927DaFDDa16F1742BeFcBEAE6798090354B294A9",
"value": "1.4",
"gas_limit": "21000"
}
}
}
```
</CodeGroup>

#### Response (success)

```json
{
"mmrpc": "2.0",
"result": {
"tx_hex": "f86680847735940083021000947bc1bbdd6a0a722fc9bffc49c921b685ecb84b948210008025a06c0ecbccf92caf5ac620b118f09a84a18c73d7b209e75696bb10e3c24c2dba64a055af3638f92daec1eb3057fb6a9ccf418325bb1aa6121a3314c3885100a5e63a"
},
"id": 0
}
```

<Note>
Once you have signed the raw transaction, dont forget to broadcast it to
the network using the [`send_raw_transaction`](/atomicdex/api/legacy/send_raw_transaction/) method.
</Note>

### Errors

<CollapsibleSection expandedText="Hide Errors" collapsedText="Show Errors">
#### Signing Error

You might see this if you try to sign a raw transaction that belongs to a different key pair.

```json
{
"mmrpc":"2.0",
"error":"Signing error: with_key_pair:114] P2PKH script 'OP_DUP\nOP_HASH160\nOP_PUSHBYTES_20 0xd346067e3c3c3964c395fee208594790e29ede5d\nOP_EQUALVERIFY\nOP_CHECKSIG\n' built from input key pair doesn't match expected prev script 'OP_DUP\nOP_HASH160\nOP_PUSHBYTES_20 0x32311a35188a9439c6c866e842564d6fefd3a028\nOP_EQUALVERIFY\nOP_CHECKSIG\n'","error_path":"utxo_common","error_trace":"utxo_common:3144]",
"error_type":"SigningError",
"error_data":"with_key_pair:114] P2PKH script 'OP_DUP\nOP_HASH160\nOP_PUSHBYTES_20 0xd346067e3c3c3964c395fee208594790e29ede5d\nOP_EQUALVERIFY\nOP_CHECKSIG\n' built from input key pair doesn't match expected prev script 'OP_DUP\nOP_HASH160\nOP_PUSHBYTES_20 0x32311a35188a9439c6c866e842564d6fefd3a028\nOP_EQUALVERIFY\nOP_CHECKSIG\n'",
"id":0
}
```

#### Invalid Request

```
{
"mmrpc":"2.0",
"error":"Error parsing request: invalid digit found in string",
"error_path":"dispatcher",
"error_trace":"dispatcher:108]",
"error_type":"InvalidRequest",
"error_data":"invalid digit found in string",
"id":0
}
```

#### Invalid Parameter

```
{
"mmrpc":"2.0",
"error":"Invalid param: Invalid input length",
"error_path":"eth",
"error_trace":"eth:2544]",
"error_type":"InvalidParam",
"error_data":"Invalid input length",
"id":0
}
```

#### No Such Coin

Coin does not exist or has not been activated.

```
{
"mmrpc":"2.0",
"error":"No such coin NOTSURE",
"error_path":"lp_coins",
"error_trace":"lp_coins:3965] lp_coins:3861]",
"error_type":"NoSuchCoin",
"error_data":{
"coin":"NOTSURE"
},
"id":0
}
```
</CollapsibleSection>
export const title = "AtomicDEX Method: Start Simple Market Maker Bot";
export const description = "The AtomicDEX API allows for simple bot trading via the start_simple_market_maker_bot method.";

Expand Down
21 changes: 21 additions & 0 deletions filepathSlugs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1727,6 +1727,11 @@
"taker-payment-refund-finished",
"finished"
],
"src/pages/atomicdex/api/common_structures/wallet/index.mdx": [
"wallet-operations-structures",
"raw-tx-info",
"input-txns"
],
"src/pages/atomicdex/api/index.mdx": [
"atomic-dex-rpc-methods"
],
Expand Down Expand Up @@ -2493,6 +2498,22 @@
"command",
"response-success"
],
"src/pages/atomicdex/api/v20/sign_raw_transaction/index.mdx": [
"sign-raw-transaction",
"request-parameters",
"response-parameters",
"sign-utxo-raw-transaction-hex",
"response-success",
"sign-utxo-raw-transaction-hex-with-inputs",
"response-success-2",
"signed-an-eth-evm-raw-transaction",
"response-success-3",
"errors",
"signing-error",
"invalid-request",
"invalid-parameter",
"no-such-coin"
],
"src/pages/atomicdex/api/v20/start_simple_market_maker_bot/index.mdx": [
"start-simple-market-maker-bot",
"arguments",
Expand Down
11 changes: 10 additions & 1 deletion src/data/sidebar.json
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@
"title": "Message Signing",
"links": [
{
"title": "Configuring supported coins, signing, verifying messages",
"title": "Configuring supported coins, signing & verifying messages",
"href": "/atomicdex/api/v20/message_signing/"
}
]
Expand Down Expand Up @@ -356,6 +356,10 @@
"title": "get_raw_transaction",
"href": "/atomicdex/api/v20/get_raw_transaction/"
},
{
"title": "sign_raw_transaction",
"href": "/atomicdex/api/v20/sign_raw_transaction/"
},
{
"title": "my_tx_history",
"href": "/atomicdex/api/v20/my_tx_history/"
Expand Down Expand Up @@ -801,6 +805,11 @@
"href": "/atomicdex/api/common_structures/swaps/taker_events/"
}
]
},
{
"title": "Wallet Operations Structures",
"titleLink": "/atomicdex/api/common_structures/wallet/",
"links": []
}
]
},
Expand Down
1 change: 1 addition & 0 deletions src/pages/atomicdex/api/common_structures/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The objects are in the request or response of multiple Komodo DeFi SDK methods h
* [Swaps](/atomicdex/api/common_structures/swaps/)
* [Lightning Network](/atomicdex/api/common_structures/lightning/)
* [Non-fungible Tokens](/atomicdex/api/common_structures/nfts/)
* [Wallet Operations](/atomicdex/api/common_structures/wallet/)

Structures which are used in more than one section are listed below:

Expand Down
64 changes: 64 additions & 0 deletions src/pages/atomicdex/api/common_structures/wallet/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
export const title = "Komodo DeFi SDK Common Structures: Wallet Operations";
export const description = "Starting with version beta-2.1.3434, the Komodo DeFi SDK supports the standardized protocol format called mmrpc 2.0.";

# Wallet Operations Structures

### RawTxInfo

The `RawTxInfo` object includes the following items:

| Parameter | Type | Description |
| ---------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| tx\_hex | string | UTXO only. The raw unsigned hex of a proposed transaction. |
| prev\_txns | list | UTXO only. A list of standard [InputTxns objects](/atomicdex/api/common_structures/wallet/#input-txns). |
| to | string | ETH/EVM only. A destination address to send the funds to. |
| value | string | ETH/EVM only. The amount of funds to be sent as a string with a `0x` prefix, in [wei](https://ethereum.stackexchange.com/questions/253/the-ether-denominations-are-called-finney-szabo-and-wei-what-who-are-these-na) units. |
| gas\_limit | string | ETH/EVM only. The maximum gas to be used for sending the transaction, in [gwei](https://eth-converter.com/) units. |

<DevComment>
TODO: Confirm units used in ETH/EVM transactions.
</DevComment>

<CollapsibleSection expandedText="Hide UTXO Example" collapsedText="Show UTXO Example">
```json
{
"tx_hex": "02000000010d23d763f12d77a337cc16df2696ac3f48552dda373c9977fa1f5dd8d5025cb20100000000fdffffff01f40100000000000016001488accd2145b7232b958db5cdf09336ad619541e200000000",
"prev_txns": [
...
]
}
```
</CollapsibleSection>

<CollapsibleSection expandedText="Hide ETH/EVM Example" collapsedText="Show ETH/EVM Example">
```json
{
"to": "0x927DaFDDa16F1742BeFcBEAE6798090354B294A9",
"value": "0.85",
"gas_limit": "21000"
}
```
</CollapsibleSection>

### InputTxns

The `InputTxns` object includes the following items:

| Parameter | Type | Description |
| ---------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| tx\_hash | string | The transaction id of an unspent transaction from the same wallet output. |
| index | integer | The \[output index([https://bitcoin.stackexchange.com/questions/100765/what-does-the-index-of-an-utxo-stand-for](https://bitcoin.stackexchange.com/questions/100765/what-does-the-index-of-an-utxo-stand-for))] of this unspent transaction output. |
| script\_pub\_key | string | The [scriptpubkey](https://learnmeabitcoin.com/technical/scriptPubKey) of this unspent transaction output. |
| amount | float | The value of this unspent transaction output. |
| amount | | |

<CollapsibleSection expandedText="Hide Example" collapsedText="Show Example">
```json
{
"tx_hash": "0d23d763f12d77a337cc16df2696ac3f48552dda373c9977fa1f5dd8d5025cb2",
"index": 1,
"script_pub_key": "001449e3b6b4684c4d4a914b29411af51843c59bfff0",
"amount": 0.00001000
}
```
</CollapsibleSection>
1 change: 1 addition & 0 deletions src/pages/atomicdex/api/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Below is a table of the currently available legacy, v2.0 and v2.0 (Dev) methods:
| [setprice](/atomicdex/api/legacy/setprice/#setprice) | | |
| [show\_priv\_key](/atomicdex/api/legacy/show_priv_key/#show-priv-key) | | |
| | [sign\_message](/atomicdex/api/v20/message_signing/#sign-message) | |
| | [sign\_raw\_transaction](/atomicdex/api/v20/sign_raw_transaction/#sign-raw-transaction) | |
| | [start\_simple\_market\_maker\_bot](/atomicdex/api/v20/start_simple_market_maker_bot/#start-simple-market-maker-bot) | |
| | [start\_version\_stat\_collection](/atomicdex/api/v20/start_version_stat_collection/#start-version-stat-collection) | |
| | [stop\_simple\_market\_maker\_bot](/atomicdex/api/v20/stop_simple_market_maker_bot/#stop-simple-market-maker-bot) | |
Expand Down
Loading
Loading