Skip to content
This repository was archived by the owner on Sep 6, 2024. It is now read-only.

Commit a50e4bf

Browse files
author
domschiener
committed
Fixed bug with multisigs
1 parent 478fde5 commit a50e4bf

File tree

5 files changed

+66
-69
lines changed

5 files changed

+66
-69
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "iota.lib.js",
3-
"version": "0.2.5",
3+
"version": "0.2.6",
44
"description": "Javascript Library for IOTA",
55
"main": "./dist/iota.js",
66
"authors": [

examples/multisig.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
var IOTA = require('../lib/iota');
22

33
var iota = new IOTA({
4-
'host': 'http://localhost',
4+
'host': 'http://85.93.93.110',
55
'port': 14265
66
});
77

88
// First co-signer uses index 0 and security level 3
9+
// We initiate the multisig address generation by absorbing the key address digest
910
var digestOne = iota.multisig.getDigest('ABCDFG', 0, 3);
10-
11-
// We initiate the multisig address generation by absorbing the key digest
1211
var initiatedMultisigAddress = iota.multisig.addAddressDigest(digestOne);
1312

1413
// Second cosigner also uses index 0 and security level 3 for the private key
@@ -25,7 +24,7 @@ console.log("MULTISIG ADDRESS: ", address);
2524
// Simple validation if the multisig was created correctly
2625
// Can be called by each cosigner independently
2726
var isValid = iota.multisig.validateAddress(address, [digestOne, digestTwo]);
28-
console.log("IS VALID MULTISIG:", isValid);
27+
console.log("IS VALID MULTISIG ADDRESS:", isValid);
2928

3029
// SIGNING EXAMPLE
3130
//
@@ -38,22 +37,20 @@ iota.multisig.initiateTransfer(6, address, "NZRALDYNVGJWUVLKDWFKJVNYLWQGCWYCURJI
3837

3938
if (e) {
4039
console.log(e);
41-
} else {
42-
40+
}
4341

44-
iota.multisig.addSignature(initiatedBundle, address, iota.multisig.getKey('ABCDFG', 0, 3), function(e,firstSignedBundle) {
42+
iota.multisig.addSignature(initiatedBundle, address, iota.multisig.getKey('ABCDFG', 0, 3), function(e,firstSignedBundle) {
4543

46-
if (e) {
47-
console.log(e);
48-
} else {
44+
if (e) {
45+
console.log(e);
46+
}
4947

50-
iota.multisig.addSignature(firstSignedBundle, address, iota.multisig.getKey('FDSAG', 0, 3), function(e,finalBundle) {
48+
iota.multisig.addSignature(firstSignedBundle, address, iota.multisig.getKey('FDSAG', 0, 3), function(e,finalBundle) {
5149

52-
if (!e) {
53-
console.log("IS VALID SIGNATURE: ", iota.utils.validateSignatures(finalBundle, address));
54-
}
55-
});
50+
if (!e) {
51+
console.log("IS VALID SIGNATURE: ", iota.utils.validateSignatures(finalBundle, address));
5652
}
5753
});
58-
}
54+
});
55+
5956
})

lib/api/api.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
var apiCommands = require('./apiCommands')
22
var errors = require('../errors/inputErrors');
33
var inputValidator = require('../utils/inputValidator');
4-
var Curl = require("../crypto/curl");
54
var Converter = require("../crypto/converter");
65
var Signing = require("../crypto/signing");
76
var Bundle = require("../crypto/bundle");

lib/multisig/multisig.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Multisig.prototype.addAddressDigest = function(digestTrytes, curlStateTrytes) {
5555

5656
// If curlStateTrytes is provided, convert into trits
5757
// else use empty state and initiate the creation of a new address
58-
var curlState = curlStateTrytes ? Converter.trits(curlStateTrytes) : [];
58+
var curlState = curlStateTrytes ? Converter.trits(curlStateTrytes) : null;
5959

6060
var curl = new Curl();
6161

@@ -148,7 +148,7 @@ Multisig.prototype.initiateTransfer = function(securitySum, inputAddress, remain
148148
}
149149

150150
// check if int
151-
if (!inputValidator.isInt(securitySum)) {
151+
if (!inputValidator.isValue(securitySum)) {
152152
return callback(errors.invalidInputs());
153153
}
154154

@@ -244,6 +244,7 @@ Multisig.prototype.initiateTransfer = function(securitySum, inputAddress, remain
244244

245245
self._makeRequest.send(command, function(e, balances) {
246246

247+
if (e) return callback(e);
247248

248249
var totalBalance = parseInt(balances.balances[0]);
249250

package.json

Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,51 @@
11
{
2-
"name": "iota.lib.js",
3-
"version": "0.2.5",
4-
"description": "Javascript Library for IOTA",
5-
"main": "./lib/iota.js",
6-
"scripts": {
7-
"build": "gulp",
8-
"test": "mocha"
9-
},
10-
"author": {
11-
"name": "Dominik Schiener (IOTA Foundation)",
12-
"website": "https://iota.org"
13-
},
14-
"keywords": [
15-
"iota",
16-
"tangle",
17-
"library",
18-
"browser",
19-
"javascript",
20-
"nodejs",
21-
"API"
22-
],
23-
"license": "MIT",
24-
"bugs": {
25-
"url": "https://github.com/iotaledger/iota.lib.js/issues"
26-
},
27-
"repository": {
28-
"type": "git",
29-
"url": "https://github.com/iotaledger/iota.lib.js.git"
30-
},
31-
"dependencies": {
32-
"async": "^2.1.2",
33-
"xmlhttprequest": "^1.8.0"
34-
},
35-
"devDependencies": {
36-
"bower": "^1.8.0",
37-
"browserify": "^14.1.0",
38-
"chai": "^3.5.0",
39-
"del": "^2.2.2",
40-
"gulp": "^3.9.1",
41-
"gulp-jshint": "^2.0.2",
42-
"gulp-nsp": "^2.4.2",
43-
"gulp-rename": "^1.2.2",
44-
"gulp-replace": "^0.5.4",
45-
"gulp-uglify": "^2.1.2",
46-
"jshint": "^2.9.4",
47-
"mocha": "^3.2.0",
48-
"vinyl-buffer": "^1.0.0",
49-
"vinyl-source-stream": "^1.1.0"
50-
}
2+
"name": "iota.lib.js",
3+
"version": "0.2.6",
4+
"description": "Javascript Library for IOTA",
5+
"main": "./lib/iota.js",
6+
"scripts": {
7+
"build": "gulp",
8+
"test": "mocha"
9+
},
10+
"author": {
11+
"name": "Dominik Schiener (IOTA Foundation)",
12+
"website": "https://iota.org"
13+
},
14+
"keywords": [
15+
"iota",
16+
"tangle",
17+
"library",
18+
"browser",
19+
"javascript",
20+
"nodejs",
21+
"API"
22+
],
23+
"license": "MIT",
24+
"bugs": {
25+
"url": "https://github.com/iotaledger/iota.lib.js/issues"
26+
},
27+
"repository": {
28+
"type": "git",
29+
"url": "https://github.com/iotaledger/iota.lib.js.git"
30+
},
31+
"dependencies": {
32+
"async": "^2.1.2",
33+
"xmlhttprequest": "^1.8.0"
34+
},
35+
"devDependencies": {
36+
"bower": "^1.8.0",
37+
"browserify": "^14.1.0",
38+
"chai": "^3.5.0",
39+
"del": "^2.2.2",
40+
"gulp": "^3.9.1",
41+
"gulp-jshint": "^2.0.2",
42+
"gulp-nsp": "^2.4.2",
43+
"gulp-rename": "^1.2.2",
44+
"gulp-replace": "^0.5.4",
45+
"gulp-uglify": "^2.1.2",
46+
"jshint": "^2.9.4",
47+
"mocha": "^3.2.0",
48+
"vinyl-buffer": "^1.0.0",
49+
"vinyl-source-stream": "^1.1.0"
50+
}
5151
}

0 commit comments

Comments
 (0)