Add full zksnarks tx support
This commit is contained in:
@@ -190,7 +190,7 @@ Table of Contents
|
||||
- **getsupply:** Returns the current money supply
|
||||
- **getnextrewardestimate:** Returns an estimate for the next block reward based on the current state of decentralized voting
|
||||
- **getnextrewardwhenstr:** Returns a string describing how long until the votes are tallied and the next block reward is computed
|
||||
- Partial Zcash/zk-SNARKs private tx support (90% complete)
|
||||
- Zcash/zk-SNARKs private tx support
|
||||
|
||||
### See it in Action
|
||||
|
||||
|
||||
+50
-11
@@ -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});
|
||||
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 {
|
||||
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 ((!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();
|
||||
});
|
||||
}
|
||||
|
||||
tx_type = "zksnarks";
|
||||
});
|
||||
});
|
||||
} 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();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof vout[0] !== 'undefined' && vout[0].scriptPubKey.type == 'nonstandard') {
|
||||
|
||||
@@ -960,9 +960,6 @@ exports.blockchain_specific = {
|
||||
}
|
||||
},
|
||||
// zksnarks: A collection of settings that pertain to Zcash zk-SNARKs private transactions
|
||||
// NOTE: This is only partial zk-SNARKs private tx support (90% complete)
|
||||
// While the current implementation should be stable, it does not yet work in 100% of the transaction scenarios
|
||||
// USE THIS FEATURE AT YOUR OWN RISK. FOR TESTING PURPOSES ONLY!
|
||||
"zksnarks": {
|
||||
// enabled: Enable/disable Zcash zk-SNARKs private transaction support (true/false)
|
||||
// If set to false, zk-SNARKs private txs will not be properly read or saved by the explorer
|
||||
|
||||
@@ -1077,9 +1077,6 @@
|
||||
}
|
||||
},
|
||||
// zksnarks: A collection of settings that pertain to Zcash zk-SNARKs private transactions
|
||||
// NOTE: This is only partial zk-SNARKs private tx support (90% complete)
|
||||
// While the current implementation should be stable, it does not yet work in 100% of the transaction scenarios
|
||||
// USE THIS FEATURE AT YOUR OWN RISK. FOR TESTING PURPOSES ONLY!
|
||||
"zksnarks": {
|
||||
// enabled: Enable/disable Zcash zk-SNARKs private transaction support (true/false)
|
||||
// If set to false, zk-SNARKs private txs will not be properly read or saved by the explorer
|
||||
|
||||
Reference in New Issue
Block a user