Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

bitcore-lib-cash: Error upon attempt to spend from a 2-of-8 multisig P2SH address #263

Open
ghost opened this issue Oct 6, 2018 · 0 comments

Comments

@ghost
Copy link

ghost commented Oct 6, 2018

I may not spend coins from a 2-of-8 multisig. When I'm trying to do it I get an error "TypeError: "value" argument is out of bounds".

For example:

const privateKeys = [
	new bch.PrivateKey.fromRandom(),
	new bch.PrivateKey.fromRandom(),
	new bch.PrivateKey.fromRandom(),
	new bch.PrivateKey.fromRandom(),
	new bch.PrivateKey.fromRandom(),
	new bch.PrivateKey.fromRandom(),
	new bch.PrivateKey.fromRandom(),
	new bch.PrivateKey.fromRandom(),
];
const publicKeys = privateKeys.map(bch.PublicKey);
const address = new bch.Address(publicKeys, 2); // 2 of 8
const utxo = {
	'txId' : '153068cdd81b73ec9d8dcce27f2c77ddda12dee3db424bff5cafdbe9f01c1756',
	'outputIndex' : 0,
	'address' : address.toString(),
	'script' : new bch.Script(address).toHex(),
	'satoshis' : 20000
};
const transaction = new bch.Transaction()
	.from(utxo, publicKeys, 2)
	.to('mtoKs9V381UAhUia3d7Vb9GNak8Qvmcsme', 20000)
	.sign([privateKeys[0]]);

console.log(transaction.toString())

The result is an error

TypeError: "value" argument is out of bounds
    at checkInt (buffer.js:1185:11)
    at Buffer.writeUInt8 (buffer.js:1233:5)
    at BufferWriter.writeUInt8 (~/server/node_modules/bitcore-lib-cash/lib/encoding/bufferwriter.js:46:7)
    at sighashForForkId (~/server/node_modules/bitcore-lib-cash/lib/transaction/sighash.js:122:10)
    at sighash (~/server/node_modules/bitcore-lib-cash/lib/transaction/sighash.js:183:12)
    at Object.sign (~/server/node_modules/bitcore-lib-cash/lib/transaction/sighash.js:255:17)
    at ~/server/node_modules/bitcore-lib-cash/lib/transaction/input/multisigscripthash.js:118:24
    at arrayEach (~/server/node_modules/bitcore-lib-cash/node_modules/lodash/lodash.js:537:11)
    at Function.forEach (~/server/node_modules/bitcore-lib-cash/node_modules/lodash/lodash.js:9359:14)
    at MultiSigScriptHashInput.getSignatures (~/server/node_modules/bitcore-lib-cash/lib/transaction/input/multisigscripthash.js:111:4)
    at forEachInput (~/server/node_modules/bitcore-lib-cash/lib/transaction/transaction.js:1139:18)
    at arrayEach (~/server/node_modules/bitcore-lib-cash/node_modules/lodash/lodash.js:537:11)
    at Function.forEach (~/server/node_modules/bitcore-lib-cash/node_modules/lodash/lodash.js:9359:14)
    at Transaction.getSignatures (~/server/node_modules/bitcore-lib-cash/lib/transaction/transaction.js:1138:5)
    at Transaction.sign (~/server/node_modules/bitcore-lib-cash/lib/transaction/transaction.js:1125:15)
    at ~/server/node_modules/bitcore-lib-cash/lib/transaction/transaction.js:1121:12
    at arrayEach (~/server/node_modules/bitcore-lib-cash/node_modules/lodash/lodash.js:537:11)
    at Function.forEach (~/server/node_modules/bitcore-lib-cash/node_modules/lodash/lodash.js:9359:14)
    at Transaction.sign (~/server/node_modules/bitcore-lib-cash/lib/transaction/transaction.js:1120:7)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants