|
|
@ -345,123 +345,6 @@ def test_unfair_fee(client: Client):
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_no_anonymity(client: Client):
|
|
|
|
|
|
|
|
# Test CoinJoin transaction giving the user's outputs no gain in anonymity.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with client:
|
|
|
|
|
|
|
|
btc.authorize_coinjoin(
|
|
|
|
|
|
|
|
client,
|
|
|
|
|
|
|
|
coordinator="www.example.com",
|
|
|
|
|
|
|
|
max_total_fee=5_005,
|
|
|
|
|
|
|
|
fee_per_anonymity=5_000_000, # 0.005 %
|
|
|
|
|
|
|
|
n=parse_path("m/84h/1h/0h"),
|
|
|
|
|
|
|
|
coin_name="Testnet",
|
|
|
|
|
|
|
|
script_type=messages.InputScriptType.SPENDWITNESS,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inputs = [
|
|
|
|
|
|
|
|
messages.TxInputType(
|
|
|
|
|
|
|
|
# seed "alcohol woman abuse must during monitor noble actual mixed trade anger aisle"
|
|
|
|
|
|
|
|
# 84'/1'/0'/0/0
|
|
|
|
|
|
|
|
# tb1qnspxpr2xj9s2jt6qlhuvdnxw6q55jvygcf89r2
|
|
|
|
|
|
|
|
amount=100_000,
|
|
|
|
|
|
|
|
prev_hash=TXHASH_e5b7e2,
|
|
|
|
|
|
|
|
prev_index=0,
|
|
|
|
|
|
|
|
script_type=messages.InputScriptType.EXTERNAL,
|
|
|
|
|
|
|
|
script_pubkey=bytes.fromhex("00149c02608d469160a92f40fdf8c6ccced029493088"),
|
|
|
|
|
|
|
|
ownership_proof=bytearray.fromhex(
|
|
|
|
|
|
|
|
"534c001901016b2055d8190244b2ed2d46513c40658a574d3bc2deb6969c0535bb818b44d2c40002483045022100a6c7d59b453efa7b4abc9bc724a94c5655ae986d5924dc29d28bcc2b859cbace022047d2bc4422a47f7b044bd6cdfbf63fe1a0ecbf11393f4c0bf8565f867a5ced16012103505f0d82bbdd251511591b34f36ad5eea37d3220c2b81a1189084431ddb3aa3d"
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
commitment_data=b"\x0fwww.example.com" + (1).to_bytes(ROUND_ID_LEN, "big"),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
messages.TxInputType(
|
|
|
|
|
|
|
|
address_n=parse_path("m/84h/1h/0h/1/0"),
|
|
|
|
|
|
|
|
amount=7_289_000,
|
|
|
|
|
|
|
|
prev_hash=FAKE_TXHASH_f982c0,
|
|
|
|
|
|
|
|
prev_index=1,
|
|
|
|
|
|
|
|
script_type=messages.InputScriptType.SPENDWITNESS,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outputs = [
|
|
|
|
|
|
|
|
# Other's coinjoined output.
|
|
|
|
|
|
|
|
messages.TxOutputType(
|
|
|
|
|
|
|
|
address="tb1qk7j3ahs2v6hrv4v282cf0tvxh0vqq7rpt3zcml",
|
|
|
|
|
|
|
|
amount=30_000,
|
|
|
|
|
|
|
|
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
|
|
|
|
|
|
|
payment_req_index=0,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
# Other's coinjoined output.
|
|
|
|
|
|
|
|
messages.TxOutputType(
|
|
|
|
|
|
|
|
address="tb1q9cqhdr9ydetjzrct6tyeuccws9505hl96azwxk",
|
|
|
|
|
|
|
|
amount=30_000,
|
|
|
|
|
|
|
|
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
|
|
|
|
|
|
|
payment_req_index=0,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
# Our coinjoined output.
|
|
|
|
|
|
|
|
messages.TxOutputType(
|
|
|
|
|
|
|
|
# tb1qze76uzqteg6un6jfcryrxhwvfvjj58ts0swg3d
|
|
|
|
|
|
|
|
address_n=parse_path("m/84h/1h/0h/1/1"),
|
|
|
|
|
|
|
|
amount=50_000,
|
|
|
|
|
|
|
|
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
|
|
|
|
|
|
|
payment_req_index=0,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
# Our coinjoined output.
|
|
|
|
|
|
|
|
messages.TxOutputType(
|
|
|
|
|
|
|
|
# tb1qr5p6f5sk09sms57ket074vywfymuthlgud7xyx
|
|
|
|
|
|
|
|
address_n=parse_path("m/84h/1h/0h/1/2"),
|
|
|
|
|
|
|
|
amount=50_000,
|
|
|
|
|
|
|
|
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
|
|
|
|
|
|
|
payment_req_index=0,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
# Our change output.
|
|
|
|
|
|
|
|
messages.TxOutputType(
|
|
|
|
|
|
|
|
# tb1qwn0s88t9r39g72m78mcaxj72sy3ct4m404xsmq
|
|
|
|
|
|
|
|
address_n=parse_path("m/84h/1h/0h/1/3"),
|
|
|
|
|
|
|
|
amount=7_289_000 - 50_000 - 50_000 - 10 - 5_000,
|
|
|
|
|
|
|
|
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
|
|
|
|
|
|
|
payment_req_index=0,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
# Other's change output.
|
|
|
|
|
|
|
|
messages.TxOutputType(
|
|
|
|
|
|
|
|
address="tb1q9cqhdr9ydetjzrct6tyeuccws9505hl96azwxk",
|
|
|
|
|
|
|
|
amount=100_000 - 30_000 - 30_000 - 6 - 5_000,
|
|
|
|
|
|
|
|
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
|
|
|
|
|
|
|
payment_req_index=0,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
# Coordinator's output.
|
|
|
|
|
|
|
|
messages.TxOutputType(
|
|
|
|
|
|
|
|
address="mvbu1Gdy8SUjTenqerxUaZyYjmveZvt33q",
|
|
|
|
|
|
|
|
amount=16,
|
|
|
|
|
|
|
|
script_type=messages.OutputScriptType.PAYTOWITNESS,
|
|
|
|
|
|
|
|
payment_req_index=0,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
payment_req = make_payment_request(
|
|
|
|
|
|
|
|
client,
|
|
|
|
|
|
|
|
recipient_name="www.example.com",
|
|
|
|
|
|
|
|
outputs=outputs,
|
|
|
|
|
|
|
|
change_addresses=[
|
|
|
|
|
|
|
|
"tb1qze76uzqteg6un6jfcryrxhwvfvjj58ts0swg3d",
|
|
|
|
|
|
|
|
"tb1qr5p6f5sk09sms57ket074vywfymuthlgud7xyx",
|
|
|
|
|
|
|
|
"tb1qwn0s88t9r39g72m78mcaxj72sy3ct4m404xsmq",
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
payment_req.amount = None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with pytest.raises(TrezorFailure, match="No anonymity gain"):
|
|
|
|
|
|
|
|
btc.sign_tx(
|
|
|
|
|
|
|
|
client,
|
|
|
|
|
|
|
|
"Testnet",
|
|
|
|
|
|
|
|
inputs,
|
|
|
|
|
|
|
|
outputs,
|
|
|
|
|
|
|
|
prev_txes=TX_CACHE_TESTNET,
|
|
|
|
|
|
|
|
payment_reqs=[payment_req],
|
|
|
|
|
|
|
|
preauthorized=True,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_wrong_coordinator(client: Client):
|
|
|
|
def test_wrong_coordinator(client: Client):
|
|
|
|
# Ensure that a preauthorized GetOwnershipProof fails if the commitment_data doesn't match the coordinator.
|
|
|
|
# Ensure that a preauthorized GetOwnershipProof fails if the commitment_data doesn't match the coordinator.
|
|
|
|
|
|
|
|
|
|
|
|