diff --git a/src/templates/partials/tx_details.html b/src/templates/partials/tx_details.html index 8d1fa88..bb723c6 100644 --- a/src/templates/partials/tx_details.html +++ b/src/templates/partials/tx_details.html @@ -211,11 +211,17 @@ return; } + // when using subaddress, there can be more than one tx_prv_key + var multiple_tx_prv_keys = parse_str_secret_key(tx_prv_key); + + console.log("multiple_tx_prv_keys: ", multiple_tx_prv_keys); + + try { var address_decoded = decode_address(address); decodeOutputs(tx_json, address_decoded.view, tx_prv_key, address_decoded.spend, payment_id, - add_tx_pub_keys); + multiple_tx_prv_keys); } catch(err){ console.log(err); $("#decode-prove-results").html('

Error:' + err.message + '

' ); @@ -224,6 +230,25 @@ }); + // based on C++ by stoffu + function parse_str_secret_key(key_str) { + + var multiple_tx_secret_keys = []; + + var num_keys = Math.floor(key_str.length / 64); + + if (num_keys * 64 != key_str.length) + throw "num_keys * 64 != key_str.length for " + num_keys + " and " + key_str; + + for (var i = 0; i < num_keys; i++) + { + multiple_tx_secret_keys.push(key_str.slice(64*i, 64*i + 64)); + } + + return multiple_tx_secret_keys; + } + + function decodeOutputs(tx_json, pub_key, sec_key, address_pub_key, payment_id, add_tx_pub_keys) { //console.log(tx_json); diff --git a/src/tools.h b/src/tools.h index 32d2236..9dfe838 100644 --- a/src/tools.h +++ b/src/tools.h @@ -77,14 +77,18 @@ bool parse_str_secret_key(const string& key_str, std::vector& secret_keys) { const size_t num_keys = key_str.size() / 64; + if (num_keys * 64 != key_str.size()) return false; + secret_keys.resize(num_keys); + for (size_t i = 0; i < num_keys; ++i) { if (!parse_str_secret_key(key_str.substr(64*i, 64), secret_keys[i])) return false; } + return true; }