From ba63157a776d3d2884f19540ad2a0f672f908885 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Tue, 19 Aug 2014 00:49:17 +0200 Subject: [PATCH] check coin->address_type while building output --- firmware/transaction.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/firmware/transaction.c b/firmware/transaction.c index 8aa4776bd..69acabd73 100644 --- a/firmware/transaction.c +++ b/firmware/transaction.c @@ -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;