mirror of https://github.com/BTCPrivate/copay.git
finish m_n script
This commit is contained in:
parent
73e7d2a827
commit
89cdfb3f7c
|
@ -96,7 +96,7 @@ angular.module('copay.send').controller('SendController',
|
||||||
//alert(JSON.stringify(qrcode.process(context)));
|
//alert(JSON.stringify(qrcode.process(context)));
|
||||||
qrcode.decode();
|
qrcode.decode();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
alert(e);
|
console.log('error decoding QR: '+e);
|
||||||
}
|
}
|
||||||
}, 1500);
|
}, 1500);
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
var imports = require('soop').imports();
|
var imports = require('soop').imports();
|
||||||
|
|
||||||
var bitcore = require('bitcore');
|
var bitcore = require('bitcore');
|
||||||
|
var bignum = bitcore.Bignum;
|
||||||
var coinUtil = bitcore.util;
|
var coinUtil = bitcore.util;
|
||||||
var buffertools = bitcore.buffertools;
|
var buffertools = bitcore.buffertools;
|
||||||
var Builder = bitcore.TransactionBuilder;
|
var Builder = bitcore.TransactionBuilder;
|
||||||
|
@ -571,7 +572,7 @@ Wallet.prototype.createTxSync = function(toAddress, amountSatStr, utxos, opts) {
|
||||||
var priv = this.privateKey;
|
var priv = this.privateKey;
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
var amountSat = bitcore.bignum(amountSatStr);
|
var amountSat = bignum(amountSatStr);
|
||||||
|
|
||||||
if (!pkr.isComplete()) {
|
if (!pkr.isComplete()) {
|
||||||
throw new Error('publicKeyRing is not complete');
|
throw new Error('publicKeyRing is not complete');
|
||||||
|
|
|
@ -19,10 +19,11 @@ var WalletFactory = require('soop').load('../js/models/core/WalletFactory', {
|
||||||
var Key = bitcore.Key;
|
var Key = bitcore.Key;
|
||||||
|
|
||||||
|
|
||||||
var N_LIMIT = 16;
|
var N_LIMIT = 20;
|
||||||
var nn = 'livenet';
|
var nn = 'livenet';
|
||||||
|
|
||||||
for (var n = 1; n < N_LIMIT; n++) {
|
for (var n = 1; n <= N_LIMIT; n++) {
|
||||||
|
var end = false;
|
||||||
for (var m = 1; m <= n; m++) {
|
for (var m = 1; m <= n; m++) {
|
||||||
// case m-of-n
|
// case m-of-n
|
||||||
console.log('case ' + m + '-of-' + n);
|
console.log('case ' + m + '-of-' + n);
|
||||||
|
@ -64,28 +65,26 @@ for (var n = 1; n < N_LIMIT; n++) {
|
||||||
// create fake utxo
|
// create fake utxo
|
||||||
var utxos = [{
|
var utxos = [{
|
||||||
'address': addr,
|
'address': addr,
|
||||||
'txid': '659e4e6d9c840e57aee6ebe35f2511cdeb848d786938f0b6b4f1b00de09b29da',
|
'txid': '82a974b72d3135152043989652e687e2966c651ba4822274926221017ea072d2',
|
||||||
'vout': 1,
|
'vout': 1,
|
||||||
'ts': 1400682132,
|
'ts': 1400696213,
|
||||||
'scriptPubKey': 'a914e4a6744eeed5571cff9e427cbb5dd5e1a2d1b2fa87',
|
'scriptPubKey': 'a914b2562c950498ff48ad3479ca1c2dfda2b0273e2287',
|
||||||
'amount': 10.000,
|
'amount': 10.0,
|
||||||
'confirmations': 100
|
'confirmations': 2
|
||||||
}];
|
}];
|
||||||
var ntxid = w.createTxSync(toAddress, amount, utxos);
|
var ntxid = w.createTxSync(toAddress, amount, utxos);
|
||||||
console.log('\t ntxid =' + ntxid);
|
console.log('\t ntxid =' + ntxid);
|
||||||
var sign = function(pk, cb) {
|
|
||||||
w.sign(ntxid, cb);
|
|
||||||
}
|
|
||||||
async.each(pks, sign, function(err) {
|
|
||||||
if (err) {
|
|
||||||
throw new Error(err);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
var txp = w.txProposals.txps[ntxid];
|
var txp = w.txProposals.txps[ntxid];
|
||||||
var tx = txp.builder.build();
|
var tx = txp.builder.build();
|
||||||
console.log(tx.isComplete());
|
|
||||||
var scriptSig = tx.ins[0].getScript();
|
var scriptSig = tx.ins[0].getScript();
|
||||||
console.log(scriptSig.toHumanReadable());
|
var size = scriptSig.serialize().length;
|
||||||
console.log(scriptSig.serialize().length);
|
console.log('\t scriptSig size: '+size);
|
||||||
|
if (size > 500) {
|
||||||
|
if (m === 1) {
|
||||||
|
end = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (end) break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue