Skip to content

fix: unblinded re/issuance for non-policy asset greater than 21 million #1445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/confidential_validation.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

#include <chainparams.h>
#include <confidential_validation.h>
#include <issuance.h>
#include <pegins.h>
Expand Down Expand Up @@ -102,7 +103,7 @@ static bool VerifyIssuanceAmount(secp256k1_pedersen_commitment& value_commit, se

// Build value commitment
if (value.IsExplicit()) {
if (!MoneyRange(value.GetAmount()) || value.GetAmount() == 0) {
if ((asset == Params().GetConsensus().pegged_asset && !MoneyRange(value.GetAmount())) || value.GetAmount() <= 0) {
return false;
}
if (!rangeproof.empty()) {
Expand Down
11 changes: 11 additions & 0 deletions test/functional/wallet_elements_21million.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ def run_test(self):
self.generate(self.nodes[0], 1)
assert_equal(self.nodes[0].getbalance()[asset], 200_000_000)

self.log.info("Issue more than 21 million of a unblinded non-policy asset")
issuance = self.nodes[0].issueasset(300_000_000, 100, False)
unblinded_asset = issuance['asset']
self.generate(self.nodes[0], 1)
assert_equal(self.nodes[0].getbalance()[unblinded_asset], 300_000_000)

self.log.info("Reissue more than 21 million of a unblinded non-policy asset")
self.nodes[0].reissueasset(unblinded_asset, 200_000_000)
self.generate(self.nodes[0], 1)
assert_equal(self.nodes[0].getbalance()[unblinded_asset], 500_000_000)

# send more than 21 million of that asset
addr = self.nodes[1].getnewaddress()
self.nodes[0].sendtoaddress(address=addr, amount=22_000_000, assetlabel=asset)
Expand Down