mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-05 20:31:01 +00:00
fix(cardano): don't allow duplicate withdrawals
This commit is contained in:
parent
3cd2182b69
commit
4e5772662c
@ -555,6 +555,44 @@
|
||||
"error_message": "Invalid withdrawal"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"description": "Duplicate withdrawal",
|
||||
"parameters": {
|
||||
"protocol_magic": 764824073,
|
||||
"network_id": 1,
|
||||
"fee": 42,
|
||||
"ttl": 10,
|
||||
"certificates": [],
|
||||
"withdrawals": [
|
||||
{
|
||||
"path": "m/1852'/1815'/0'/2/0",
|
||||
"amount": "1000"
|
||||
},
|
||||
{
|
||||
"path": "m/1852'/1815'/0'/2/0",
|
||||
"amount": "2000"
|
||||
}
|
||||
],
|
||||
"auxiliary_data": null,
|
||||
"inputs": [
|
||||
{
|
||||
"path": "m/1852'/1815'/0'/0/0",
|
||||
"prev_hash": "3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7",
|
||||
"prev_index": 0
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"address": "Ae2tdPwUPEZCanmBz5g2GEwFqKTKpNJcGYPKfDxoNeKZ8bRHr8366kseiK2",
|
||||
"amount": "3003112"
|
||||
}
|
||||
]
|
||||
},
|
||||
"result": {
|
||||
"error_message": "Duplicate withdrawals"
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "Auxiliary data blob is incomplete",
|
||||
"parameters": {
|
||||
|
@ -309,6 +309,7 @@ def _validate_certificates(
|
||||
|
||||
|
||||
def _validate_withdrawals(withdrawals: list[CardanoTxWithdrawalType]) -> None:
|
||||
seen_withdrawals = set()
|
||||
for withdrawal in withdrawals:
|
||||
if not SCHEMA_STAKING_ANY_ACCOUNT.match(withdrawal.path):
|
||||
raise INVALID_WITHDRAWAL
|
||||
@ -316,6 +317,12 @@ def _validate_withdrawals(withdrawals: list[CardanoTxWithdrawalType]) -> None:
|
||||
if not 0 <= withdrawal.amount < LOVELACE_MAX_SUPPLY:
|
||||
raise INVALID_WITHDRAWAL
|
||||
|
||||
path_tuple = tuple(withdrawal.path)
|
||||
if path_tuple in seen_withdrawals:
|
||||
raise wire.ProcessError("Duplicate withdrawals")
|
||||
else:
|
||||
seen_withdrawals.add(path_tuple)
|
||||
|
||||
|
||||
def _cborize_signed_tx(
|
||||
keychain: seed.Keychain, msg: CardanoSignTx
|
||||
|
Loading…
Reference in New Issue
Block a user