diff --git a/common/protob/messages-cardano.proto b/common/protob/messages-cardano.proto index e6b06c0110..5b8e6c31de 100644 --- a/common/protob/messages-cardano.proto +++ b/common/protob/messages-cardano.proto @@ -205,6 +205,7 @@ message CardanoSignTxInit { required uint32 witness_requests_count = 12; required uint32 minting_asset_groups_count = 13; required CardanoDerivationType derivation_type = 14; + optional bool include_network_id = 15 [default=false]; // network id included as tx body item } /** diff --git a/common/tests/fixtures/cardano/sign_tx.failed.json b/common/tests/fixtures/cardano/sign_tx.failed.json index 4dde96f27c..eec5e18027 100644 --- a/common/tests/fixtures/cardano/sign_tx.failed.json +++ b/common/tests/fixtures/cardano/sign_tx.failed.json @@ -29,7 +29,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid address" @@ -60,7 +61,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid address" @@ -91,7 +93,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid address" @@ -122,7 +125,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid address" @@ -153,7 +157,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid address" @@ -184,7 +189,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Fee is out of range" @@ -220,7 +226,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Total transaction amount is out of range!" @@ -251,7 +258,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Output address network mismatch" @@ -282,7 +290,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Output address network mismatch" @@ -313,7 +322,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid address" @@ -344,7 +354,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid address" @@ -375,7 +386,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid network id/protocol magic combination!" @@ -406,7 +418,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid network id/protocol magic combination!" @@ -437,7 +450,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid address" @@ -471,7 +485,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid output" @@ -507,7 +522,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid certificate" @@ -543,7 +559,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid certificate" @@ -579,7 +596,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid certificate" @@ -616,7 +634,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid certificate" @@ -653,7 +672,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid certificate" @@ -689,7 +709,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid withdrawal" @@ -725,7 +746,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid withdrawal" @@ -761,7 +783,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid withdrawal" @@ -797,7 +820,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid withdrawal" @@ -834,7 +858,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid withdrawal" @@ -874,7 +899,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Duplicate withdrawals" @@ -907,7 +933,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid auxiliary data" @@ -948,7 +975,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid auxiliary data" @@ -991,7 +1019,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid auxiliary data" @@ -1028,7 +1057,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid change output path" @@ -1065,7 +1095,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid change output staking path" @@ -1102,7 +1133,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid address parameters" @@ -1133,7 +1165,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid address" @@ -1169,7 +1202,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid certificate path" @@ -1215,7 +1249,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid token bundle in output" @@ -1266,7 +1301,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid token bundle in output" @@ -1301,7 +1337,8 @@ { "path": "m/1854'/1815'/0'/0/0" } - ] + ], + "include_network_id": false }, "result": { "error_message": "Invalid witness request" @@ -1336,7 +1373,8 @@ { "path": "m/1854'/1815'/0'/0/0" } - ] + ], + "include_network_id": false }, "result": { "error_message": "Invalid witness request" @@ -1369,7 +1407,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid address parameters" @@ -1452,7 +1491,8 @@ { "path": "m/1854'/1815'/0'/0/0" } - ] + ], + "include_network_id": false }, "result": { "error_message": "Invalid witness request" @@ -1488,7 +1528,8 @@ { "path": "m/1855'/1815'/0'" } - ] + ], + "include_network_id": false }, "result": { "error_message": "Invalid witness request" @@ -1575,7 +1616,8 @@ { "path": "m/1855'/1815'/0'/0/0" } - ] + ], + "include_network_id": false }, "result": { "error_message": "Invalid witness request" @@ -1612,7 +1654,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid witness request" @@ -1648,7 +1691,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid witness request" @@ -1684,7 +1728,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid witness request" @@ -1726,7 +1771,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid certificate" @@ -1768,7 +1814,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid withdrawal" @@ -1809,7 +1856,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid withdrawal" @@ -1844,7 +1892,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid witness request" @@ -1876,7 +1925,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid witness request" diff --git a/common/tests/fixtures/cardano/sign_tx.json b/common/tests/fixtures/cardano/sign_tx.json index e2a22f0fb7..f55304ea26 100644 --- a/common/tests/fixtures/cardano/sign_tx.json +++ b/common/tests/fixtures/cardano/sign_tx.json @@ -29,7 +29,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "73e09bdebf98a9e0f17f86a2d11e0f14f4f8dae77cdf26ff1678e821f20c8db6", @@ -73,7 +74,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "81b14b7e62972127eb33c0b1198de6430540ad3a98eec621a3194f2baac43a43", @@ -118,7 +120,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "16fe72bb198be423677577e6326f1f648ec5fc11263b072006382d8125a6edda", @@ -172,7 +175,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "7e16a0b47bdfc37abf4ddd3143f7481af07ffe7abd68f752676f5b0b2890d05b", @@ -235,7 +239,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "5ddbb530b8a89e2b08fc91db03950c876c4a9c1c3fb6e628c4cab638b1c97648", @@ -281,7 +286,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "1fc82ce2420c173a0947eaf49af76fcd6f4e400e2bfb5fa152a482ea12dde24b", @@ -327,7 +333,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "abd1b24ac0638251398444ee136110f952738df32a512ce35894f8453d0e8edf", @@ -372,7 +379,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "d1610bb89bece22ed3158738bc1fbb31c6af0685053e2993361e3380f49afad9", @@ -419,7 +427,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "40535fa8f88515f1da008d3cdf544cf9dbf1675c3cb0adb13b74b9293f1b7096", @@ -463,7 +472,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "d3570557b197604109481a80aeb66cd2cfabc57f802ad593bacc12eb658e5d72", @@ -507,7 +517,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "1a3a295908afd8b2afc368071272d6964be6ee0af062bb765aea65ca454dc0c9", @@ -546,7 +557,8 @@ "outputs": [], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "03535791d04fc1b4457fada025f1c1f7778b5c2d7fa580bbac8abd53b85d3255", @@ -595,7 +607,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "439764b5f7e08839881536a3191faeaf111e75d9f00f83b102c5c1c6fa9fcaf9", @@ -645,7 +658,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "3aca1784d151dc75bdbb80fae71bda3f4b26af3f5fd71bd5e9e9bbcdd2b64ad1", @@ -700,7 +714,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "22c67f12e6f6aa0f2f09fd27d472b19c7208ccd7c3af4b09604fd5d462c1de2b", @@ -751,7 +766,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "cc068a25994ef6a90cdab8adfbe302d6f742de9901ba2495dd64a09f2ef951f5", @@ -798,7 +814,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "1875f1d59a53f1cb4c43949867d72bcfd857fa3b64feb88f41b78ddaa1a21cbf", @@ -848,7 +865,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "839a587109358e0aa81b8fb3d5fa74665fac303425ec544a4db7f6ba4e882dff", @@ -901,7 +919,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "47cf79f20c6c62edb4162b3b232a57afc1bd0b57c7fd8389555276408a004776", @@ -958,7 +977,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "b7269ddc59e4094a6581c653e0d5dc1e553e3a5fb6ffae47d3d094dff1cfe87b", @@ -1028,7 +1048,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "0b929def7bd9f44f5602f809bc0f9be30521f6b93d625525cf33b956993bfb22", @@ -1068,7 +1089,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "b621e22f7cb9aac1a70a3362fde88bdfd31fc100e20f3f3c24a7b853536b4f50", @@ -1117,7 +1139,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "00d393f7fc9a8c17b3efccb44dad9d7e15fdaf2d942a3a455b52b5be016066dd", @@ -1168,7 +1191,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "f4b7315ec080d05024d1f7bf6795dd234c6624970d8e272a245702de539feaa2", @@ -1214,7 +1238,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "cabc87a76ad8944e8a97a7cbf9c893a77ed7d1bd963c428c3786d663adb7f0dd", @@ -1351,7 +1376,8 @@ }, "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "ee0dfef8b97857ebe7aa8935af50e9f8f608ff4054c0c034600750d722d90631", @@ -1469,7 +1495,8 @@ { "path": "m/1855'/1815'/0'" } - ] + ], + "include_network_id": false }, "result": { "tx_hash": "042c1d3a6eab693d2ea6b186a88aed038159e7eb581da80464bca7339fb9afe0", @@ -1488,6 +1515,46 @@ } ] } + }, + { + "description": "Ordinary transaction with network id included in tx body", + "parameters": { + "protocol_magic": 764824073, + "network_id": 1, + "fee": 42, + "ttl": 10, + "certificates": [], + "withdrawals": [], + "auxiliary_data": null, + "inputs": [ + { + "path": "m/44'/1815'/0'/0/1", + "prev_hash": "1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc", + "prev_index": 0 + } + ], + "outputs": [ + { + "address": "Ae2tdPwUPEZCanmBz5g2GEwFqKTKpNJcGYPKfDxoNeKZ8bRHr8366kseiK2", + "amount": "3003112" + } + ], + "mint": [], + "signing_mode": "ORDINARY_TRANSACTION", + "additional_witness_requests": [], + "include_network_id": true + }, + "result": { + "tx_hash": "4fcd4532bb0a9dfff2368e60be80d46819a92a9acfb2c64a7bf5975040789bac", + "witnesses": [ + { + "type": 0, + "pub_key": "89053545a6c254b0d9b1464e48d2b5fcf91d4e25c128afb1fcfc61d0843338ea", + "signature": "7223909207fc1fa0c6125ffd4fbf7e1d845b7ca77078de7705aa34e4b6f416bb2efaaadfa022a91437ba4f33875b9a688f78d6fb30542b59417650a169afde01", + "chain_code": "26308151516f3b0e02bb1638142747863c520273ce9bd3e5cd91e1d46fe2a635" + } + ] + } } ] } diff --git a/common/tests/fixtures/cardano/sign_tx.multisig.failed.json b/common/tests/fixtures/cardano/sign_tx.multisig.failed.json index da5454f009..d73f78cf4a 100644 --- a/common/tests/fixtures/cardano/sign_tx.multisig.failed.json +++ b/common/tests/fixtures/cardano/sign_tx.multisig.failed.json @@ -37,7 +37,8 @@ { "path": "m/1854'/1815'/0'/0/0" } - ] + ], + "include_network_id": false }, "result": { "error_message": "Invalid certificate" @@ -79,7 +80,8 @@ { "path": "m/1854'/1815'/2'/0/0" } - ] + ], + "include_network_id": false }, "result": { "error_message": "Invalid certificate" @@ -119,7 +121,8 @@ { "path": "m/1854'/1815'/0'/0/0" } - ] + ], + "include_network_id": false }, "result": { "error_message": "Invalid certificate" @@ -153,7 +156,8 @@ { "path": "m/1852'/1815'/0'/0/0" } - ] + ], + "include_network_id": false }, "result": { "error_message": "Invalid witness request" @@ -189,7 +193,8 @@ { "path": "m/1854'/1815'/0'/0/0" } - ] + ], + "include_network_id": false }, "result": { "error_message": "Invalid output" @@ -223,7 +228,8 @@ { "path": "m/1855'/1815'/0'" } - ] + ], + "include_network_id": false }, "result": { "error_message": "Invalid witness request" @@ -309,7 +315,8 @@ { "path": "m/1855'/1815'/0'/0/0" } - ] + ], + "include_network_id": false }, "result": { "error_message": "Invalid witness request" diff --git a/common/tests/fixtures/cardano/sign_tx.multisig.json b/common/tests/fixtures/cardano/sign_tx.multisig.json index e5bcbe30ab..075c488f2e 100644 --- a/common/tests/fixtures/cardano/sign_tx.multisig.json +++ b/common/tests/fixtures/cardano/sign_tx.multisig.json @@ -87,7 +87,8 @@ { "path": "m/1855'/1815'/0'" } - ] + ], + "include_network_id": false }, "result": { "tx_hash": "042c1d3a6eab693d2ea6b186a88aed038159e7eb581da80464bca7339fb9afe0", @@ -140,7 +141,8 @@ { "path": "m/1854'/1815'/0'/0/0" } - ] + ], + "include_network_id": false }, "result": { "tx_hash": "ed9fc2755091fa72b58e9dd06db05cce87c0c6f3962f587d5fc348fe478f0752", @@ -195,7 +197,8 @@ { "path": "m/1854'/1815'/0'/2/0" } - ] + ], + "include_network_id": false }, "result": { "tx_hash": "26fb07b23368898665829283985ffe6c4cb2ec13758e83f467b78e5061f9619b", @@ -251,7 +254,8 @@ { "path": "m/1854'/1815'/0'/2/0" } - ] + ], + "include_network_id": false }, "result": { "tx_hash": "c4e70484c964eca910219047542632ac9a9ac81f11f5d5afd8bb1b0ef4366d69", @@ -312,7 +316,8 @@ { "path": "m/1854'/1815'/0'/2/0" } - ] + ], + "include_network_id": false }, "result": { "tx_hash": "e02d252c5cad2a4d8f163069cd7f0822c7876d16af9ad8ac2d461655812b2d1b", @@ -413,7 +418,8 @@ { "path": "m/1855'/1815'/0'" } - ] + ], + "include_network_id": false }, "result": { "tx_hash": "2be64c04ea3f5bac3c224ec47a4157ade91fc6ab4fd6b83ce3d57b2e9186720b", diff --git a/common/tests/fixtures/cardano/sign_tx.slip39.json b/common/tests/fixtures/cardano/sign_tx.slip39.json index fcf613f040..7f00d98729 100644 --- a/common/tests/fixtures/cardano/sign_tx.slip39.json +++ b/common/tests/fixtures/cardano/sign_tx.slip39.json @@ -33,7 +33,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "73e09bdebf98a9e0f17f86a2d11e0f14f4f8dae77cdf26ff1678e821f20c8db6", @@ -77,7 +78,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "4c43ce4c72f145b145ae7add414722735e250d048f61c4585a5becafcbffa6ae", @@ -121,7 +123,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "93a2c3cfb67ef1e4bae167b0f443c3370664bdb9171bc9cd41bad98e5cc049b2", diff --git a/common/tests/fixtures/cardano/sign_tx_stake_pool_registration.failed.json b/common/tests/fixtures/cardano/sign_tx_stake_pool_registration.failed.json index a2e708f731..45e002f8de 100644 --- a/common/tests/fixtures/cardano/sign_tx_stake_pool_registration.failed.json +++ b/common/tests/fixtures/cardano/sign_tx_stake_pool_registration.failed.json @@ -50,7 +50,8 @@ ], "mint": [], "signing_mode": "POOL_REGISTRATION_AS_OWNER", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid certificate" @@ -105,7 +106,8 @@ ], "mint": [], "signing_mode": "POOL_REGISTRATION_AS_OWNER", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid certificate" @@ -157,7 +159,8 @@ ], "mint": [], "signing_mode": "POOL_REGISTRATION_AS_OWNER", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid certificate" @@ -209,7 +212,8 @@ ], "mint": [], "signing_mode": "POOL_REGISTRATION_AS_OWNER", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid certificate" @@ -282,7 +286,8 @@ ], "mint": [], "signing_mode": "POOL_REGISTRATION_AS_OWNER", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Stakepool registration transaction cannot contain other certificates, withdrawals or minting" @@ -317,7 +322,8 @@ ], "mint": [], "signing_mode": "POOL_REGISTRATION_AS_OWNER", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid certificate" @@ -374,7 +380,8 @@ ], "mint": [], "signing_mode": "POOL_REGISTRATION_AS_OWNER", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Stakepool registration transaction cannot contain other certificates, withdrawals or minting" @@ -426,7 +433,8 @@ ], "mint": [], "signing_mode": "POOL_REGISTRATION_AS_OWNER", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Stakepool registration transaction can only contain staking witnesses" @@ -477,7 +485,8 @@ ], "mint": [], "signing_mode": "POOL_REGISTRATION_AS_OWNER", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "ProcessError: Invalid address" @@ -528,7 +537,8 @@ ], "mint": [], "signing_mode": "POOL_REGISTRATION_AS_OWNER", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "ProcessError: Invalid address" @@ -613,7 +623,8 @@ ], "mint": [], "signing_mode": "POOL_REGISTRATION_AS_OWNER", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid pool owner staking path" @@ -698,7 +709,8 @@ ], "mint": [], "signing_mode": "ORDINARY_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid certificate" @@ -783,7 +795,8 @@ ], "mint": [], "signing_mode": "MULTISIG_TRANSACTION", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid certificate" @@ -872,7 +885,8 @@ { "path": "m/1854'/1815'/0'/0/0" } - ] + ], + "include_network_id": false }, "result": { "error_message": "Stakepool registration transaction can only contain staking witnesses" @@ -961,7 +975,8 @@ { "path": "m/1855'/1815'/0'/0/0" } - ] + ], + "include_network_id": false }, "result": { "error_message": "Stakepool registration transaction can only contain staking witnesses" @@ -1077,7 +1092,8 @@ { "path": "m/1855'/1815'/0'/0/0" } - ] + ], + "include_network_id": false }, "result": { "error_message": "Stakepool registration transaction cannot contain other certificates, withdrawals or minting" @@ -1164,7 +1180,8 @@ ], "mint": [], "signing_mode": "POOL_REGISTRATION_AS_OWNER", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "error_message": "Invalid output" diff --git a/common/tests/fixtures/cardano/sign_tx_stake_pool_registration.json b/common/tests/fixtures/cardano/sign_tx_stake_pool_registration.json index a324262e9d..98e4d329e7 100644 --- a/common/tests/fixtures/cardano/sign_tx_stake_pool_registration.json +++ b/common/tests/fixtures/cardano/sign_tx_stake_pool_registration.json @@ -83,7 +83,8 @@ ], "mint": [], "signing_mode": "POOL_REGISTRATION_AS_OWNER", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "e3b9a5657bf62609465a930c8359d774c73944973cfc5a104a0f0ed1e1e8db21", @@ -176,7 +177,8 @@ ], "mint": [], "signing_mode": "POOL_REGISTRATION_AS_OWNER", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "c0d944db15446cf05e8db014685414c928d4d9a3e96aea229234be56eeae34c5", @@ -270,7 +272,8 @@ ], "mint": [], "signing_mode": "POOL_REGISTRATION_AS_OWNER", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "f3d62758ff2f520e7256e65be9d8165da60c7979a97202c19d625709412411fd", @@ -330,7 +333,8 @@ ], "mint": [], "signing_mode": "POOL_REGISTRATION_AS_OWNER", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "504f9214142996e0b7e315103b25d88a4afa3d01dd5be22376921b52b01483c3", @@ -390,7 +394,8 @@ ], "mint": [], "signing_mode": "POOL_REGISTRATION_AS_OWNER", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "12921b4f8e77f815e0c8ed97c541fbd5ba38a6d3323f4ff1af0cb934b8ac6b39", @@ -485,7 +490,8 @@ ], "mint": [], "signing_mode": "POOL_REGISTRATION_AS_OWNER", - "additional_witness_requests": [] + "additional_witness_requests": [], + "include_network_id": false }, "result": { "tx_hash": "880fafab19a36407e9af300c2905e2f6bc8a8debd8b625005f56994d242ba460", diff --git a/core/src/apps/cardano/sign_tx.py b/core/src/apps/cardano/sign_tx.py index 1c7445217f..7109461237 100644 --- a/core/src/apps/cardano/sign_tx.py +++ b/core/src/apps/cardano/sign_tx.py @@ -124,6 +124,7 @@ TX_BODY_KEY_WITHDRAWALS = const(5) TX_BODY_KEY_AUXILIARY_DATA = const(7) TX_BODY_KEY_VALIDITY_INTERVAL_START = const(8) TX_BODY_KEY_MINT = const(9) +TX_BODY_KEY_NETWORK_ID = const(15) POOL_REGISTRATION_CERTIFICATE_ITEMS_COUNT = 10 @@ -145,6 +146,7 @@ async def sign_tx( msg.has_auxiliary_data, msg.validity_interval_start is not None, msg.minting_asset_groups_count > 0, + msg.include_network_id, ) ) @@ -282,6 +284,9 @@ async def _process_transaction( with tx_dict.add(TX_BODY_KEY_MINT, minting_dict): await _process_minting(ctx, minting_dict) + if msg.include_network_id: + tx_dict.add(TX_BODY_KEY_NETWORK_ID, msg.network_id) + async def _confirm_transaction( ctx: wire.Context, @@ -1012,12 +1017,18 @@ async def _show_witness_request( def _is_network_id_verifiable(msg: CardanoSignTxInit) -> bool: """ - checks whether there is at least one element that contains + Checks whether there is at least one element that contains information about network ID, otherwise Trezor cannot - guarantee that the tx is actually meant for the given network + guarantee that the tx is actually meant for the given network. + + Note: Shelley addresses contain network id. The intended network + of Byron addresses can be determined based on whether they + contain the protocol magic. These checks are performed during + address validation. """ return ( - msg.outputs_count != 0 + msg.include_network_id + or msg.outputs_count != 0 or msg.withdrawals_count != 0 or msg.signing_mode == CardanoTxSigningMode.POOL_REGISTRATION_AS_OWNER ) diff --git a/core/src/trezor/messages.py b/core/src/trezor/messages.py index c298f91f0d..ed88875fa3 100644 --- a/core/src/trezor/messages.py +++ b/core/src/trezor/messages.py @@ -1331,6 +1331,7 @@ if TYPE_CHECKING: witness_requests_count: "int" minting_asset_groups_count: "int" derivation_type: "CardanoDerivationType" + include_network_id: "bool" def __init__( self, @@ -1349,6 +1350,7 @@ if TYPE_CHECKING: derivation_type: "CardanoDerivationType", ttl: "int | None" = None, validity_interval_start: "int | None" = None, + include_network_id: "bool | None" = None, ) -> None: pass diff --git a/python/src/trezorlib/cardano.py b/python/src/trezorlib/cardano.py index 88c08867f8..708b120a52 100644 --- a/python/src/trezorlib/cardano.py +++ b/python/src/trezorlib/cardano.py @@ -690,6 +690,7 @@ def sign_tx( mint: Sequence[AssetGroupWithTokens] = (), additional_witness_requests: Sequence[Path] = (), derivation_type: messages.CardanoDerivationType = messages.CardanoDerivationType.ICARUS, + include_network_id: bool = False, ) -> Dict[str, Any]: UNEXPECTED_RESPONSE_ERROR = exceptions.TrezorException("Unexpected response") @@ -713,6 +714,7 @@ def sign_tx( minting_asset_groups_count=len(mint), witness_requests_count=len(witness_requests), derivation_type=derivation_type, + include_network_id=include_network_id, ) ) if not isinstance(response, messages.CardanoTxItemAck): diff --git a/python/src/trezorlib/cli/cardano.py b/python/src/trezorlib/cli/cardano.py index 0d8156a1fb..697f4b5c79 100644 --- a/python/src/trezorlib/cli/cardano.py +++ b/python/src/trezorlib/cli/cardano.py @@ -53,6 +53,7 @@ def cli() -> None: type=ChoiceType({m.name: m for m in messages.CardanoDerivationType}), default=messages.CardanoDerivationType.ICARUS, ) +@click.option("-i", "--include-network-id", is_flag=True) @with_client def sign_tx( client: "TrezorClient", @@ -62,6 +63,7 @@ def sign_tx( network_id: int, testnet: bool, derivation_type: messages.CardanoDerivationType, + include_network_id: bool, ) -> cardano.SignTxResponse: """Sign Cardano transaction.""" transaction = json.load(file) @@ -107,6 +109,7 @@ def sign_tx( mint, additional_witness_requests, derivation_type=derivation_type, + include_network_id=include_network_id, ) sign_tx_response["tx_hash"] = sign_tx_response["tx_hash"].hex() diff --git a/python/src/trezorlib/messages.py b/python/src/trezorlib/messages.py index bd6fe97be9..9d852c5446 100644 --- a/python/src/trezorlib/messages.py +++ b/python/src/trezorlib/messages.py @@ -2244,6 +2244,7 @@ class CardanoSignTxInit(protobuf.MessageType): 12: protobuf.Field("witness_requests_count", "uint32", repeated=False, required=True), 13: protobuf.Field("minting_asset_groups_count", "uint32", repeated=False, required=True), 14: protobuf.Field("derivation_type", "CardanoDerivationType", repeated=False, required=True), + 15: protobuf.Field("include_network_id", "bool", repeated=False, required=False), } def __init__( @@ -2263,6 +2264,7 @@ class CardanoSignTxInit(protobuf.MessageType): derivation_type: "CardanoDerivationType", ttl: Optional["int"] = None, validity_interval_start: Optional["int"] = None, + include_network_id: Optional["bool"] = False, ) -> None: self.signing_mode = signing_mode self.protocol_magic = protocol_magic @@ -2278,6 +2280,7 @@ class CardanoSignTxInit(protobuf.MessageType): self.derivation_type = derivation_type self.ttl = ttl self.validity_interval_start = validity_interval_start + self.include_network_id = include_network_id class CardanoTxInput(protobuf.MessageType): diff --git a/tests/device_tests/cardano/test_sign_tx.py b/tests/device_tests/cardano/test_sign_tx.py index c9a8f104e0..316a9e52c2 100644 --- a/tests/device_tests/cardano/test_sign_tx.py +++ b/tests/device_tests/cardano/test_sign_tx.py @@ -73,6 +73,7 @@ def test_cardano_sign_tx(client: Client, parameters, result): auxiliary_data=auxiliary_data, mint=mint, additional_witness_requests=additional_witness_requests, + include_network_id=parameters["include_network_id"], ) assert response == _transform_expected_result(result) @@ -121,6 +122,7 @@ def test_cardano_sign_tx_failed(client: Client, parameters, result): auxiliary_data=auxiliary_data, mint=mint, additional_witness_requests=additional_witness_requests, + include_network_id=parameters["include_network_id"], )