feat(tx): add new sign_raw_transaction rpc for UTXO and EVM coins#1930
feat(tx): add new sign_raw_transaction rpc for UTXO and EVM coins#1930
Conversation
| hex::decode(args.tx_hex.as_bytes()).map_to_mm(|e| RawTransactionError::InvalidParam(e.to_string()))?; | ||
| let tx: UtxoTx = | ||
| deserialize(tx_bytes.as_slice()).map_to_mm(|e| RawTransactionError::InvalidParam(e.to_string()))?; |
There was a problem hiding this comment.
I think these should be TxByteParseError or DecodeError
| .map_to_mm(|e| RawTransactionError::InvalidParam(e.to_string()))?, | ||
| ); | ||
| } | ||
|
|
||
| let prev_hash = hex::decode(prev_utxo.tx_hash.as_bytes()) | ||
| .map_err(|e| RawTransactionError::InvalidParam(e.to_string()))?; |
| .filter(|input| !unspents.iter().any(|u| u.outpoint.hash == input.previous_output.hash)) | ||
| .map(|input| input.previous_output.hash.into()) |
There was a problem hiding this comment.
what about using filter_map here once?
| signature_version, | ||
| coin.as_ref().conf.fork_id, | ||
| ) | ||
| .map_err(|err| RawTransactionError::SigningError(err.get_inner().to_string()))?; |
There was a problem hiding this comment.
why don't we just call err.to_string() so we get the error trace too
| let secret = SecretKey::from_slice(&*self.secret)?; | ||
| let message = SecpMessage::from_slice(&**message)?; | ||
| let signature = SECP_SIGN.sign(&message, &secret); | ||
| let signature = SECP_SIGN.sign_low_r(&message, &secret); // use low R signing from bitcoin which reduces signature malleability |
There was a problem hiding this comment.
// use low R signing from bitcoin which reduces signature malleability
let signature = SECP_SIGN.sign_low_r(&message, &secret); |
@dimxy please fix clippy and fmt warnings, you should use |
shamardy
left a comment
There was a problem hiding this comment.
Thanks a lot for the PR! First review iteration!
okay thank you, I used clippy but apparently with different params that I found in the contrib guide |
Contribution guide needs lots of updates apparently. |
|
thank you all for your reviews, added new commits following them: used async_trait, fixed formatting, clippy errs, refactored sign_raw_tx (advised function added), improved RawTransactionError |
shamardy
left a comment
There was a problem hiding this comment.
Thanks a lot for the fixes! Next review iteration!
5d422ab to
7f01291
Compare
|
I rebased on the latest dev. I believe I have made all fixes requested by the reviewers |
shamardy
left a comment
There was a problem hiding this comment.
Next review iteration! Will do one final review round once these comments are fixed.
|
@dimxy please note, that this PR started to have conflicts |
Oh, thank you. I have already fixed several conflicts recently but more of them came |
f5afcf8 to
a699167
Compare
|
just rebased on the latest dev |
Thanks! I'm, still a little confused about the ETH/EVM units. Seems the |
|
Docs draft at https://edbbd891.komodo-docs.pages.dev/en/docs/atomicdex/api/v20/sign_raw_transaction/ |
Yes it is in wei and to be directly converted into U256 'value' (as it was supposed to be the 'raw transaction'). |
…saction for ETH type
9cb21d2 to
eb0dfee
Compare
| } | ||
|
|
||
| impl From<&'static str> for Address { | ||
| fn from(s: &'static str) -> Self { s.parse().unwrap() } |
There was a problem hiding this comment.
Ideally this should be conditionally compiled for tests only.
There was a problem hiding this comment.
Yes, here is a PR for refactoring this struct and a discussion on this unwrap in it: #1960 (comment)
* dev: (22 commits) chore(config): remove vscode launchjson (GLEECBTC#2040) feat(trading-proto-upgrade): wasm DB, kickstart, refund states, v2 RPCs (GLEECBTC#2015) feat(UTXO): balance event streaming for Electrum clients (GLEECBTC#2013) feat(tx): add new sign_raw_transaction rpc for UTXO and EVM coins (GLEECBTC#1930) fix(p2p): handle encode_and_sign errors (GLEECBTC#2038) chore(release): add changelog entries for v2.0.0-beta (GLEECBTC#2037) chore(network): write network information to stdout (GLEECBTC#2034) fix(price_endpoints): add cached url (GLEECBTC#2032) deps(network): sync with upstream yamux (GLEECBTC#2030) fix(config): accept a string as rpcport value (GLEECBTC#2026) feat(nft): move db lock, add tx fee and confirmations (GLEECBTC#1989) chore(network): update seednodes for netid 8762 (GLEECBTC#2024) chore(network): add todo on peer storage behaviour (GLEECBTC#2025) chore(network): exclude `168.119.236.249` from the seednode list (GLEECBTC#2021) feat(network): deprecate 7777 network (GLEECBTC#2020) chore(release): bump mm2 version to 2.0.0-beta (GLEECBTC#2018) feat(UTXO swaps): kmd burn plan impl (GLEECBTC#2006) chore(docs): fix the link to simple market maker in README.md (GLEECBTC#2011) refactor(cli): cli dependency updates and warn on bad config perm (GLEECBTC#1956) chore(containers and docs): update docs and container images (GLEECBTC#2003) ... # Conflicts: # mm2src/mm2_main/tests/mm2_tests/mm2_tests_inner.rs # mm2src/mm2_test_helpers/src/for_tests.rs
* dev: (24 commits) chore(release): bump mm2 version to 2.1.0-beta (GLEECBTC#2044) feat(trezor): add segwit support for withdraw with trezor (GLEECBTC#1984) chore(config): remove vscode launchjson (GLEECBTC#2040) feat(trading-proto-upgrade): wasm DB, kickstart, refund states, v2 RPCs (GLEECBTC#2015) feat(UTXO): balance event streaming for Electrum clients (GLEECBTC#2013) feat(tx): add new sign_raw_transaction rpc for UTXO and EVM coins (GLEECBTC#1930) fix(p2p): handle encode_and_sign errors (GLEECBTC#2038) chore(release): add changelog entries for v2.0.0-beta (GLEECBTC#2037) chore(network): write network information to stdout (GLEECBTC#2034) fix(price_endpoints): add cached url (GLEECBTC#2032) deps(network): sync with upstream yamux (GLEECBTC#2030) fix(config): accept a string as rpcport value (GLEECBTC#2026) feat(nft): move db lock, add tx fee and confirmations (GLEECBTC#1989) chore(network): update seednodes for netid 8762 (GLEECBTC#2024) chore(network): add todo on peer storage behaviour (GLEECBTC#2025) chore(network): exclude `168.119.236.249` from the seednode list (GLEECBTC#2021) feat(network): deprecate 7777 network (GLEECBTC#2020) chore(release): bump mm2 version to 2.0.0-beta (GLEECBTC#2018) feat(UTXO swaps): kmd burn plan impl (GLEECBTC#2006) chore(docs): fix the link to simple market maker in README.md (GLEECBTC#2011) ...
* evm-hd-wallet: (27 commits) Fix todo comments Fix HDAddressOps::Address trait bounds fix(indexeddb): fix IDB cursor.continue_() call after drop (GLEECBTC#2028) security bump for `h2` (GLEECBTC#2062) fix(makerbot): allow more than one prices url in makerbot (GLEECBTC#2027) fix(wasm worker env): refactor direct usage of `window` (GLEECBTC#1953) feat(nft): nft abi in withdraw_nft RPC, clear_nft_db RPC (GLEECBTC#2039) refactor(utxo): refactor utxo output script creation (GLEECBTC#1960) feat(ETH): balance event streaming for ETH (GLEECBTC#2041) chore(release): bump mm2 version to 2.1.0-beta (GLEECBTC#2044) feat(trezor): add segwit support for withdraw with trezor (GLEECBTC#1984) chore(config): remove vscode launchjson (GLEECBTC#2040) feat(trading-proto-upgrade): wasm DB, kickstart, refund states, v2 RPCs (GLEECBTC#2015) feat(UTXO): balance event streaming for Electrum clients (GLEECBTC#2013) feat(tx): add new sign_raw_transaction rpc for UTXO and EVM coins (GLEECBTC#1930) fix(p2p): handle encode_and_sign errors (GLEECBTC#2038) chore(release): add changelog entries for v2.0.0-beta (GLEECBTC#2037) chore(network): write network information to stdout (GLEECBTC#2034) fix(price_endpoints): add cached url (GLEECBTC#2032) deps(network): sync with upstream yamux (GLEECBTC#2030) ...
Adds new sign_raw_transaction rpc method for UTXO coins.
Currently supports P2PKH and P2WPKH spent outputs.
Closes #1407
TODO:
support more previous output types
support several signing keys
update docs to add rpc desc
signing with trezor