mirror of https://github.com/BTCPrivate/copay.git
advancing with m-n script
This commit is contained in:
parent
c8ebf0ce65
commit
73e7d2a827
|
@ -440,9 +440,8 @@ Wallet.prototype.sendTx = function(ntxid, cb) {
|
|||
this.log('[Wallet.js.261:txHex:]', txHex); //TODO
|
||||
|
||||
var self = this;
|
||||
|
||||
this.blockchain.sendRawTransaction(txHex, function(txid) {
|
||||
self.log('BITCOND txid:', txid); //TODO
|
||||
self.log('BITCOIND txid:', txid); //TODO
|
||||
if (txid) {
|
||||
self.txProposals.setSent(ntxid, txid);
|
||||
self.sendTxProposals(null, ntxid);
|
||||
|
@ -545,8 +544,6 @@ Wallet.prototype.getUnspent = function(cb) {
|
|||
|
||||
Wallet.prototype.createTx = function(toAddress, amountSatStr, opts, cb) {
|
||||
var self = this;
|
||||
alert(amountSatStr);
|
||||
alert(JSON.stringify(opts));
|
||||
if (typeof opts === 'function') {
|
||||
cb = opts;
|
||||
opts = {};
|
||||
|
@ -565,7 +562,7 @@ Wallet.prototype.createTx = function(toAddress, amountSatStr, opts, cb) {
|
|||
self.store();
|
||||
self.emit('txProposalsUpdated');
|
||||
}
|
||||
return cb();
|
||||
return cb(ntxid);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
"bitcore": "git://github.com/bitpay/bitcore.git",
|
||||
"chai": "~1.9.1",
|
||||
"sinon": "~1.9.1",
|
||||
"node-cryptojs-aes": "=0.4.0"
|
||||
"node-cryptojs-aes": "=0.4.0",
|
||||
"async": "~0.9.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
var async = require('async');
|
||||
var bitcore = require('bitcore');
|
||||
var PublicKeyRing = require('../js/models/core/PublicKeyRing');
|
||||
var PrivateKey = require('../js/models/core/PrivateKey');
|
||||
|
@ -24,7 +25,7 @@ var nn = 'livenet';
|
|||
for (var n = 1; n < N_LIMIT; n++) {
|
||||
for (var m = 1; m <= n; m++) {
|
||||
// case m-of-n
|
||||
console.log('case '+m+'-of-'+n);
|
||||
console.log('case ' + m + '-of-' + n);
|
||||
// create full pkr
|
||||
var publicKeyRing = new PublicKeyRing({
|
||||
networkName: nn,
|
||||
|
@ -32,6 +33,7 @@ for (var n = 1; n < N_LIMIT; n++) {
|
|||
totalCopayers: n,
|
||||
});
|
||||
var privateKey = null;
|
||||
var pks = [];
|
||||
for (var i = 0; i < n; i++) {
|
||||
var pk = new PrivateKey({
|
||||
networkName: nn
|
||||
|
@ -41,6 +43,7 @@ for (var n = 1; n < N_LIMIT; n++) {
|
|||
} else {
|
||||
publicKeyRing.addCopayer(pk.getExtendedPublicKeyString(), 'dummy');
|
||||
}
|
||||
pks.push(pk);
|
||||
}
|
||||
|
||||
var opts = {};
|
||||
|
@ -53,13 +56,36 @@ for (var n = 1; n < N_LIMIT; n++) {
|
|||
|
||||
var w = new WalletFactory(opts).create(opts);
|
||||
var addr = w.generateAddress();
|
||||
console.log('\t receive addr='+addr);
|
||||
console.log('\t receive addr=' + addr);
|
||||
|
||||
|
||||
var toAddress = 'msj42CCGruhRsFrGATiUuh25dtxYtnpbTx';
|
||||
var amount = '5000000';
|
||||
|
||||
|
||||
|
||||
// create fake utxo
|
||||
var utxos = [{
|
||||
'address': addr,
|
||||
'txid': '659e4e6d9c840e57aee6ebe35f2511cdeb848d786938f0b6b4f1b00de09b29da',
|
||||
'vout': 1,
|
||||
'ts': 1400682132,
|
||||
'scriptPubKey': 'a914e4a6744eeed5571cff9e427cbb5dd5e1a2d1b2fa87',
|
||||
'amount': 10.000,
|
||||
'confirmations': 100
|
||||
}];
|
||||
var ntxid = w.createTxSync(toAddress, amount, utxos);
|
||||
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 tx = txp.builder.build();
|
||||
console.log(tx.isComplete());
|
||||
var scriptSig = tx.ins[0].getScript();
|
||||
console.log(scriptSig.toHumanReadable());
|
||||
console.log(scriptSig.serialize().length);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue