Skip to content

Commit

Permalink
Fixed bug related to isReattachable
Browse files Browse the repository at this point in the history
  • Loading branch information
domschiener committed Jul 20, 2017
1 parent f9fc823 commit 45d5214
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iota.lib.js",
"version": "0.3.7",
"version": "0.3.8",
"description": "Javascript Library for IOTA",
"main": "./dist/iota.js",
"authors": [
Expand Down
20 changes: 15 additions & 5 deletions dist/iota.js
Original file line number Diff line number Diff line change
Expand Up @@ -1806,17 +1806,27 @@ api.prototype.isReattachable = function(inputAddresses, callback) {
var results = addresses.map(function(address) {

var txs = addressTxsMap[address];
var numTxs = txs.length;

if (txs.length === 0) {
if (numTxs === 0) {
return true;
}

var shouldReattach = true;
txs.forEach(function(tx) {

for (var i = 0; i < numTxs; i++) {

var tx = txs[i];

var txIndex = valueTransactions.indexOf(tx);
shouldReattach = inclusionStates[txIndex] ? false : true;
})
var isConfirmed = inclusionStates[txIndex];
shouldReattach = isConfirmed ? false : true;

// if tx confirmed, break
if (isConfirmed)
break;
}


return shouldReattach;

Expand Down Expand Up @@ -17933,7 +17943,7 @@ function extend() {
},{}],57:[function(require,module,exports){
module.exports={
"name": "iota.lib.js",
"version": "0.3.7",
"version": "0.3.8",
"description": "Javascript Library for IOTA",
"main": "./lib/iota.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion dist/iota.min.js

Large diffs are not rendered by default.

18 changes: 14 additions & 4 deletions lib/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1801,17 +1801,27 @@ api.prototype.isReattachable = function(inputAddresses, callback) {
var results = addresses.map(function(address) {

var txs = addressTxsMap[address];
var numTxs = txs.length;

if (txs.length === 0) {
if (numTxs === 0) {
return true;
}

var shouldReattach = true;
txs.forEach(function(tx) {

for (var i = 0; i < numTxs; i++) {

var tx = txs[i];

var txIndex = valueTransactions.indexOf(tx);
shouldReattach = inclusionStates[txIndex] ? false : true;
})
var isConfirmed = inclusionStates[txIndex];
shouldReattach = isConfirmed ? false : true;

// if tx confirmed, break
if (isConfirmed)
break;
}


return shouldReattach;

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iota.lib.js",
"version": "0.3.7",
"version": "0.3.8",
"description": "Javascript Library for IOTA",
"main": "./lib/iota.js",
"scripts": {
Expand Down

0 comments on commit 45d5214

Please sign in to comment.