Skip to content

Commit 1b393ad

Browse files
authored
Merge pull request #161 from KomodoPlatform/v2-signrawtx
[R2R] Add draft docs for `sign_raw_transaction`
2 parents 5e15b92 + dc73b29 commit 1b393ad

File tree

11 files changed

+1384
-10
lines changed

11 files changed

+1384
-10
lines changed

data-for-gpts/all-content.txt

+276
Large diffs are not rendered by default.

data-for-gpts/atomicdex-content.txt

+276
Large diffs are not rendered by default.

data-for-gpts/komodefi-api/all-api-content.txt

+276
Large diffs are not rendered by default.

data-for-gpts/komodefi-api/v20-api-content.txt

+210
Original file line numberDiff line numberDiff line change
@@ -4581,6 +4581,216 @@ The `remove_node_from_version_stat` method removes a Node (by name) from the loc
45814581
}
45824582
```
45834583
</CollapsibleSection>
4584+
export const title = "AtomicDEX: Sign Raw Transaction";
4585+
export const description = "The methods in this document allow you to sign raw transactions.";
4586+
4587+
# Sign Raw Transaction
4588+
4589+
This method allows users to:
4590+
4591+
* Create a signed UTXO raw transaction given unsigned hex, and optionally a set of prior transaction inputs.
4592+
* Create a signed EVM raw transaction, given the destination address, amount and gas limit.
4593+
4594+
The transaction can then be broadcasted to the network using the [`send_raw_transaction`](/atomicdex/api/legacy/send_raw_transaction/) to complete the process.
4595+
4596+
<Note>
4597+
This method is used to sign a raw transaction that has already been created.
4598+
For UTXO coins, the unsigned hex is required to sign the transaction.
4599+
If `prev_txns` is not provided, it will be sourced via electrums.
4600+
</Note>
4601+
4602+
### Request Parameters
4603+
4604+
| Structure | Type | Description |
4605+
| --------- | ------ | ----------------------------------------------------------------------------------- |
4606+
| coin | string | The coin to sign the raw transaction with |
4607+
| type | string | The operation type. Accepted values: UTXO ( for utxo coins), ETH (for emv coins) |
4608+
| tx | object | A standard [RawTxInfo object](/atomicdex/api/common_structures/wallet/#raw-tx-info) |
4609+
4610+
### Response Parameters
4611+
4612+
| Structure | Type | Description |
4613+
| --------- | ------ | ----------------------------------------------- |
4614+
| tx\_hex | string | The signed transaction hex, ready for broadcast |
4615+
4616+
#### Sign UTXO raw transaction hex
4617+
4618+
<CodeGroup title="" tag="POST" label="sign_raw_transaction" mm2MethodDecorate="true">
4619+
```json
4620+
{
4621+
"userpass": "testpsw",
4622+
"mmrpc": "2.0",
4623+
"method": "sign_raw_transaction",
4624+
"params": {
4625+
"coin": "KMD",
4626+
"type": "UTXO",
4627+
"tx": {
4628+
"tx_hex": "0400008085202f8901c8d6d8764e51bbadc0592b99f37b3b7d8c9719686d5a9bf63652a0802a1cd0360200000000feffffff0100dd96d8080000001976a914d346067e3c3c3964c395fee208594790e29ede5d88ac46366665000000000000000000000000000000"
4629+
}
4630+
},
4631+
"id": 0
4632+
}
4633+
```
4634+
</CodeGroup>
4635+
4636+
<CollapsibleSection expandedText="Hide Response" collapsedText="Show Response">
4637+
#### Response (success)
4638+
4639+
```json
4640+
{
4641+
"mmrpc": "2.0",
4642+
"result": {
4643+
"tx_hex": "0400008085202f8901c8d6d8764e51bbadc0592b99f37b3b7d8c9719686d5a9bf63652a0802a1cd036020000006a47304402206b40df6d7b1d87622ea1eba0cdce09dfaf21556a408b2bd245920c2f3e9ff5e702201bd7bcc9587a9731cfd7c57057f173cbf635d2818263a96f211c413f6e83d187012103d8064eece4fa5c0f8dc0267f68cee9bdd527f9e88f3594a323428718c391ecc2feffffff0100dd96d8080000001976a914d346067e3c3c3964c395fee208594790e29ede5d88ac46366665000000000000000000000000000000"
4644+
},
4645+
"id":0
4646+
}
4647+
```
4648+
</CollapsibleSection>
4649+
4650+
#### Sign UTXO raw transaction hex with inputs
4651+
4652+
<CodeGroup title="" tag="POST" label="sign_raw_transaction" mm2MethodDecorate="true">
4653+
```json
4654+
{
4655+
"userpass": "testpsw",
4656+
"mmrpc": "2.0",
4657+
"id": 0,
4658+
"method": "sign_raw_transaction",
4659+
"params": {
4660+
"coin": "KMD",
4661+
"type": "UTXO",
4662+
"tx": {
4663+
"tx_hex": "0400008085202f8901c8d6d8764e51bbadc0592b99f37b3b7d8c9719686d5a9bf63652a0802a1cd0360200000000feffffff0100dd96d8080000001976a914d346067e3c3c3964c395fee208594790e29ede5d88ac46366665000000000000000000000000000000",
4664+
"prev_txns": [
4665+
{
4666+
"tx_hash": "36d01c2a80a05236f69b5a6d6819978c7d3b7bf3992b59c0adbb514e76d8d6c8",
4667+
"index": 2,
4668+
"script_pub_key": "76a914d346067e3c3c3964c395fee208594790e29ede5d88ac",
4669+
"amount": 0.00001
4670+
}
4671+
]
4672+
}
4673+
}
4674+
}
4675+
```
4676+
</CodeGroup>
4677+
4678+
#### Response (success)
4679+
4680+
<CollapsibleSection expandedText="Hide Response" collapsedText="Show Response">
4681+
```json
4682+
{
4683+
"mmrpc": "2.0",
4684+
"result": {
4685+
"tx_hex": "020000000001010d23d763f12d77a337cc16df2696ac3f48552dda373c9977fa1f5dd8d5025cb20100000000fdffffff01f40100000000000016001488accd2145b7232b958db5cdf09336ad619541e2024730440220156d185b3fb21725c040b7ddcf84bf862b46f079bb66067eef1941023b8451e602204d877ac51b74932dea34c20874fa8112b3636eb506ac429548f7c05fe54e3faf0121039ad38f67dbc22cf5a6bd48b26920d9fac71681836faf80a9a678ddbaa0fe92f800000000"
4686+
},
4687+
"id":0
4688+
}
4689+
```
4690+
</CollapsibleSection>
4691+
4692+
#### Signed an ETH/EVM raw transaction
4693+
4694+
<CodeGroup title="" tag="POST" label="sign_raw_transaction" mm2MethodDecorate="true">
4695+
```json
4696+
{
4697+
"userpass": "testpsw",
4698+
"mmrpc": "2.0",
4699+
"id": 0,
4700+
"method": "sign_raw_transaction",
4701+
"params": {
4702+
"coin": "MATIC",
4703+
"type": "ETH",
4704+
"tx": {
4705+
"to": "0x927DaFDDa16F1742BeFcBEAE6798090354B294A9",
4706+
"value": "1.4",
4707+
"gas_limit": "21000"
4708+
}
4709+
}
4710+
}
4711+
```
4712+
</CodeGroup>
4713+
4714+
#### Response (success)
4715+
4716+
```json
4717+
{
4718+
"mmrpc": "2.0",
4719+
"result": {
4720+
"tx_hex": "f86680847735940083021000947bc1bbdd6a0a722fc9bffc49c921b685ecb84b948210008025a06c0ecbccf92caf5ac620b118f09a84a18c73d7b209e75696bb10e3c24c2dba64a055af3638f92daec1eb3057fb6a9ccf418325bb1aa6121a3314c3885100a5e63a"
4721+
},
4722+
"id": 0
4723+
}
4724+
```
4725+
4726+
<Note>
4727+
Once you have signed the raw transaction, dont forget to broadcast it to
4728+
the network using the [`send_raw_transaction`](/atomicdex/api/legacy/send_raw_transaction/) method.
4729+
</Note>
4730+
4731+
### Errors
4732+
4733+
<CollapsibleSection expandedText="Hide Errors" collapsedText="Show Errors">
4734+
#### Signing Error
4735+
4736+
You might see this if you try to sign a raw transaction that belongs to a different key pair.
4737+
4738+
```json
4739+
{
4740+
"mmrpc":"2.0",
4741+
"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]",
4742+
"error_type":"SigningError",
4743+
"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'",
4744+
"id":0
4745+
}
4746+
```
4747+
4748+
#### Invalid Request
4749+
4750+
```
4751+
{
4752+
"mmrpc":"2.0",
4753+
"error":"Error parsing request: invalid digit found in string",
4754+
"error_path":"dispatcher",
4755+
"error_trace":"dispatcher:108]",
4756+
"error_type":"InvalidRequest",
4757+
"error_data":"invalid digit found in string",
4758+
"id":0
4759+
}
4760+
```
4761+
4762+
#### Invalid Parameter
4763+
4764+
```
4765+
{
4766+
"mmrpc":"2.0",
4767+
"error":"Invalid param: Invalid input length",
4768+
"error_path":"eth",
4769+
"error_trace":"eth:2544]",
4770+
"error_type":"InvalidParam",
4771+
"error_data":"Invalid input length",
4772+
"id":0
4773+
}
4774+
```
4775+
4776+
#### No Such Coin
4777+
4778+
Coin does not exist or has not been activated.
4779+
4780+
```
4781+
{
4782+
"mmrpc":"2.0",
4783+
"error":"No such coin NOTSURE",
4784+
"error_path":"lp_coins",
4785+
"error_trace":"lp_coins:3965] lp_coins:3861]",
4786+
"error_type":"NoSuchCoin",
4787+
"error_data":{
4788+
"coin":"NOTSURE"
4789+
},
4790+
"id":0
4791+
}
4792+
```
4793+
</CollapsibleSection>
45844794
export const title = "AtomicDEX Method: Start Simple Market Maker Bot";
45854795
export const description = "The AtomicDEX API allows for simple bot trading via the start_simple_market_maker_bot method.";
45864796

filepathSlugs.json

+21
Original file line numberDiff line numberDiff line change
@@ -1727,6 +1727,11 @@
17271727
"taker-payment-refund-finished",
17281728
"finished"
17291729
],
1730+
"src/pages/atomicdex/api/common_structures/wallet/index.mdx": [
1731+
"wallet-operations-structures",
1732+
"raw-tx-info",
1733+
"input-txns"
1734+
],
17301735
"src/pages/atomicdex/api/index.mdx": [
17311736
"atomic-dex-rpc-methods"
17321737
],
@@ -2493,6 +2498,22 @@
24932498
"command",
24942499
"response-success"
24952500
],
2501+
"src/pages/atomicdex/api/v20/sign_raw_transaction/index.mdx": [
2502+
"sign-raw-transaction",
2503+
"request-parameters",
2504+
"response-parameters",
2505+
"sign-utxo-raw-transaction-hex",
2506+
"response-success",
2507+
"sign-utxo-raw-transaction-hex-with-inputs",
2508+
"response-success-2",
2509+
"signed-an-eth-evm-raw-transaction",
2510+
"response-success-3",
2511+
"errors",
2512+
"signing-error",
2513+
"invalid-request",
2514+
"invalid-parameter",
2515+
"no-such-coin"
2516+
],
24962517
"src/pages/atomicdex/api/v20/start_simple_market_maker_bot/index.mdx": [
24972518
"start-simple-market-maker-bot",
24982519
"arguments",

src/data/sidebar.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@
268268
"title": "Message Signing",
269269
"links": [
270270
{
271-
"title": "Configuring supported coins, signing, verifying messages",
271+
"title": "Configuring supported coins, signing & verifying messages",
272272
"href": "/atomicdex/api/v20/message_signing/"
273273
}
274274
]
@@ -356,6 +356,10 @@
356356
"title": "get_raw_transaction",
357357
"href": "/atomicdex/api/v20/get_raw_transaction/"
358358
},
359+
{
360+
"title": "sign_raw_transaction",
361+
"href": "/atomicdex/api/v20/sign_raw_transaction/"
362+
},
359363
{
360364
"title": "my_tx_history",
361365
"href": "/atomicdex/api/v20/my_tx_history/"
@@ -801,6 +805,11 @@
801805
"href": "/atomicdex/api/common_structures/swaps/taker_events/"
802806
}
803807
]
808+
},
809+
{
810+
"title": "Wallet Operations Structures",
811+
"titleLink": "/atomicdex/api/common_structures/wallet/",
812+
"links": []
804813
}
805814
]
806815
},

src/pages/atomicdex/api/common_structures/index.mdx

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ The objects are in the request or response of multiple Komodo DeFi SDK methods h
99
* [Swaps](/atomicdex/api/common_structures/swaps/)
1010
* [Lightning Network](/atomicdex/api/common_structures/lightning/)
1111
* [Non-fungible Tokens](/atomicdex/api/common_structures/nfts/)
12+
* [Wallet Operations](/atomicdex/api/common_structures/wallet/)
1213

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

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
export const title = "Komodo DeFi SDK Common Structures: Wallet Operations";
2+
export const description = "Starting with version beta-2.1.3434, the Komodo DeFi SDK supports the standardized protocol format called mmrpc 2.0.";
3+
4+
# Wallet Operations Structures
5+
6+
### RawTxInfo
7+
8+
The `RawTxInfo` object includes the following items:
9+
10+
| Parameter | Type | Description |
11+
| ---------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
12+
| tx\_hex | string | UTXO only. The raw unsigned hex of a proposed transaction. |
13+
| prev\_txns | list | UTXO only. A list of standard [InputTxns objects](/atomicdex/api/common_structures/wallet/#input-txns). |
14+
| to | string | ETH/EVM only. A destination address to send the funds to. |
15+
| 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. |
16+
| gas\_limit | string | ETH/EVM only. The maximum gas to be used for sending the transaction, in [gwei](https://eth-converter.com/) units. |
17+
18+
<DevComment>
19+
TODO: Confirm units used in ETH/EVM transactions.
20+
</DevComment>
21+
22+
<CollapsibleSection expandedText="Hide UTXO Example" collapsedText="Show UTXO Example">
23+
```json
24+
{
25+
"tx_hex": "02000000010d23d763f12d77a337cc16df2696ac3f48552dda373c9977fa1f5dd8d5025cb20100000000fdffffff01f40100000000000016001488accd2145b7232b958db5cdf09336ad619541e200000000",
26+
"prev_txns": [
27+
...
28+
]
29+
}
30+
```
31+
</CollapsibleSection>
32+
33+
<CollapsibleSection expandedText="Hide ETH/EVM Example" collapsedText="Show ETH/EVM Example">
34+
```json
35+
{
36+
"to": "0x927DaFDDa16F1742BeFcBEAE6798090354B294A9",
37+
"value": "0.85",
38+
"gas_limit": "21000"
39+
}
40+
```
41+
</CollapsibleSection>
42+
43+
### InputTxns
44+
45+
The `InputTxns` object includes the following items:
46+
47+
| Parameter | Type | Description |
48+
| ---------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
49+
| tx\_hash | string | The transaction id of an unspent transaction from the same wallet output. |
50+
| 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. |
51+
| script\_pub\_key | string | The [scriptpubkey](https://learnmeabitcoin.com/technical/scriptPubKey) of this unspent transaction output. |
52+
| amount | float | The value of this unspent transaction output. |
53+
| amount | | |
54+
55+
<CollapsibleSection expandedText="Hide Example" collapsedText="Show Example">
56+
```json
57+
{
58+
"tx_hash": "0d23d763f12d77a337cc16df2696ac3f48552dda373c9977fa1f5dd8d5025cb2",
59+
"index": 1,
60+
"script_pub_key": "001449e3b6b4684c4d4a914b29411af51843c59bfff0",
61+
"amount": 0.00001000
62+
}
63+
```
64+
</CollapsibleSection>

src/pages/atomicdex/api/index.mdx

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ Below is a table of the currently available legacy, v2.0 and v2.0 (Dev) methods:
9595
| [setprice](/atomicdex/api/legacy/setprice/#setprice) | | |
9696
| [show\_priv\_key](/atomicdex/api/legacy/show_priv_key/#show-priv-key) | | |
9797
| | [sign\_message](/atomicdex/api/v20/message_signing/#sign-message) | |
98+
| | [sign\_raw\_transaction](/atomicdex/api/v20/sign_raw_transaction/#sign-raw-transaction) | |
9899
| | [start\_simple\_market\_maker\_bot](/atomicdex/api/v20/start_simple_market_maker_bot/#start-simple-market-maker-bot) | |
99100
| | [start\_version\_stat\_collection](/atomicdex/api/v20/start_version_stat_collection/#start-version-stat-collection) | |
100101
| | [stop\_simple\_market\_maker\_bot](/atomicdex/api/v20/stop_simple_market_maker_bot/#stop-simple-market-maker-bot) | |

0 commit comments

Comments
 (0)