mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
CT: CTxOutValue::IsAmount() -> CTxOutValue::IsExplicit()
This commit is contained in:
parent
e2077844f6
commit
96221efaab
16 changed files with 51 additions and 51 deletions
|
|
@ -335,7 +335,7 @@ static void MutateTxBlind(CMutableTransaction& tx, const string& strInput)
|
|||
}
|
||||
}
|
||||
for (size_t nOut = 0; nOut < tx.vout.size(); nOut++) {
|
||||
if (!tx.vout[nOut].nValue.IsAmount())
|
||||
if (!tx.vout[nOut].nValue.IsExplicit())
|
||||
throw runtime_error("Invalid parameter: transaction outputs must be unblinded");
|
||||
if (tx.vout[nOut].nValue.vchNonceCommitment.size() == 0) {
|
||||
output_pubkeys.push_back(CPubKey());
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ bool UnblindOutput(const CKey &key, const CTxOut& txout, CAmount& amount_out, ui
|
|||
size_t msg_size = 64;
|
||||
uint64_t min_value, max_value, amount;
|
||||
secp256k1_pedersen_commitment commit;
|
||||
if (!txout.nAsset.IsCommitment() || txout.nValue.IsAmount())
|
||||
if (!txout.nAsset.IsCommitment() || txout.nValue.IsExplicit())
|
||||
return false;
|
||||
|
||||
secp256k1_generator gen;
|
||||
|
|
@ -124,8 +124,8 @@ int BlindOutputs(std::vector<uint256 >& input_blinding_factors, const std::vecto
|
|||
for (size_t nOut = 0; nOut < tx.vout.size(); nOut++) {
|
||||
CTxOut& out = tx.vout[nOut];
|
||||
// Wallet only understands all-blinded or all-unblinded
|
||||
assert((output_blinding_factors[nOut] != uint256()) == !out.nValue.IsAmount());
|
||||
assert(out.nValue.IsAmount() == out.nAsset.IsExplicit() || out.nValue.IsAmount() == out.nAsset.IsAssetGeneration());
|
||||
assert((output_blinding_factors[nOut] != uint256()) == !out.nValue.IsExplicit());
|
||||
assert(out.nValue.IsExplicit() == out.nAsset.IsExplicit() || out.nValue.IsExplicit() == out.nAsset.IsAssetGeneration());
|
||||
assert(out.nAsset.IsCommitment() == !out.nAsset.vchSurjectionproof.empty());
|
||||
if (output_blinding_factors[nOut] != uint256()) {
|
||||
assert(output_asset_blinding_factors[nOut] != uint256());
|
||||
|
|
@ -157,7 +157,7 @@ int BlindOutputs(std::vector<uint256 >& input_blinding_factors, const std::vecto
|
|||
|
||||
for (size_t nOut = 0; nOut < tx.vout.size(); nOut++) {
|
||||
CTxOut& out = tx.vout[nOut];
|
||||
if (out.nValue.IsAmount() && output_pubkeys[nOut].IsFullyValid()) {
|
||||
if (out.nValue.IsExplicit() && output_pubkeys[nOut].IsFullyValid()) {
|
||||
CTxOutValue& value = out.nValue;
|
||||
CTxOutAsset& asset = out.nAsset;
|
||||
CAmount amount = value.GetAmount();
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ double CCoinsViewCache::GetPriority(const CTransaction &tx, int nHeight, CAmount
|
|||
if (coins->nHeight <= nHeight) {
|
||||
const CTxOutValue& val = coins->vout[txin.prevout.n].nValue;
|
||||
CAmount nAmount = COIN;
|
||||
if (val.IsAmount())
|
||||
if (val.IsExplicit())
|
||||
nAmount = val.GetAmount();
|
||||
dResult += nAmount * (nHeight-coins->nHeight);
|
||||
inChainInputValue += nAmount;
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ public:
|
|||
template <typename Stream, typename Operation>
|
||||
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
||||
if (!ser_action.ForRead()) {
|
||||
if (txout.nValue.IsAmount()) {
|
||||
if (txout.nValue.IsExplicit()) {
|
||||
uint8_t b = 0;
|
||||
READWRITE(b);
|
||||
uint64_t nVal = CompressAmount(txout.nValue.GetAmount());
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry)
|
|||
|
||||
UniValue out(UniValue::VOBJ);
|
||||
|
||||
if (txout.nValue.IsAmount()) {
|
||||
if (txout.nValue.IsExplicit()) {
|
||||
UniValue outValue(UniValue::VNUM, FormatMoney(txout.nValue.GetAmount()));
|
||||
out.pushKV("value", outValue);
|
||||
} else {
|
||||
|
|
|
|||
28
src/main.cpp
28
src/main.cpp
|
|
@ -1083,7 +1083,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
|
|||
{
|
||||
if (!txout.nValue.IsValid())
|
||||
return state.DoS(100, false, REJECT_INVALID, "bad-txns-vout-amount-invalid");
|
||||
if (!txout.nValue.IsAmount())
|
||||
if (!txout.nValue.IsExplicit())
|
||||
continue;
|
||||
// Each output is turned into a value commitment, no overflow detection needed
|
||||
if (!MoneyRange(txout.nValue.GetAmount()))
|
||||
|
|
@ -1201,7 +1201,7 @@ static inline bool QueueCheck(std::vector<CCheck*>* queue, CCheck* check)
|
|||
|
||||
bool CRangeCheck::operator()()
|
||||
{
|
||||
if (val->IsAmount()) {
|
||||
if (val->IsExplicit()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1268,7 +1268,7 @@ bool VerifyAmounts(const CCoinsViewCache& cache, const CTransaction& tx, std::ve
|
|||
return false;
|
||||
}
|
||||
|
||||
if (val.IsAmount()) {
|
||||
if (val.IsExplicit()) {
|
||||
if (!MoneyRange(val.GetAmount()))
|
||||
return false;
|
||||
|
||||
|
|
@ -1317,7 +1317,7 @@ bool VerifyAmounts(const CCoinsViewCache& cache, const CTransaction& tx, std::ve
|
|||
return false;
|
||||
}
|
||||
|
||||
if (val.IsAmount()) {
|
||||
if (val.IsExplicit()) {
|
||||
if (!MoneyRange(val.GetAmount()))
|
||||
return false;
|
||||
|
||||
|
|
@ -1346,7 +1346,7 @@ bool VerifyAmounts(const CCoinsViewCache& cache, const CTransaction& tx, std::ve
|
|||
// Range proofs
|
||||
for (size_t i = 0; i < tx.vout.size(); i++) {
|
||||
const CTxOutValue& val = tx.vout[i].nValue;
|
||||
if (val.IsAmount())
|
||||
if (val.IsExplicit())
|
||||
continue;
|
||||
if (!QueueCheck(pvChecks, new CRangeCheck(&val, &tx.vout[i].nAsset, &tx.vout[i].scriptPubKey, cacheStore))) {
|
||||
return false;
|
||||
|
|
@ -1404,7 +1404,7 @@ bool VerifyCoinbaseAmount(const CTransaction& tx, const CAmountMap& mapFees)
|
|||
assert(tx.IsCoinBase());
|
||||
CAmountMap remaining = mapFees;
|
||||
for (unsigned int i = 0; i < tx.vout.size(); i++) {
|
||||
if (!tx.vout[i].nValue.IsAmount() || !tx.vout[i].nAsset.IsExplicit())
|
||||
if (!tx.vout[i].nValue.IsExplicit() || !tx.vout[i].nAsset.IsExplicit())
|
||||
return false;
|
||||
remaining[tx.vout[i].nAsset.GetAsset()] -= tx.vout[i].nValue.GetAmount();
|
||||
}
|
||||
|
|
@ -2012,7 +2012,7 @@ bool GetLockedOutputs(const uint256 &genesisHash, const CAmount &nAmount, std::v
|
|||
continue;
|
||||
}
|
||||
|
||||
assert(coins.vout[lock.first.n].nValue.IsAmount() && coins.vout[lock.first.n].nValue.GetAmount() == lock.second);
|
||||
assert(coins.vout[lock.first.n].nValue.IsExplicit() && coins.vout[lock.first.n].nValue.GetAmount() == lock.second);
|
||||
res.push_back(lock);
|
||||
break;
|
||||
}
|
||||
|
|
@ -2039,7 +2039,7 @@ bool GetLockedOutputs(const uint256 &genesisHash, const CAmount &nAmount, std::v
|
|||
if (mempool.mapNextTx.count(COutPoint(it->first.hash, it->first.n)))
|
||||
continue;
|
||||
|
||||
assert(coins.vout[it->first.n].nValue.IsAmount() && coins.vout[it->first.n].nValue.GetAmount() == it->second);
|
||||
assert(coins.vout[it->first.n].nValue.IsExplicit() && coins.vout[it->first.n].nValue.GetAmount() == it->second);
|
||||
res.push_back(*it);
|
||||
|
||||
nTotal += it->second;
|
||||
|
|
@ -2074,7 +2074,7 @@ bool GetLockedOutputs(const uint256 &genesisHash, const CAmount &nAmount, std::v
|
|||
if (mempool.mapWithdrawsSpentToTxid.count(std::make_pair(withdrawGenHash, COutPoint(tx.GetHash(), j))))
|
||||
continue;
|
||||
|
||||
if (txout.scriptPubKey.IsWithdrawLock() && txout.nValue.IsAmount()) {
|
||||
if (txout.scriptPubKey.IsWithdrawLock() && txout.nValue.IsExplicit()) {
|
||||
res.push_back(std::make_pair(COutPoint(tx.GetHash(), j), txout.nValue.GetAmount()));
|
||||
nTotal += txout.nValue.GetAmount();
|
||||
if (nTotal >= nAmount)
|
||||
|
|
@ -2429,7 +2429,7 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins
|
|||
|
||||
// Check for negative or overflow input values
|
||||
const CTxOutValue& value = coins->vout[prevout.n].nValue;
|
||||
if (value.IsAmount()) {
|
||||
if (value.IsExplicit()) {
|
||||
nValueIn += value.GetAmount();
|
||||
if (!MoneyRange(value.GetAmount()) || !MoneyRange(nValueIn))
|
||||
return state.DoS(100, false, REJECT_INVALID, "bad-txns-inputvalues-outofrange");
|
||||
|
|
@ -2568,7 +2568,7 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
|
|||
return state.DoS(100,false, REJECT_INVALID, strprintf("mandatory-script-verify-flag-failed (%s)", ScriptErrorString(serror)));
|
||||
}
|
||||
const CTxOutValue& value = coins->vout[tx.vin[i].prevout.n].nValue;
|
||||
if (value.IsAmount())
|
||||
if (value.IsExplicit())
|
||||
prevValueIn = value.GetAmount();
|
||||
else
|
||||
prevValueIn = -1;
|
||||
|
|
@ -2984,7 +2984,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
vPos.push_back(std::make_pair(tx.GetHash(), pos));
|
||||
for (unsigned int i = 0; i < tx.vout.size(); i++) {
|
||||
CTxOut txout= tx.vout[i];
|
||||
if (txout.scriptPubKey.IsWithdrawLock() && txout.nValue.IsAmount())
|
||||
if (txout.scriptPubKey.IsWithdrawLock() && txout.nValue.IsExplicit())
|
||||
mLocksCreated.insert(std::make_pair(txout.scriptPubKey.GetWithdrawLockGenesisHash(), std::make_pair(COutPoint(tx.GetHash(), i), txout.nValue.GetAmount())));
|
||||
}
|
||||
|
||||
|
|
@ -3000,7 +3000,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
|
||||
// Check that all non-zero-value coinbase outputs pay to the required destination
|
||||
BOOST_FOREACH(const CTxOut& txout, block.vtx[0].vout) {
|
||||
if (chainparams.CoinbaseDestination() != CScript() && txout.scriptPubKey != chainparams.CoinbaseDestination() && !(txout.nValue.IsAmount() && txout.nValue.GetAmount() == 0))
|
||||
if (chainparams.CoinbaseDestination() != CScript() && txout.scriptPubKey != chainparams.CoinbaseDestination() && !(txout.nValue.IsExplicit() && txout.nValue.GetAmount() == 0))
|
||||
return state.DoS(100, error("ConnectBlock(): Coinbase outputs didnt match required scriptPubKey"),
|
||||
REJECT_INVALID, "bad-coinbase-txos");
|
||||
}
|
||||
|
|
@ -3167,7 +3167,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
|
||||
for (unsigned int j = 0; j < tx.vout.size(); j++) {
|
||||
CTxOut txout = tx.vout[j];
|
||||
if (txout.scriptPubKey.IsWithdrawLock() && txout.nValue.IsAmount())
|
||||
if (txout.scriptPubKey.IsWithdrawLock() && txout.nValue.IsExplicit())
|
||||
mLocksCreated.insert(std::make_pair(txout.scriptPubKey.GetWithdrawLockGenesisHash(), std::make_pair(COutPoint(tx.GetHash(), j), txout.nValue.GetAmount())));
|
||||
}
|
||||
if (!tx.HasValidFee())
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs)
|
|||
if (prev.scriptPubKey.IsWithdrawLock()) {
|
||||
if (!tx.vin[i].scriptSig.IsWithdrawProof()) {
|
||||
if (tx.vout.size() < i)
|
||||
if (!tx.vout[i].nValue.IsAmount() || tx.vout[i].nValue.GetAmount() > MAX_MONEY / 100)
|
||||
if (!tx.vout[i].nValue.IsExplicit() || tx.vout[i].nValue.GetAmount() > MAX_MONEY / 100)
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ bool CTxOutValue::IsValid() const
|
|||
|
||||
CAmount CTxOutValue::GetAmount() const
|
||||
{
|
||||
assert(IsAmount());
|
||||
assert(IsExplicit());
|
||||
return ReadBE64(&vchCommitment[1]);
|
||||
}
|
||||
|
||||
|
|
@ -77,7 +77,7 @@ std::string CTxOut::ToString() const
|
|||
strAsset = strprintf("nAsset=%s, ", nAsset.GetAsset().GetHex());
|
||||
if (nAsset.IsCommitment())
|
||||
strAsset = std::string("nAsset=UNKNOWN, ");
|
||||
return strprintf("CTxOut(%snValue=%s, scriptPubKey=%s)", strAsset, (nValue.IsAmount() ? strprintf("%d.%08d", nValue.GetAmount() / COIN, nValue.GetAmount() % COIN) : std::string("UNKNOWN")), HexStr(scriptPubKey).substr(0, 30));
|
||||
return strprintf("CTxOut(%snValue=%s, scriptPubKey=%s)", strAsset, (nValue.IsExplicit() ? strprintf("%d.%08d", nValue.GetAmount() / COIN, nValue.GetAmount() % COIN) : std::string("UNKNOWN")), HexStr(scriptPubKey).substr(0, 30));
|
||||
}
|
||||
|
||||
std::string COutPoint::ToString() const
|
||||
|
|
@ -92,9 +92,9 @@ std::string CAssetIssuance::ToString() const
|
|||
str += assetBlindingNonce.ToString();
|
||||
str += ", ";
|
||||
str += assetEntropy.ToString();
|
||||
str += strprintf(", %s", (nAmount.IsAmount() ? strprintf("%d.%08d", nAmount.GetAmount() / COIN, nAmount.GetAmount() % COIN) : std::string("UNKNOWN")));
|
||||
str += strprintf(", %s", (nAmount.IsExplicit() ? strprintf("%d.%08d", nAmount.GetAmount() / COIN, nAmount.GetAmount() % COIN) : std::string("UNKNOWN")));
|
||||
if (!nInflationKeys.IsNull())
|
||||
str += strprintf(", %s", (nInflationKeys.IsAmount() ? strprintf("%d.%08d", nInflationKeys.GetAmount() / COIN, nInflationKeys.GetAmount() % COIN) : std::string("UNKNOWN")));
|
||||
str += strprintf(", %s", (nInflationKeys.IsExplicit() ? strprintf("%d.%08d", nInflationKeys.GetAmount() / COIN, nInflationKeys.GetAmount() % COIN) : std::string("UNKNOWN")));
|
||||
str += ")";
|
||||
return str;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ public:
|
|||
|
||||
bool IsValid() const;
|
||||
|
||||
bool IsAmount() const { return vchCommitment[0] == 1; }
|
||||
bool IsExplicit() const { return vchCommitment[0] == 1; }
|
||||
CAmount GetAmount() const;
|
||||
|
||||
friend bool operator==(const CTxOutValue& a, const CTxOutValue& b)
|
||||
|
|
@ -260,7 +260,7 @@ public:
|
|||
|
||||
bool IsDust(const CFeeRate &minRelayTxFee) const
|
||||
{
|
||||
if (!nValue.IsAmount())
|
||||
if (!nValue.IsExplicit())
|
||||
return false; // FIXME
|
||||
if (!nAsset.IsExplicit() || nAsset.GetAsset() != BITCOINID)
|
||||
return false;
|
||||
|
|
@ -274,7 +274,7 @@ public:
|
|||
bool IsFee() const
|
||||
{
|
||||
CAsset asset;
|
||||
if (scriptPubKey == CScript() && nValue.IsAmount() && nAsset.IsExplicit())
|
||||
if (scriptPubKey == CScript() && nValue.IsExplicit() && nAsset.IsExplicit())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -574,7 +574,7 @@ static bool rest_getutxos(HTTPRequest* req, const std::string& strURIPart)
|
|||
UniValue utxo(UniValue::VOBJ);
|
||||
utxo.push_back(Pair("txvers", (int32_t)coin.nTxVer));
|
||||
utxo.push_back(Pair("height", (int32_t)coin.nHeight));
|
||||
if (coin.out.nValue.IsAmount())
|
||||
if (coin.out.nValue.IsExplicit())
|
||||
utxo.push_back(Pair("value", ValueFromAmount(coin.out.nValue.GetAmount())));
|
||||
else {} //TODO: Non-Amount values
|
||||
|
||||
|
|
|
|||
|
|
@ -639,7 +639,7 @@ static bool GetUTXOStats(CCoinsView *view, CCoinsStats &stats)
|
|||
stats.nTransactionOutputs++;
|
||||
ss << VARINT(i+1);
|
||||
ss << out;
|
||||
if (out.nValue.IsAmount())
|
||||
if (out.nValue.IsExplicit())
|
||||
nTotalAmount += out.nValue.GetAmount();
|
||||
}
|
||||
}
|
||||
|
|
@ -763,7 +763,7 @@ UniValue gettxout(const UniValue& params, bool fHelp)
|
|||
ret.push_back(Pair("confirmations", 0));
|
||||
else
|
||||
ret.push_back(Pair("confirmations", pindex->nHeight - coins.nHeight + 1));
|
||||
if (coins.vout[n].nValue.IsAmount()) {
|
||||
if (coins.vout[n].nValue.IsExplicit()) {
|
||||
ret.push_back(Pair("value", ValueFromAmount(coins.vout[n].nValue.GetAmount())));
|
||||
} else {
|
||||
ret.push_back(Pair("valuecommitment", uint256(coins.vout[n].nValue.vchCommitment).GetHex()));
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
|
|||
for (unsigned int i = 0; i < tx.vout.size(); i++) {
|
||||
const CTxOut& txout = tx.vout[i];
|
||||
UniValue out(UniValue::VOBJ);
|
||||
if (txout.nValue.IsAmount())
|
||||
if (txout.nValue.IsExplicit())
|
||||
out.push_back(Pair("value", ValueFromAmount(txout.nValue.GetAmount())));
|
||||
else {
|
||||
int exp;
|
||||
|
|
@ -573,7 +573,7 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp)
|
|||
// or blank spots to be filled by BlindOutputs
|
||||
void FillOutputBlinds(const CMutableTransaction& tx, bool fUseWallet, std::vector<uint256>& output_value_blinds, std::vector<uint256>& output_asset_blinds, std::vector<CAsset>& output_assets, std::vector<CPubKey>& output_pubkeys) {
|
||||
for (size_t nOut = 0; nOut < tx.vout.size(); nOut++) {
|
||||
if (!tx.vout[nOut].nValue.IsAmount()) {
|
||||
if (!tx.vout[nOut].nValue.IsExplicit()) {
|
||||
uint256 blinding_factor;
|
||||
uint256 asset_blinding_factor;
|
||||
CAsset asset;
|
||||
|
|
@ -769,7 +769,7 @@ UniValue blindrawtransaction(const UniValue& params, bool fHelp)
|
|||
else {
|
||||
input_assets.push_back(it->second.GetAsset(tx.vin[nIn].prevout.n));
|
||||
}
|
||||
if (it->second.vout[tx.vin[nIn].prevout.n].nValue.IsAmount()) {
|
||||
if (it->second.vout[tx.vin[nIn].prevout.n].nValue.IsExplicit()) {
|
||||
input_amounts.push_back(it->second.vout[tx.vin[nIn].prevout.n].nValue.GetAmount());
|
||||
}
|
||||
else {
|
||||
|
|
@ -1222,7 +1222,7 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp)
|
|||
if (!fOverrideBlindable) {
|
||||
for (unsigned i = 0; i < tx.vout.size(); i++) {
|
||||
const CTxOut& txout = tx.vout[i];
|
||||
if (txout.nValue.IsAmount() && txout.nValue.vchNonceCommitment.size() != 0)
|
||||
if (txout.nValue.IsExplicit() && txout.nValue.vchNonceCommitment.size() != 0)
|
||||
throw JSONRPCError(RPC_TRANSACTION_ERROR, strprintf("Output %u is unblinded, but has blinding pubkey attached, please use [raw]blindrawtransaction", i));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ static int verify_script(const unsigned char *scriptPubKey, unsigned int scriptP
|
|||
// Regardless of the verification result, the tx did not error.
|
||||
set_error(err, bitcoinconsensus_ERR_OK);
|
||||
PrecomputedTransactionData txdata(tx);
|
||||
if (amountPreviousInput.IsAmount() && (amountPreviousInput.GetAmount() < -1 || (nIn != 0 && !MoneyRange(amountPreviousInput.GetAmount()))))
|
||||
if (amountPreviousInput.IsExplicit() && (amountPreviousInput.GetAmount() < -1 || (nIn != 0 && !MoneyRange(amountPreviousInput.GetAmount()))))
|
||||
return VerifyScript(tx.vin[nIn].scriptSig, CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), nIn < tx.wit.vtxinwit.size() ? &tx.wit.vtxinwit[nIn].scriptWitness : NULL, flags, TransactionNoWithdrawsSignatureChecker(&tx, nIn, amount, txdata), NULL);
|
||||
else
|
||||
return VerifyScript(tx.vin[nIn].scriptSig, CScript(scriptPubKey, scriptPubKey + scriptPubKeyLen), nIn < tx.wit.vtxinwit.size() ? &tx.wit.vtxinwit[nIn].scriptWitness : NULL, flags, TransactionSignatureChecker(&tx, nIn, amount, amountPreviousInput, CScript()), NULL);
|
||||
|
|
|
|||
|
|
@ -1443,17 +1443,17 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, un
|
|||
CScript relockScript = CScript() << vgenesisHash << OP_WITHDRAWPROOFVERIFY;
|
||||
|
||||
if (stack.size() == 1) { // increasing value of locked coins
|
||||
if (!checker.GetValueIn().IsAmount())
|
||||
if (!checker.GetValueIn().IsExplicit())
|
||||
return set_error(serror, SCRIPT_ERR_WITHDRAW_VERIFY_BLINDED_AMOUNTS);
|
||||
CAmount minValue = checker.GetValueIn().GetAmount();
|
||||
CTxOut newOutput = checker.GetOutputOffsetFromCurrent(0);
|
||||
if (newOutput.IsNull()) {
|
||||
newOutput = checker.GetOutputOffsetFromCurrent(-1);
|
||||
if (!checker.GetValueInPrevIn().IsAmount())
|
||||
if (!checker.GetValueInPrevIn().IsExplicit())
|
||||
return set_error(serror, SCRIPT_ERR_WITHDRAW_VERIFY_BLINDED_AMOUNTS);
|
||||
minValue += checker.GetValueInPrevIn().GetAmount();
|
||||
}
|
||||
if (!newOutput.nValue.IsAmount())
|
||||
if (!newOutput.nValue.IsExplicit())
|
||||
return set_error(serror, SCRIPT_ERR_WITHDRAW_VERIFY_BLINDED_AMOUNTS);
|
||||
if (newOutput.scriptPubKey != relockScript || newOutput.nValue.GetAmount() < minValue)
|
||||
return set_error(serror, SCRIPT_ERR_WITHDRAW_VERIFY_OUTPUT);
|
||||
|
|
@ -1550,20 +1550,20 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, un
|
|||
// * Tx must relock at least <unlocked coins> - <locked-on-bitcoin coins>
|
||||
// * Tx must send at least the withdraw value to its P2SH withdraw, but may send more
|
||||
CAmount withdrawVal = locktx.vout[nlocktxOut].nValue;
|
||||
if (!checker.GetValueIn().IsAmount()) // Heh, you just destroyed coins
|
||||
if (!checker.GetValueIn().IsExplicit()) // Heh, you just destroyed coins
|
||||
return set_error(serror, SCRIPT_ERR_WITHDRAW_VERIFY_BLINDED_AMOUNTS);
|
||||
|
||||
CAmount lockValueRequired = checker.GetValueIn().GetAmount() - withdrawVal;
|
||||
if (lockValueRequired > 0) {
|
||||
const CTxOut newLockOutput = checker.GetOutputOffsetFromCurrent(1);
|
||||
if (!newLockOutput.nValue.IsAmount())
|
||||
if (!newLockOutput.nValue.IsExplicit())
|
||||
return set_error(serror, SCRIPT_ERR_WITHDRAW_VERIFY_BLINDED_AMOUNTS);
|
||||
if (newLockOutput.IsNull() || newLockOutput.scriptPubKey != relockScript || newLockOutput.nValue.GetAmount() < lockValueRequired)
|
||||
return set_error(serror, SCRIPT_ERR_WITHDRAW_VERIFY_RELOCK_SCRIPTVAL);
|
||||
}
|
||||
|
||||
const CTxOut withdrawOutput = checker.GetOutputOffsetFromCurrent(0);
|
||||
if (!withdrawOutput.nValue.IsAmount())
|
||||
if (!withdrawOutput.nValue.IsExplicit())
|
||||
return set_error(serror, SCRIPT_ERR_WITHDRAW_VERIFY_BLINDED_AMOUNTS);
|
||||
if (withdrawOutput.nValue.GetAmount() < withdrawVal)
|
||||
return set_error(serror, SCRIPT_ERR_WITHDRAW_VERIFY_OUTPUT_VAL);
|
||||
|
|
|
|||
|
|
@ -109,8 +109,8 @@ BOOST_AUTO_TEST_CASE(naive_blinding_test)
|
|||
output_asset_blinds.push_back(uint256());
|
||||
output_pubkeys.push_back(pubkeyDummy);
|
||||
BOOST_CHECK(BlindOutputs(input_blinds, input_asset_blinds, input_assets, input_amounts, output_blinds, output_asset_blinds, output_pubkeys, tx3) == 2);
|
||||
BOOST_CHECK(!tx3.vout[0].nValue.IsAmount());
|
||||
BOOST_CHECK(!tx3.vout[2].nValue.IsAmount());
|
||||
BOOST_CHECK(!tx3.vout[0].nValue.IsExplicit());
|
||||
BOOST_CHECK(!tx3.vout[2].nValue.IsExplicit());
|
||||
BOOST_CHECK(VerifyAmounts(cache, tx3));
|
||||
|
||||
CAmount unblinded_amount;
|
||||
|
|
@ -220,9 +220,9 @@ BOOST_AUTO_TEST_CASE(naive_blinding_test)
|
|||
output_pubkeys.push_back(CPubKey());
|
||||
|
||||
BOOST_CHECK(BlindOutputs(input_blinds, input_asset_blinds, input_assets, input_amounts, output_blinds, output_asset_blinds, output_pubkeys, tx4) == 2);
|
||||
BOOST_CHECK(!tx4.vout[0].nValue.IsAmount());
|
||||
BOOST_CHECK(tx4.vout[1].nValue.IsAmount());
|
||||
BOOST_CHECK(!tx4.vout[2].nValue.IsAmount());
|
||||
BOOST_CHECK(!tx4.vout[0].nValue.IsExplicit());
|
||||
BOOST_CHECK(tx4.vout[1].nValue.IsExplicit());
|
||||
BOOST_CHECK(!tx4.vout[2].nValue.IsExplicit());
|
||||
BOOST_CHECK(VerifyAmounts(cache, tx4));
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
|
|
|
|||
|
|
@ -2325,7 +2325,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, bool ov
|
|||
// Turn the txout set into a CRecipient vector
|
||||
BOOST_FOREACH(const CTxOut& txOut, tx.vout)
|
||||
{
|
||||
if (!txOut.nValue.IsAmount() || !txOut.nAsset.IsExplicit()) {
|
||||
if (!txOut.nValue.IsExplicit() || !txOut.nAsset.IsExplicit()) {
|
||||
strFailReason = _("Pre-funded amounts must be non-blinded");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -4043,7 +4043,7 @@ bool CWallet::LoadAssetLabelMapping(const CAsset& id, const std::string& label)
|
|||
|
||||
void CWallet::ComputeBlindingData(const CTxOut& output, CAmount& amount, CPubKey& pubkey, uint256& blindingfactor, CAsset& asset, uint256& assetBlindingFactor) const
|
||||
{
|
||||
if (output.nValue.IsAmount() && (output.nAsset.IsExplicit() || output.nAsset.IsAssetGeneration())) {
|
||||
if (output.nValue.IsExplicit() && (output.nAsset.IsExplicit() || output.nAsset.IsAssetGeneration())) {
|
||||
amount = output.nValue.GetAmount();
|
||||
asset = output.nAsset.GetAsset();
|
||||
pubkey = CPubKey();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue