Browse Source

Handled OP_KEVA_* - treated them as NOP.

cn
Jianping Wu 6 years ago
parent
commit
148ff7fcbd
  1. 2
      src/consensus/tx_verify.cpp
  2. 30
      src/keva/main.cpp
  3. 10
      src/script/interpreter.cpp
  4. 4
      src/wallet/rpcwallet.cpp
  5. 11
      src/wallet/wallet.cpp

2
src/consensus/tx_verify.cpp

@ -209,7 +209,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fChe @@ -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?

30
src/keva/main.cpp

@ -306,24 +306,24 @@ CheckKevaTransaction (const CTransaction& tx, unsigned nHeight, @@ -306,24 +306,24 @@ 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)
{
for (unsigned i = 0; i < tx.vin.size (); ++i) {
const COutPoint& prevout = tx.vin[i].prevout;
Coin coin;
if (!view.GetCoin (prevout, 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));
if (nameIn != -1) {
return state.Invalid (error ("%s: multiple name inputs into transaction %s", __func__, txid));
}
nameIn = i;
nameOpIn = op;
coinIn = coin;
@ -335,9 +335,10 @@ CheckKevaTransaction (const CTransaction& tx, unsigned nHeight, @@ -335,9 +335,10 @@ CheckKevaTransaction (const CTransaction& tx, unsigned nHeight,
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, @@ -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, @@ -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, @@ -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();

10
src/script/interpreter.cpp

@ -354,6 +354,13 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& @@ -354,6 +354,13 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& 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 @@ -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)

4
src/wallet/rpcwallet.cpp

@ -459,10 +459,10 @@ void SendMoneyToScript(CWallet* const pwallet, const CScript &scriptPubKey, @@ -459,10 +459,10 @@ 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)
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds");

11
src/wallet/wallet.cpp

@ -2857,6 +2857,10 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, @@ -2857,6 +2857,10 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend,
}
}
if (withInput) {
setCoins.insert(CInputCoin(withInputTx, withInput->prevout.n));
}
const CAmount nChange = nValueIn - nValueToSelect;
if (nChange > 0)
@ -3060,8 +3064,6 @@ CWallet::FindValueInNameInput (const CTxIn& nameInput, @@ -3060,8 +3064,6 @@ 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);
if (!walletTx) {
strFailReason = _("Input tx not found in wallet");
@ -3075,15 +3077,12 @@ CWallet::FindValueInNameInput (const CTxIn& nameInput, @@ -3075,15 +3077,12 @@ CWallet::FindValueInNameInput (const CTxIn& nameInput,
}
if (!CKevaScript::isKevaScript(output.scriptPubKey)) {
strFailReason = _("Input tx is not a name operation");
strFailReason = _("Input tx is not a keva operation");
return false;
}
value = output.nValue;
return true;
#else
return true;
#endif
}
/**

Loading…
Cancel
Save