Fix subscript[0] in compressor.cpp

This commit is contained in:
Jeremy Rubin 2017-02-19 12:39:51 -05:00
parent 500710bd29
commit 96f2119e6c

View file

@ -93,7 +93,7 @@ bool CScriptCompressor::Decompress(unsigned int nSize, const std::vector<unsigne
script[0] = OP_DUP; script[0] = OP_DUP;
script[1] = OP_HASH160; script[1] = OP_HASH160;
script[2] = 20; script[2] = 20;
memcpy(&script[3], &in[0], 20); memcpy(&script[3], in.data(), 20);
script[23] = OP_EQUALVERIFY; script[23] = OP_EQUALVERIFY;
script[24] = OP_CHECKSIG; script[24] = OP_CHECKSIG;
return true; return true;
@ -101,7 +101,7 @@ bool CScriptCompressor::Decompress(unsigned int nSize, const std::vector<unsigne
script.resize(23); script.resize(23);
script[0] = OP_HASH160; script[0] = OP_HASH160;
script[1] = 20; script[1] = 20;
memcpy(&script[2], &in[0], 20); memcpy(&script[2], in.data(), 20);
script[22] = OP_EQUAL; script[22] = OP_EQUAL;
return true; return true;
case 0x02: case 0x02:
@ -109,14 +109,14 @@ bool CScriptCompressor::Decompress(unsigned int nSize, const std::vector<unsigne
script.resize(35); script.resize(35);
script[0] = 33; script[0] = 33;
script[1] = nSize; script[1] = nSize;
memcpy(&script[2], &in[0], 32); memcpy(&script[2], in.data(), 32);
script[34] = OP_CHECKSIG; script[34] = OP_CHECKSIG;
return true; return true;
case 0x04: case 0x04:
case 0x05: case 0x05:
unsigned char vch[33] = {}; unsigned char vch[33] = {};
vch[0] = nSize - 2; vch[0] = nSize - 2;
memcpy(&vch[1], &in[0], 32); memcpy(&vch[1], in.data(), 32);
CPubKey pubkey(&vch[0], &vch[33]); CPubKey pubkey(&vch[0], &vch[33]);
if (!pubkey.Decompress()) if (!pubkey.Decompress())
return false; return false;