1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 22:38:08 +00:00

check coin->address_type while building output

This commit is contained in:
Pavol Rusnak 2014-08-19 00:49:17 +02:00
parent e5d55967a0
commit ba63157a77

View File

@ -106,6 +106,9 @@ int compile_output(const CoinType *coin, const HDNode *root, TxOutputType *in, T
if (!ecdsa_address_decode(in->address, decoded)) {
return 0;
}
if (decoded[0] != coin->address_type) {
return 0;
}
memcpy(out->script_pubkey.bytes + 3, decoded + 1, 20);
out->script_pubkey.bytes[23] = 0x88; // OP_EQUALVERIFY
out->script_pubkey.bytes[24] = 0xAC; // OP_CHECKSIG
@ -120,6 +123,9 @@ int compile_output(const CoinType *coin, const HDNode *root, TxOutputType *in, T
if (!ecdsa_address_decode(in->address, decoded)) {
return 0;
}
if (decoded[0] != 0x05) { // 0x05 is P2SH
return 0;
}
memcpy(out->script_pubkey.bytes + 2, decoded + 1, 20);
out->script_pubkey.bytes[22] = 0x87; // OP_EQUAL
out->script_pubkey.size = 23;