diff options
| author | reemuru <rimuru@hiahatf.org> | 2022-01-18 16:10:56 -0500 |
|---|---|---|
| committer | reemuru <rimuru@hiahatf.org> | 2022-01-20 20:21:11 -0500 |
| commit | 0f67580e8fc1d98a67298ecc1d70ef926521657a (patch) | |
| tree | 713879567b1f4be71318b66ab66c557dd25680b5 /main.qml | |
| parent | a959919b8ad798d1384f83c5bf3ed7a2d16dc8aa (diff) | |
| download | monzero-gui-0f67580e8fc1d98a67298ecc1d70ef926521657a.tar.gz monzero-gui-0f67580e8fc1d98a67298ecc1d70ef926521657a.tar.xz monzero-gui-0f67580e8fc1d98a67298ecc1d70ef926521657a.zip | |
Advanced: ReserveProof: Add support for reserve proof
This change adds the ability to prove and check a reserve proof
to this existing "Prove/check" advanced menu. If the amount line has
a valid amount less than that of the current account index this input
will drive the logic for generating a reserve proof. Checking a reserve
proof is accomplished by validating the address and verifying that
signature.indexOf("ReserveProofV") === 0. The result displays the total
and spent amount of the proof.
Diffstat (limited to 'main.qml')
| -rw-r--r-- | main.qml | 54 |
1 files changed, 35 insertions, 19 deletions
@@ -985,24 +985,28 @@ ApplicationWindow { } // called on "getProof" - function handleGetProof(txid, address, message) { - console.log("Getting payment proof: ") - console.log("\ttxid: ", txid, - ", address: ", address, - ", message: ", message); - - function spendProofFallback(txid, result){ - if (!result || result.indexOf("error|") === 0) { - currentWallet.getSpendProofAsync(txid, message, txProofComputed); - } else { - txProofComputed(txid, result); + function handleGetProof(txid, address, message, amount) { + if (amount.length > 0) { + var result = currentWallet.getReserveProof(false, currentWallet.currentSubaddressAccount, walletManager.amountFromString(amount), message) + txProofComputed(null, result) + } else { + console.log("Getting payment proof: ") + console.log("\ttxid: ", txid, + ", address: ", address, + ", message: ", message); + function spendProofFallback(txid, result){ + if (!result || result.indexOf("error|") === 0) { + currentWallet.getSpendProofAsync(txid, message, txProofComputed); + } else { + txProofComputed(txid, result); + } } + if (address.length > 0) + currentWallet.getTxProofAsync(txid, address, message, spendProofFallback); + else + spendProofFallback(txid, null); } - - if (address.length > 0) - currentWallet.getTxProofAsync(txid, address, message, spendProofFallback); - else - spendProofFallback(txid, null); + informationPopup.open() } function txProofComputed(txid, result){ @@ -1025,12 +1029,18 @@ ApplicationWindow { ", signature: ", signature); var result; - if (address.length > 0) + var isReserveProof = signature.indexOf("ReserveProofV") === 0; + if (address.length > 0 && !isReserveProof) { result = currentWallet.checkTxProof(txid, address, message, signature); - else + } + else if (isReserveProof) { + result = currentWallet.checkReserveProof(address, message, signature); + } + else { result = currentWallet.checkSpendProof(txid, message, signature); + } var results = result.split("|"); - if (address.length > 0 && results.length == 5 && results[0] === "true") { + if (address.length > 0 && results.length == 5 && results[0] === "true" && !isReserveProof) { var good = results[1] === "true"; var received = results[2]; var in_pool = results[3] === "true"; @@ -1058,6 +1068,12 @@ ApplicationWindow { informationPopup.title = qsTr("Payment proof check") + translationManager.emptyString; informationPopup.icon = good ? StandardIcon.Information : StandardIcon.Critical; informationPopup.text = good ? qsTr("Good signature") : qsTr("Bad signature"); + } + else if (isReserveProof && results[0] === "true") { + var good = results[1] === "true"; + informationPopup.title = qsTr("Reserve proof check") + translationManager.emptyString; + informationPopup.icon = good ? StandardIcon.Information : StandardIcon.Critical; + informationPopup.text = good ? qsTr("Good signature on ") + results[2] + qsTr(" total and ") + results[3] + qsTr(" spent.") : qsTr("Bad signature"); } else { informationPopup.title = qsTr("Error") + translationManager.emptyString; |
