mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-24 07:18:09 +00:00
core: forbid unnecessary fields in OPRETURN output
This commit is contained in:
parent
2ae8e16dd3
commit
4af9aa547e
@ -706,6 +706,10 @@ def output_derive_script(
|
||||
raise SigningError(
|
||||
FailureType.DataError, "OP_RETURN output with non-zero amount"
|
||||
)
|
||||
if o.address or o.address_n or o.multisig:
|
||||
raise SigningError(
|
||||
FailureType.DataError, "OP_RETURN output with address or multisig"
|
||||
)
|
||||
return scripts.output_script_paytoopreturn(o.op_return_data)
|
||||
|
||||
if o.address_n:
|
||||
|
@ -118,6 +118,7 @@ class TestOpReturn:
|
||||
== "010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b483045022100bc36e1227b334e856c532bbef86d30a96823a5f2461738f4dbf969dfbcf1b40b022078c5353ec9a4bce2bb05bd1ec466f2ab379c1aad926e208738407bba4e09784b012103330236b68aa6fdcaca0ea72e11b360c84ed19a338509aa527b678a7ec9076882ffffffff0260cc0500000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000000000001c6a1a74657374206f6620746865206f705f72657475726e206461746100000000"
|
||||
)
|
||||
|
||||
@pytest.mark.skip_ui
|
||||
def test_nonzero_opreturn(self, client):
|
||||
inp1 = proto.TxInputType(
|
||||
address_n=parse_path("44'/0'/10'/0/5"),
|
||||
@ -179,3 +180,60 @@ class TestOpReturn:
|
||||
assert exc.value.args[1].endswith(
|
||||
"OP_RETURN output with non-zero amount"
|
||||
)
|
||||
|
||||
@pytest.mark.skip_ui
|
||||
def test_opreturn_address(self, client):
|
||||
inp1 = proto.TxInputType(
|
||||
address_n=parse_path("44'/0'/0'/0/2"), prev_hash=TXHASH_d5f65e, prev_index=0
|
||||
)
|
||||
|
||||
out1 = proto.TxOutputType(
|
||||
address_n=parse_path("44'/0'/0'/1/2"),
|
||||
amount=0,
|
||||
op_return_data=b"OMNI TRANSACTION GOES HERE",
|
||||
script_type=proto.OutputScriptType.PAYTOOPRETURN,
|
||||
)
|
||||
|
||||
with client:
|
||||
client.set_expected_responses(
|
||||
[
|
||||
proto.TxRequest(
|
||||
request_type=proto.RequestType.TXINPUT,
|
||||
details=proto.TxRequestDetailsType(request_index=0),
|
||||
),
|
||||
proto.TxRequest(
|
||||
request_type=proto.RequestType.TXMETA,
|
||||
details=proto.TxRequestDetailsType(tx_hash=TXHASH_d5f65e),
|
||||
),
|
||||
proto.TxRequest(
|
||||
request_type=proto.RequestType.TXINPUT,
|
||||
details=proto.TxRequestDetailsType(
|
||||
request_index=0, tx_hash=TXHASH_d5f65e
|
||||
),
|
||||
),
|
||||
proto.TxRequest(
|
||||
request_type=proto.RequestType.TXINPUT,
|
||||
details=proto.TxRequestDetailsType(
|
||||
request_index=1, tx_hash=TXHASH_d5f65e
|
||||
),
|
||||
),
|
||||
proto.TxRequest(
|
||||
request_type=proto.RequestType.TXOUTPUT,
|
||||
details=proto.TxRequestDetailsType(
|
||||
request_index=0, tx_hash=TXHASH_d5f65e
|
||||
),
|
||||
),
|
||||
proto.TxRequest(
|
||||
request_type=proto.RequestType.TXOUTPUT,
|
||||
details=proto.TxRequestDetailsType(request_index=0),
|
||||
),
|
||||
proto.Failure(),
|
||||
]
|
||||
)
|
||||
with pytest.raises(CallException) as exc:
|
||||
_, serialized_tx = btc.sign_tx(
|
||||
client, "Bitcoin", [inp1], [out1], prev_txes=TX_API
|
||||
)
|
||||
|
||||
assert exc.value.args[0] == proto.FailureType.DataError
|
||||
assert exc.value.args[1] == "OP_RETURN output with address or multisig"
|
||||
|
@ -371,7 +371,6 @@
|
||||
"test_multisig_change.py-test_multisig_external_external": "ddecdadd659b0d1360a6a255c6f9dbf2c5b813039877b76d4062ddab765e1912",
|
||||
"test_multisig_change.py-test_multisig_mismatch_change": "7cb243b20be31a587dced4aaaf782a2d8487595369dde66aacb1b9a76e89c4fe",
|
||||
"test_multisig_change.py-test_multisig_mismatch_inputs": "64741bd84c5394e719125c1fbe8c34ef866ac63ca24ee1299e4268c59a199466",
|
||||
"test_op_return.py-test_nonzero_opreturn": "826099ec3e22bd113fac1bc6f4b22e362673a730ad6838a8894b52541837141c",
|
||||
"test_op_return.py-test_opreturn": "87907ef9c2f4ce30ac95ad7d0cb3eac66762756e4ace52147bc589d64277f3b1",
|
||||
"test_passphrase_slip39_advanced.py::test_128bit_passphrase": "69b6b8b22c819e1282d7d2c14b31bf8d015c81ac05fe034540dbb11c8a20dbdb",
|
||||
"test_passphrase_slip39_advanced.py::test_256bit_passphrase": "69b6b8b22c819e1282d7d2c14b31bf8d015c81ac05fe034540dbb11c8a20dbdb",
|
||||
|
Loading…
Reference in New Issue
Block a user