add quorum check and confimation

This commit is contained in:
Matias Alejo Garcia 2014-10-30 11:24:34 -03:00
parent b402a5a105
commit c427d59cfd
1 changed files with 29 additions and 20 deletions

View File

@ -108,29 +108,38 @@ firstWallet.updateIndexes(function() {
console.log('\n\n\n\n### TOTAL BALANCE: %d SATOSHIS', balance); //TODO console.log('\n\n\n\n### TOTAL BALANCE: %d SATOSHIS', balance); //TODO
console.log('Balance per address:', balanceByAddr); //TODO console.log('Balance per address:', balanceByAddr); //TODO
// rl.question("Should we swipe the wallet? (`yes` to continue)", function(answer) { if (!balance) {
// }); console.log('Could not find any balance from the generated wallet'); //TODO
process.exit(1);
}
var amount = balance - DFLT_FEE; rl.question("Should we swipe the wallet? (`yes` to continue)", function(answer) {
firstWallet.createTx(destAddr, amount, '', {}, function(err, ntxid) { if (answer!== 'yes')
console.log('\n\t### Tx Proposal Created... With copayer 0 signature.'); process.exit(1);
var l = w.length; var amount = balance - DFLT_FEE;
_.each(w, function(dummy,i){ firstWallet.createTx(destAddr, amount, '', {}, function(err, ntxid) {
console.log('\t Signing with copayer', i + 1); console.log('\n\t### Tx Proposal Created... With copayer 0 signature.');
w[i].txProposals=firstWallet.txProposals;
w[i].sign(ntxid, function(err){ var l = w.length;
console.log('\t Signed!'); _.each(w, function(dummy, i) {
firstWallet.txProposals = firstWallet.txProposals; console.log('\t Signing with copayer', i + 1);
if (i == l - 1){ w[i].txProposals = firstWallet.txProposals;
console.log('\t ALL SIGNED'); w[i].sign(ntxid, function(err) {
firstWallet.sendTx(ntxid,function(txid){ console.log('\t Signed!');
console.log('\t ####### SENT TXID:', txid); firstWallet.txProposals = firstWallet.txProposals;
process.exit(1);
}); var p = firstWallet.txProposals.getTxProposal(ntxid);
} if (p.builder.isFullySigned()) {
console.log('\t FULLY SIGNED. BROADCASTING NOW....');
firstWallet.sendTx(ntxid, function(txid) {
console.log('\t ####### SENT TXID:', txid);
process.exit(1);
});
}
})
}) })
}) });
}); });
}); });
}); });