Permalink
Browse files

Bugfix and make jshint happy

  • Loading branch information...
th0br0 committed Oct 20, 2017
1 parent 5311af9 commit 3e3adf60b337f8e39d84bb1b3b5ee365af288965
Showing with 19 additions and 0 deletions.
  1. +5 −0 .jshintrc
  2. +14 −0 lib/crypto/bundle/bundle.js
View
@@ -0,0 +1,5 @@
{
"esnext": false,
"esversion": 5,
"asi": true
}
@@ -1,6 +1,7 @@
var Curl = require("../curl/curl");
var Kerl = require("../kerl/kerl");
var Converter = require("../converter/converter");
var tritAdd = require("../helpers/adder");
/**
*
@@ -74,6 +75,9 @@ Bundle.prototype.addTrytes = function(signatureFragments) {
*
**/
Bundle.prototype.finalize = function() {
var validBundle = false;
while(!validBundle) {
var kerl = new Kerl();
kerl.initialize();
@@ -112,6 +116,16 @@ Bundle.prototype.finalize = function() {
this.bundle[i].bundle = hash;
}
var normalizedHash = this.normalizedBundle(hash);
if(normalizedHash.indexOf(13 /* = M */) != -1) {
// Insecure bundle. Increment Tag and recompute bundle hash.
var increasedTag = tritAdd(Converter.trits(this.bundle[0].obsoleteTag), [1]);
this.bundle[0].obsoleteTag = Converter.trytes(increasedTag);
} else {
validBundle = true;
}
}
}
/**

0 comments on commit 3e3adf6

Please sign in to comment.