From 59a4007b334f5a0e6808b50d86435ee4d2064aab Mon Sep 17 00:00:00 2001 From: celbalrai <80897309+celbalrai@users.noreply.github.com> Date: Thu, 17 Jun 2021 14:17:18 +0200 Subject: [PATCH] Bump NFT token data size to 96k --- src/consensus/consensus.h | 4 +++- src/consensus/tx_verify.cpp | 10 ++++++++-- src/tokens/rpctokenwallet.cpp | 7 +++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/consensus/consensus.h b/src/consensus/consensus.h index 214d4cf77ba636..271655e892fcee 100644 --- a/src/consensus/consensus.h +++ b/src/consensus/consensus.h @@ -20,8 +20,10 @@ inline unsigned int MaxBlockSigOps(bool fDIP0001Active = true) } /** The maximum allowed size of version 3 extra payload */ static const unsigned int MAX_TX_EXTRA_PAYLOAD = 10000; +/** The maximum allowed size of version 3 NFT extra payload */ +static const unsigned int MAX_TX_EXTRA_NFT_PAYLOAD = 99616; /** The maximum size of NFT token data */ -static const unsigned int MAX_TX_NFT_DATA = 8000; +static const unsigned int MAX_TX_NFT_DATA = 98300; /** Flags for nSequence and nLockTime locks */ /** Interpret sequence numbers as relative lock-time constraints. */ diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp index 4d7d4953d52813..cac339f1cf6e52 100644 --- a/src/consensus/tx_verify.cpp +++ b/src/consensus/tx_verify.cpp @@ -167,8 +167,14 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, const boo // Size limits if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) > MAX_LEGACY_BLOCK_SIZE) return state.DoS(100, false, REJECT_INVALID, "bad-txns-oversize"); - if (tx.vExtraPayload.size() > MAX_TX_EXTRA_PAYLOAD) - return state.DoS(100, false, REJECT_INVALID, "bad-txns-payload-oversize"); + // Different size for NFT + if (tx.nType == TRANSACTION_GROUP_CREATION_NFT) { + if (tx.vExtraPayload.size() > MAX_TX_EXTRA_NFT_PAYLOAD) + return state.DoS(100, false, REJECT_INVALID, "bad-txns-nft-payload-oversize"); + } else { + if (tx.vExtraPayload.size() > MAX_TX_EXTRA_PAYLOAD) + return state.DoS(100, false, REJECT_INVALID, "bad-txns-payload-oversize"); + } // Check for negative or overflow output values CAmount nValueOut = 0; diff --git a/src/tokens/rpctokenwallet.cpp b/src/tokens/rpctokenwallet.cpp index f764fb876fe0ba..dbce05bca38a6e 100644 --- a/src/tokens/rpctokenwallet.cpp +++ b/src/tokens/rpctokenwallet.cpp @@ -106,6 +106,13 @@ static unsigned int ParseGroupAddrValue(const JSONRPCRequest& request, outputs.push_back(recipient); curparam += 2; } + // If NFT then check if totalValue < desc.maxmint + if (tgCreation.creationTransaction->nType == TRANSACTION_GROUP_CREATION_NFT) { + CTokenGroupDescriptionNFT *tgDesc = boost::get(tgCreation.pTokenGroupDescription.get()); + if (totalValue != tgDesc->nMintAmount) { + throw JSONRPCError(RPC_TYPE_ERROR, strprintf("NFT mints the wrong amount (%d instead of %d)", totalValue, tgDesc->nMintAmount)); + } + } return curparam; }