implement sighash_single bug.
This commit is contained in:
parent
1b07d6e906
commit
c44ea0090f
@ -150,3 +150,8 @@ exports.block = {
|
||||
};
|
||||
|
||||
exports.locktimeThreshold = 500000000; // Tue Nov 5 00:53:20 1985 UTC
|
||||
|
||||
exports.oneHash = utils.toArray(
|
||||
'0000000000000000000000000000000000000000000000000000000000000001',
|
||||
'hex'
|
||||
);
|
||||
|
||||
@ -414,6 +414,11 @@ TX.prototype.subscriptHash = function subscriptHash(index, s, type) {
|
||||
if (typeof type === 'string')
|
||||
type = constants.hashType[type];
|
||||
|
||||
// bitcoind used to return 1 as an error code:
|
||||
// it ended up being treated like a hash.
|
||||
if (index >= copy.inputs.length)
|
||||
return constants.oneHash;
|
||||
|
||||
copy.inputs.forEach(function(input, i) {
|
||||
input.script = index === i ? s : [];
|
||||
});
|
||||
@ -427,6 +432,9 @@ TX.prototype.subscriptHash = function subscriptHash(index, s, type) {
|
||||
input.seq = 0;
|
||||
});
|
||||
} else if ((type & 0x1f) === constants.hashType.single) {
|
||||
// bitcoind sighash_single bug:
|
||||
if (index >= copy.outputs.length)
|
||||
return constants.oneHash;
|
||||
while (copy.outputs.length < index + 1)
|
||||
copy.outputs.push({});
|
||||
while (copy.outputs.length > index + 1)
|
||||
@ -434,8 +442,7 @@ TX.prototype.subscriptHash = function subscriptHash(index, s, type) {
|
||||
copy.outputs.forEach(function(output, i) {
|
||||
if (i !== index) {
|
||||
output.script = [];
|
||||
// output.value = new bn('ffffffffffffffff', 'hex');
|
||||
output.value = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff];
|
||||
output.value = utils.toArray('ffffffffffffffff', 'hex');
|
||||
output.value.toArray = function() { return this; };
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user