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
|
this.log('[Wallet.js.261:txHex:]', txHex); //TODO
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
this.blockchain.sendRawTransaction(txHex, function(txid) {
|
this.blockchain.sendRawTransaction(txHex, function(txid) {
|
||||||
self.log('BITCOND txid:', txid); //TODO
|
self.log('BITCOIND txid:', txid); //TODO
|
||||||
if (txid) {
|
if (txid) {
|
||||||
self.txProposals.setSent(ntxid, txid);
|
self.txProposals.setSent(ntxid, txid);
|
||||||
self.sendTxProposals(null, ntxid);
|
self.sendTxProposals(null, ntxid);
|
||||||
|
@ -545,8 +544,6 @@ Wallet.prototype.getUnspent = function(cb) {
|
||||||
|
|
||||||
Wallet.prototype.createTx = function(toAddress, amountSatStr, opts, cb) {
|
Wallet.prototype.createTx = function(toAddress, amountSatStr, opts, cb) {
|
||||||
var self = this;
|
var self = this;
|
||||||
alert(amountSatStr);
|
|
||||||
alert(JSON.stringify(opts));
|
|
||||||
if (typeof opts === 'function') {
|
if (typeof opts === 'function') {
|
||||||
cb = opts;
|
cb = opts;
|
||||||
opts = {};
|
opts = {};
|
||||||
|
@ -565,7 +562,7 @@ Wallet.prototype.createTx = function(toAddress, amountSatStr, opts, cb) {
|
||||||
self.store();
|
self.store();
|
||||||
self.emit('txProposalsUpdated');
|
self.emit('txProposalsUpdated');
|
||||||
}
|
}
|
||||||
return cb();
|
return cb(ntxid);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
"bitcore": "git://github.com/bitpay/bitcore.git",
|
"bitcore": "git://github.com/bitpay/bitcore.git",
|
||||||
"chai": "~1.9.1",
|
"chai": "~1.9.1",
|
||||||
"sinon": "~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';
|
'use strict';
|
||||||
|
|
||||||
|
var async = require('async');
|
||||||
var bitcore = require('bitcore');
|
var bitcore = require('bitcore');
|
||||||
var PublicKeyRing = require('../js/models/core/PublicKeyRing');
|
var PublicKeyRing = require('../js/models/core/PublicKeyRing');
|
||||||
var PrivateKey = require('../js/models/core/PrivateKey');
|
var PrivateKey = require('../js/models/core/PrivateKey');
|
||||||
|
@ -32,6 +33,7 @@ for (var n = 1; n < N_LIMIT; n++) {
|
||||||
totalCopayers: n,
|
totalCopayers: n,
|
||||||
});
|
});
|
||||||
var privateKey = null;
|
var privateKey = null;
|
||||||
|
var pks = [];
|
||||||
for (var i = 0; i < n; i++) {
|
for (var i = 0; i < n; i++) {
|
||||||
var pk = new PrivateKey({
|
var pk = new PrivateKey({
|
||||||
networkName: nn
|
networkName: nn
|
||||||
|
@ -41,6 +43,7 @@ for (var n = 1; n < N_LIMIT; n++) {
|
||||||
} else {
|
} else {
|
||||||
publicKeyRing.addCopayer(pk.getExtendedPublicKeyString(), 'dummy');
|
publicKeyRing.addCopayer(pk.getExtendedPublicKeyString(), 'dummy');
|
||||||
}
|
}
|
||||||
|
pks.push(pk);
|
||||||
}
|
}
|
||||||
|
|
||||||
var opts = {};
|
var opts = {};
|
||||||
|
@ -58,8 +61,31 @@ for (var n = 1; n < N_LIMIT; n++) {
|
||||||
|
|
||||||
var toAddress = 'msj42CCGruhRsFrGATiUuh25dtxYtnpbTx';
|
var toAddress = 'msj42CCGruhRsFrGATiUuh25dtxYtnpbTx';
|
||||||
var amount = '5000000';
|
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