diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp index 45d9c9c35..fc48c2f6d 100644 --- a/src/consensus/tx_verify.cpp +++ b/src/consensus/tx_verify.cpp @@ -209,7 +209,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fChe bool Consensus::CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, unsigned flags, CAmount& txfee) { if (!CheckKevaTransaction (tx, nSpendHeight, inputs, state, flags)) { - return state.Invalid(false, 0, "", "Tx invalid for Namecoin"); + return state.Invalid(false, 0, "", "Tx invalid for Kevacoin"); } // are the actual inputs available? diff --git a/src/keva/main.cpp b/src/keva/main.cpp index f5a941d87..0e48653d6 100644 --- a/src/keva/main.cpp +++ b/src/keva/main.cpp @@ -306,38 +306,39 @@ CheckKevaTransaction (const CTransaction& tx, unsigned nHeight, #endif /* As a first step, try to locate inputs and outputs of the transaction - that are name scripts. At most one input and output should be - a name operation. */ + that are keva scripts. At most one input and output should be + a keva operation. */ int nameIn = -1; CKevaScript nameOpIn; Coin coinIn; - for (unsigned i = 0; i < tx.vin.size (); ++i) - { - const COutPoint& prevout = tx.vin[i].prevout; - Coin coin; - if (!view.GetCoin (prevout, coin)) - return error ("%s: failed to fetch input coin for %s", __func__, txid); - - const CKevaScript op(coin.out.scriptPubKey); - if (op.isKevaOp()) { - if (nameIn != -1) - return state.Invalid (error ("%s: multiple name inputs into" - " transaction %s", __func__, txid)); - nameIn = i; - nameOpIn = op; - coinIn = coin; + for (unsigned i = 0; i < tx.vin.size (); ++i) { + const COutPoint& prevout = tx.vin[i].prevout; + Coin coin; + if (!view.GetCoin (prevout, coin)) { + return error ("%s: failed to fetch input coin for %s", __func__, txid); + } + + const CKevaScript op(coin.out.scriptPubKey); + if (op.isKevaOp()) { + if (nameIn != -1) { + return state.Invalid (error ("%s: multiple name inputs into transaction %s", __func__, txid)); } + nameIn = i; + nameOpIn = op; + coinIn = coin; } + } int nameOut = -1; CKevaScript nameOpOut; for (unsigned i = 0; i < tx.vout.size (); ++i) { const CKevaScript op(tx.vout[i].scriptPubKey); if (op.isKevaOp()) { - if (nameOut != -1) + if (nameOut != -1) { return state.Invalid (error ("%s: multiple name outputs from" " transaction %s", __func__, txid)); + } nameOut = i; nameOpOut = op; } @@ -349,11 +350,11 @@ CheckKevaTransaction (const CTransaction& tx, unsigned nHeight, if (!tx.IsKevacoin ()) { if (nameIn != -1) - return state.Invalid (error ("%s: non-Namecoin tx %s has name inputs", + return state.Invalid (error ("%s: non-Kevacoin tx %s has keva inputs", __func__, txid)); if (nameOut != -1) - return state.Invalid (error ("%s: non-Namecoin tx %s at height %u" - " has name outputs", + return state.Invalid (error ("%s: non-Kevacoin tx %s at height %u" + " has keva outputs", __func__, txid, nHeight)); return true; @@ -361,7 +362,7 @@ CheckKevaTransaction (const CTransaction& tx, unsigned nHeight, assert(tx.IsKevacoin ()); if (nameOut == -1) - return state.Invalid (error ("%s: Namecoin tx %s has no name outputs", + return state.Invalid (error ("%s: Kevacoin tx %s has no keva outputs", __func__, txid)); /* Reject "greedy names". */ @@ -406,8 +407,7 @@ CheckKevaTransaction (const CTransaction& tx, unsigned nHeight, assert (nameOpOut.isAnyUpdate()); if (nameIn == -1) { - return state.Invalid(error("CheckNameTransaction: update without" - " previous name input")); + return state.Invalid(error("CheckNameTransaction: update without previous keva input")); } const valtype& key = nameOpOut.getOpKey(); diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index 0a4417b91..791124b6c 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -354,6 +354,13 @@ bool EvalScript(std::vector >& stack, const CScript& case OP_NOP: break; + // + // KEVA + // + case OP_KEVA_NAMESPACE: + case OP_KEVA_PUT: + break; + case OP_CHECKLOCKTIMEVERIFY: { if (!(flags & SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)) { @@ -1437,9 +1444,10 @@ bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const C return false; if (flags & SCRIPT_VERIFY_P2SH) stackCopy = stack; - if (!EvalScript(stack, scriptPubKey, flags, checker, SIGVERSION_BASE, serror)) + if (!EvalScript(stack, scriptPubKey, flags, checker, SIGVERSION_BASE, serror)) { // serror is set return false; + } if (stack.empty()) return set_error(serror, SCRIPT_ERR_EVAL_FALSE); if (CastToBool(stack.back()) == false) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 95bb60ac1..c5d385868 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -459,9 +459,9 @@ void SendMoneyToScript(CWallet* const pwallet, const CScript &scriptPubKey, std::string strError; if (withInput) { const CWalletTx* dummyWalletTx; - if (!pwallet->FindValueInNameInput (*withInput, lockedValue, - dummyWalletTx, strError)) + if (!pwallet->FindValueInNameInput (*withInput, lockedValue, dummyWalletTx, strError)) { throw JSONRPCError(RPC_WALLET_ERROR, strError); + } } if (nValue > curBalance + lockedValue) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 67f1c1a22..4676d006f 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2857,6 +2857,10 @@ bool CWallet::CreateTransaction(const std::vector& vecSend, } } + if (withInput) { + setCoins.insert(CInputCoin(withInputTx, withInput->prevout.n)); + } + const CAmount nChange = nValueIn - nValueToSelect; if (nChange > 0) @@ -3060,9 +3064,7 @@ CWallet::FindValueInNameInput (const CTxIn& nameInput, CAmount& value, const CWalletTx*& walletTx, std::string& strFailReason) const { -#if 0 - // JWU TODO: implement this! - walletTx = GetWalletTx (nameInput.prevout.hash); + walletTx = GetWalletTx(nameInput.prevout.hash); if (!walletTx) { strFailReason = _("Input tx not found in wallet"); return false; @@ -3074,16 +3076,13 @@ CWallet::FindValueInNameInput (const CTxIn& nameInput, return false; } - if (!CKevaScript::isKevaScript (output.scriptPubKey)) { - strFailReason = _("Input tx is not a name operation"); + if (!CKevaScript::isKevaScript(output.scriptPubKey)) { + strFailReason = _("Input tx is not a keva operation"); return false; } value = output.nValue; return true; -#else - return true; -#endif } /**