Merge pull request #543 from LedgerHQ/fix/apa/client_non_legacy_recover_transaction

Fix recover_transaction function in Ragger client
This commit is contained in:
apaillier-ledger
2024-02-27 16:52:15 +01:00
committed by GitHub
2 changed files with 11 additions and 12 deletions

View File

@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed ### Fixed
- Increased the delay between `autonext` callback calls for EIP-712 on Stax - Increased the delay between `autonext` callback calls for EIP-712 on Stax
- `recover_transaction` util function for non-legacy transactions
## [0.2.1] - 2023-12-01 ## [0.2.1] - 2023-12-01

View File

@@ -17,14 +17,12 @@ def recover_message(msg, vrs: tuple) -> bytes:
return bytes.fromhex(addr[2:]) return bytes.fromhex(addr[2:])
# TODO: Figure out why it doesn't work for non-legacy transactions
def recover_transaction(tx_params, vrs: tuple) -> bytes: def recover_transaction(tx_params, vrs: tuple) -> bytes:
raw_tx = Account.create().sign_transaction(tx_params).rawTransaction raw_tx = Account.create().sign_transaction(tx_params).rawTransaction
prefix = bytes() prefix = bytes()
if raw_tx[0] in [0x01, 0x02]: if raw_tx[0] in [0x01, 0x02]:
prefix = raw_tx[:1] prefix = raw_tx[:1]
raw_tx = raw_tx[len(prefix):] raw_tx = raw_tx[len(prefix):]
if prefix == bytes():
# v is returned on one byte only so it might have overflowed # v is returned on one byte only so it might have overflowed
# in that case, we will reconstruct it to its full value # in that case, we will reconstruct it to its full value
if "chainId" in tx_params: if "chainId" in tx_params: