Add full zksnarks tx support
This commit is contained in:
+56
-17
@@ -1082,26 +1082,65 @@ module.exports = {
|
||||
// check if zksnarks is enabled
|
||||
if (settings.blockchain_specific.zksnarks.enabled == true) {
|
||||
// check for hidden/anonymous outputs
|
||||
vhidden.forEach(function(vanon, i) {
|
||||
if (vanon.vpub_old > 0) {
|
||||
module.exports.convert_to_satoshi(parseFloat(vanon.vpub_old), function(amount_sat) {
|
||||
arr_vout.push({addresses: 'hidden_address', amount: amount_sat});
|
||||
});
|
||||
} else {
|
||||
module.exports.convert_to_satoshi(parseFloat(vanon.vpub_new), function(amount_sat) {
|
||||
if (vhidden.length > 0 && (!vout || vout.length == 0) && (!vin || vin.length == 0)) {
|
||||
if (vhidden != null && vhidden.length > 0) {
|
||||
tx_type = "zksnarks";
|
||||
// loop through all hidden/anonymous outputs
|
||||
module.exports.syncLoop(vhidden.length, function (loop) {
|
||||
var i = loop.iteration();
|
||||
|
||||
if (vhidden[i].vpub_old > 0) {
|
||||
// process vout addresses
|
||||
processVoutAddresses(['hidden_address'], parseFloat(vhidden[i].vpub_old), arr_vout, function(vout_array) {
|
||||
// save updated array
|
||||
arr_vout = vout_array;
|
||||
// move to next vout
|
||||
loop.next();
|
||||
});
|
||||
} else {
|
||||
if ((!vout || vout.length == 0) && (!vin || vin.length == 0)) {
|
||||
// hidden sender is sending to hidden recipient
|
||||
// the sent and received values are not known in this case. only the fee paid is known and subtracted from the sender.
|
||||
arr_vout.push({addresses: 'hidden_address', amount: 0});
|
||||
// process vout addresses
|
||||
processVoutAddresses(['hidden_address'], 0, arr_vout, function(vout_array) {
|
||||
// save updated array
|
||||
arr_vout = vout_array;
|
||||
// add a private send address with the known amount sent
|
||||
module.exports.is_unique(arr_vin, 'hidden_address', function(unique, index) {
|
||||
if (unique == true) {
|
||||
module.exports.convert_to_satoshi(parseFloat(vhidden[i].vpub_new), function(amount_sat) {
|
||||
arr_vin.push({addresses: 'hidden_address', amount: amount_sat});
|
||||
// move to next vout
|
||||
loop.next();
|
||||
});
|
||||
} else {
|
||||
module.exports.convert_to_satoshi(parseFloat(vhidden[i].vpub_new), function(amount_sat) {
|
||||
arr_vin[index].amount = arr_vin[index].amount + amount_sat;
|
||||
// move to next vout
|
||||
loop.next();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
module.exports.is_unique(arr_vin, 'hidden_address', function(unique, index) {
|
||||
if (unique == true) {
|
||||
module.exports.convert_to_satoshi(parseFloat(vhidden[i].vpub_new), function(amount_sat) {
|
||||
arr_vin.push({addresses: 'hidden_address', amount: amount_sat});
|
||||
// move to next vout
|
||||
loop.next();
|
||||
});
|
||||
} else {
|
||||
module.exports.convert_to_satoshi(parseFloat(vhidden[i].vpub_new), function(amount_sat) {
|
||||
arr_vin[index].amount = arr_vin[index].amount + amount_sat;
|
||||
// move to next vout
|
||||
loop.next();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// add a private send address with the known amount sent
|
||||
arr_vin.push({addresses: 'hidden_address', amount: amount_sat});
|
||||
});
|
||||
}
|
||||
|
||||
tx_type = "zksnarks";
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof vout[0] !== 'undefined' && vout[0].scriptPubKey.type == 'nonstandard') {
|
||||
|
||||
Reference in New Issue
Block a user