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
to complete the process.
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.
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 |
Structure | Type | Description |
---|---|---|
tx_hex | string | The signed transaction hex, ready for broadcast |
POST
sign_raw_transaction{
"userpass": "testpsw",
"mmrpc": "2.0",
"method": "sign_raw_transaction",
"params": {
"coin": "KMD",
"type": "UTXO",
"tx": {
"tx_hex": "0400008085202f8901c8d6d8764e51bbadc0592b99f37b3b7d8c9719686d5a9bf63652a0802a1cd0360200000000feffffff0100dd96d8080000001976a914d346067e3c3c3964c395fee208594790e29ede5d88ac46366665000000000000000000000000000000"
}
},
"id": 0
}
POST
sign_raw_transaction{
"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
}
]
}
}
}
POST
sign_raw_transaction{
"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"
}
}
}
{
"mmrpc": "2.0",
"result": {
"tx_hex": "f86680847735940083021000947bc1bbdd6a0a722fc9bffc49c921b685ecb84b948210008025a06c0ecbccf92caf5ac620b118f09a84a18c73d7b209e75696bb10e3c24c2dba64a055af3638f92daec1eb3057fb6a9ccf418325bb1aa6121a3314c3885100a5e63a"
},
"id": 0
}
You might see this if you try to sign a raw transaction that belongs to a different key pair.
{
"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
}
{
"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
}
{
"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
}
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
}