From 589a5d954873a6853c9eb26c92b0c025905e4584 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Mon, 22 Jan 2018 17:47:18 +0800 Subject: [PATCH] started js for multiple ouputs subaddress --- src/templates/partials/tx_details.html | 40 ++++++++++++++++++++------ 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/templates/partials/tx_details.html b/src/templates/partials/tx_details.html index 4491587..8d1fa88 100644 --- a/src/templates/partials/tx_details.html +++ b/src/templates/partials/tx_details.html @@ -173,9 +173,9 @@ var tx_public_key = $("#tx_pub_key").text(); - var add_tx_pub_keys = $("#add_tx_pub_keys").text().split(';'); + var add_tx_pub_keys = $("#add_tx_pub_keys").text().split(';').slice(0, -1); - console.log("add_tx_pub_keys: " + add_tx_pub_keys); + console.log("add_tx_pub_keys: ", add_tx_pub_keys); var payment_id = $("#payment_id").text(); @@ -192,7 +192,9 @@ try { var address_decoded = decode_address(address); - decodeOutputs(tx_json, tx_public_key, viewkey, address_decoded.spend, payment_id); + decodeOutputs(tx_json, tx_public_key, viewkey, + address_decoded.spend, payment_id, + add_tx_pub_keys); } catch(err){ console.log(err); $("#decode-prove-results").html('

Error:' + err.message + '

' ); @@ -211,7 +213,9 @@ try { var address_decoded = decode_address(address); - decodeOutputs(tx_json, address_decoded.view, tx_prv_key, address_decoded.spend, payment_id); + decodeOutputs(tx_json, address_decoded.view, tx_prv_key, + address_decoded.spend, payment_id, + add_tx_pub_keys); } catch(err){ console.log(err); $("#decode-prove-results").html('

Error:' + err.message + '

' ); @@ -220,7 +224,8 @@ }); - function decodeOutputs(tx_json, pub_key, sec_key, address_pub_key, payment_id) { + function decodeOutputs(tx_json, pub_key, sec_key, + address_pub_key, payment_id, add_tx_pub_keys) { //console.log(tx_json); var is_rct = (tx_json.version === 2); @@ -228,7 +233,16 @@ var key_derivation = generate_key_derivation(pub_key, sec_key); - // console.log(pub_key, address_pub_key, sec_key, key_derivation); + var add_key_derivation = []; + + if (add_tx_pub_keys) { + for (var i = 0; i < add_tx_pub_keys.length; i++) + { + add_key_derivation.push(generate_key_derivation(add_tx_pub_keys[i], sec_key)); + } + } + + console.log("add_key_derivation: ", add_key_derivation); // go over each tx output, and check if it is ours or not @@ -252,7 +266,12 @@ var output_pub_key = output.target.key; var amount = output.amount; - var pubkey_generated = derive_public_key(key_derivation, output_idx, address_pub_key); + var pubkey_generated = (add_tx_pub_keys + ? derive_public_key(add_key_derivation[output_idx], + output_idx, address_pub_key) + : derive_public_key(key_derivation, output_idx, address_pub_key)); + + console.log(pubkey_generated); var mine_output = (output_pub_key == pubkey_generated); @@ -264,7 +283,12 @@ if (is_rct) { try { - var ecdh = decodeRct(tx_json.rct_signatures, output_idx, key_derivation); + //var ecdh = decodeRct(tx_json.rct_signatures, output_idx, key_derivation); + + var ecdh = (add_tx_pub_keys + ? decodeRct(tx_json.rct_signatures, output_idx, add_key_derivation[output_idx]) + : decodeRct(tx_json.rct_signatures, output_idx, key_derivation)); + amount = ecdh.amount; } catch (err) { decoding_results_str += "RingCT amount for output " + i + " with pubkey: " + output_pub_key + "" + "
"; //rct commitment != computed