Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

prevent crash if ccurl is not supported #515

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions app/js/ccurl-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@ var ccurlInterruptAndFinalize = function(libccurl) {
}

var ccurlHashing = function(libccurl, trunkTransaction, branchTransaction, minWeightMagnitude, trytes, callback) {
if (!libccurl.hasOwnProperty("ccurl_pow")) {
return callback(new Error("Hashing not available"));
var ccurlPoW = connection.ccurl

if (!libccurl || !libccurl.hasOwnProperty("ccurl_pow")) {
ccurlPoW = 0
}

var iotaObj = iota;
Expand Down Expand Up @@ -165,7 +167,7 @@ var ccurlHashing = function(libccurl, trunkTransaction, branchTransaction, minWe

var newTrytes = iotaObj.utils.transactionTrytes(txObject);

switch (connection.ccurl) {
switch (ccurlPoW) {
case 0: {
libcurl.pow({trytes: newTrytes, minWeight: minWeightMagnitude}).then(function(nonce) {
var returnedTrytes = newTrytes.substr(0, 2673-81).concat(nonce);
Expand Down
13 changes: 8 additions & 5 deletions ui/js/ui.init.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,15 @@ var UI = (function(UI, $, undefined) {
console.log("...");
}
showLightWalletErrorMessage();
return;
connection.ccurlProvider = null
} else {
connection.ccurlProvider = ccurl.ccurlProvider(connection.ccurlPath);
if (!connection.ccurlProvider) {
console.log("Did not get ccurlProvider from " + connection.ccurlPath);
return;
try {
connection.ccurlProvider = ccurl.ccurlProvider(connection.ccurlPath);
if (!connection.ccurlProvider) {
console.log("Did not get ccurlProvider from " + connection.ccurlPath);
}
} catch (err) {
connection.ccurlProvider = null
}
}
// Overwrite iota lib with light wallet functionality
Expand Down