Skip to content

Commit

Permalink
Adapt code for new bitcoinjs api.
Browse files Browse the repository at this point in the history
  • Loading branch information
caedesvvv committed Oct 19, 2014
1 parent 441320d commit d8763d9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions js/backend/services/mixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,20 +143,21 @@ function(Port, Channel, Protocol, Bitcoin, CoinJoin, BtcUtils, CryptoJS) {
* Check if all transaction inputs are funded
*/
MixerService.prototype.isTransactionFunded = function(txHex, callback, msg) {
var identity = this.core.getCurrentIdentity();
var self = this;
var client = this.core.getClient();
var addresses = {};
var tx = new Bitcoin.Transaction(txHex);
var tx = Bitcoin.Transaction.fromHex(txHex);
var pending = tx.ins.length;
tx.ins.forEach(function(anIn) {
console.log("[mixer] check tx", anIn.outpoint.hash);
client.fetch_transaction(anIn.outpoint.hash, function(err, txBody) {
var outTx = new Bitcoin.Transaction(txBody);
var address = outTx.outs[anIn.outpoint.index].address.toString();
console.log("[mixer] check tx", anIn.hash.toString('hex'));
client.fetch_transaction(anIn.hash.toString('hex'), function(err, txBody) {
var outTx = Bitcoin.Transaction.fromHex(txBody);
var address = Bitcoin.Address.fromOutputScript(outTx.outs[anIn.index], Bitcoin.networks(identity.wallet.network)).toString();
if (!addresses.hasOwnProperty(address)) {
addresses[address] = [];
}
var index = anIn.outpoint.hash+":"+anIn.outpoint.index;
var index = anIn.hash.toString('hex')+":"+anIn.index;
if (addresses[address].indexOf(index) === -1) {
addresses[address].push(index);
}
Expand Down

0 comments on commit d8763d9

Please sign in to comment.