fixed swipe script

This commit is contained in:
Ivan Socolsky 2014-12-22 16:59:37 -03:00
commit a58f801714
2 changed files with 4 additions and 3 deletions

View file

@ -1,5 +1,6 @@
'use strict'; 'use strict';
var _ = require('lodash');
var preconditions = require('preconditions').singleton(); var preconditions = require('preconditions').singleton();
var bitcore = require('bitcore'); var bitcore = require('bitcore');

View file

@ -162,7 +162,7 @@ firstWallet.updateIndexes(function() {
amount = amount || balance - fee * bitcore.util.COIN; amount = amount || balance - fee * bitcore.util.COIN;
firstWallet.createTx(destAddr, amount, '', {}, function(err, ntxid) { firstWallet.spend({ toAddress: destAddr, amountSat: amount }, function(err, ntxid) {
if (err || !ntxid) { if (err || !ntxid) {
if (err && err.toString().match('BIG')) { if (err && err.toString().match('BIG')) {
throw new Error('Could not create tx' + err); throw new Error('Could not create tx' + err);
@ -204,13 +204,13 @@ firstWallet.updateIndexes(function() {
if (err) if (err)
throw new Error(err); throw new Error(err);
var p = firstWallet.txProposals.getTxProposal(ntxid); var p = firstWallet.txProposals.get(ntxid);
if (p.builder.isFullySigned()) { if (p.builder.isFullySigned()) {
console.log('\t FULLY SIGNED. BROADCASTING NOW....'); console.log('\t FULLY SIGNED. BROADCASTING NOW....');
var tx = p.builder.build(); var tx = p.builder.build();
var txHex = tx.serialize().toString('hex'); var txHex = tx.serialize().toString('hex');
//console.log('\t RAW TX: ', txHex); //console.log('\t RAW TX: ', txHex);
firstWallet.sendTx(ntxid, function(txid) { firstWallet.broadcastToBitcoinNetwork(ntxid, function(txid) {
console.log('\t ####### SENT TXID:', txid); console.log('\t ####### SENT TXID:', txid);
process.exit(1); process.exit(1);
}); });