sorting of key images, sources and context added in JS

https://github.com/moneroexamples/openmonero/issues/63

Seems to solve this issue.
pull/74/head
moneroexamples 6 years ago
parent ae88a75b3f
commit 7487e9e7b5

@ -1645,6 +1645,17 @@ var cnUtil = (function(initConfig) {
return sigs;
};
// reargances array to specific indices.
this.rearrange = function(arr, ind) {
var new_arr = [];
for (j = 0; j < ind.length; j++) {
new_arr.push(arr[ind[j]]);
}
return new_arr;
};
this.construct_tx = function(keys, sources, dsts, fee_amount, payment_id, pid_encrypt, realDestViewKey, unlock_time, rct) {
//we move payment ID stuff here, because we need txkey to encrypt
var txkey = this.random_keypair();
@ -1732,6 +1743,35 @@ var cnUtil = (function(initConfig) {
input_to_key.key_offsets = this.abs_to_rel_offsets(input_to_key.key_offsets);
tx.vin.push(input_to_key);
}
// new to sort key_imags and associated variables.
var ins_order = [];
for (var i = 0; i < tx.vin.length; i++){
ins_order.push(i);
}
// determine indexes whish we shuld sort.
ins_order.sort(function(i0, i1) {
if (tx.vin[i0].k_image < tx.vin[i1].k_image) {
return 1;
}
if (tx.vin[i0].k_image > tx.vin[i1].k_image) {
return -1;
}
return 0;
});
// sort key images along with rources and contexts.
tx.vin = rearrange(tx.vin , ins_order);
sources = rearrange(sources, ins_order);
in_contexts = rearrange(in_contexts, ins_order);
var outputs_money = JSBigInt.ZERO;
var out_index = 0;
var amountKeys = []; //rct only

@ -1,7 +1,7 @@
var config = {
apiUrl: "http://127.0.0.1:1984/",
mainnetExplorerUrl: "https://moneroexplorer.com/",
testnetExplorerUrl: "http://139.162.32.245:8082/",
mainnetExplorerUrl: "https://xmrchain.com/",
testnetExplorerUrl: "https://testnet.xmrchain.com/",
testnet: true,
coinUnitPlaces: 12,
txMinConfirms: 10, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Monero

Loading…
Cancel
Save