This commit is contained in:
Mario Colque 2014-05-21 18:03:46 -03:00
commit 3e0c1ad17c
6 changed files with 105 additions and 13 deletions

View file

@ -3,6 +3,7 @@
var imports = require('soop').imports();
var bitcore = require('bitcore');
var bignum = bitcore.Bignum;
var coinUtil = bitcore.util;
var buffertools = bitcore.buffertools;
var Builder = bitcore.TransactionBuilder;
@ -20,7 +21,8 @@ function Wallet(opts) {
'requiredCopayers', 'totalCopayers', 'spendUnconfirmed',
'publicKeyRing', 'txProposals', 'privateKey', 'version'
].forEach(function(k) {
if (typeof opts[k] === 'undefined') throw new Error('missing key:' + k);
if (typeof opts[k] === 'undefined')
throw new Error('missing required option for Wallet: ' + k);
self[k] = opts[k];
});
@ -439,9 +441,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);
@ -572,7 +573,7 @@ Wallet.prototype.createTx = function(toAddress, amountSatStr, opts, cb) {
self.store();
self.emit('txProposalsUpdated');
}
return cb();
return cb(ntxid);
});
};
@ -581,7 +582,7 @@ Wallet.prototype.createTxSync = function(toAddress, amountSatStr, utxos, opts) {
var priv = this.privateKey;
opts = opts || {};
var amountSat = bitcore.bignum(amountSatStr);
var amountSat = bignum(amountSatStr);
if (!pkr.isComplete()) {
throw new Error('publicKeyRing is not complete');

View file

@ -17,6 +17,8 @@ var Wallet = require('./Wallet');
function WalletFactory(config, version) {
var self = this;
config = config || {};
this.storage = new Storage(config.storage);
this.network = new Network(config.network);
this.blockchain = new Blockchain(config.blockchain);
@ -97,7 +99,6 @@ WalletFactory.prototype.create = function(opts) {
opts.privateKey = opts.privateKey || new PrivateKey({ networkName: this.networkName });
var requiredCopayers = opts.requiredCopayers || this.walletDefaults.requiredCopayers;
var totalCopayers = opts.totalCopayers || this.walletDefaults.totalCopayers;
@ -124,7 +125,7 @@ WalletFactory.prototype.create = function(opts) {
opts.spendUnconfirmed = opts.spendUnconfirmed || this.walletDefaults.spendUnconfirmed;
opts.requiredCopayers = requiredCopayers;
opts.totalCopayers = totalCopayers;
opts.version = this.version;
opts.version = opts.version || this.version;
var w = new Wallet(opts);
w.store();
return w;