|
|
@ -306,38 +306,39 @@ CheckKevaTransaction (const CTransaction& tx, unsigned nHeight, |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
/* As a first step, try to locate inputs and outputs of the transaction
|
|
|
|
/* 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 |
|
|
|
that are keva scripts. At most one input and output should be |
|
|
|
a name operation. */ |
|
|
|
a keva operation. */ |
|
|
|
|
|
|
|
|
|
|
|
int nameIn = -1; |
|
|
|
int nameIn = -1; |
|
|
|
CKevaScript nameOpIn; |
|
|
|
CKevaScript nameOpIn; |
|
|
|
Coin coinIn; |
|
|
|
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; |
|
|
|
const COutPoint& prevout = tx.vin[i].prevout; |
|
|
|
Coin coin; |
|
|
|
Coin coin; |
|
|
|
if (!view.GetCoin (prevout, coin)) { |
|
|
|
if (!view.GetCoin (prevout, coin)) |
|
|
|
return error ("%s: failed to fetch input coin for %s", __func__, txid); |
|
|
|
return error ("%s: failed to fetch input coin for %s", __func__, txid); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const CKevaScript op(coin.out.scriptPubKey); |
|
|
|
const CKevaScript op(coin.out.scriptPubKey); |
|
|
|
if (op.isKevaOp()) { |
|
|
|
if (op.isKevaOp()) { |
|
|
|
if (nameIn != -1) |
|
|
|
if (nameIn != -1) { |
|
|
|
return state.Invalid (error ("%s: multiple name inputs into" |
|
|
|
return state.Invalid (error ("%s: multiple name inputs into transaction %s", __func__, txid)); |
|
|
|
" transaction %s", __func__, txid)); |
|
|
|
|
|
|
|
nameIn = i; |
|
|
|
|
|
|
|
nameOpIn = op; |
|
|
|
|
|
|
|
coinIn = coin; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
nameIn = i; |
|
|
|
|
|
|
|
nameOpIn = op; |
|
|
|
|
|
|
|
coinIn = coin; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int nameOut = -1; |
|
|
|
int nameOut = -1; |
|
|
|
CKevaScript nameOpOut; |
|
|
|
CKevaScript nameOpOut; |
|
|
|
for (unsigned i = 0; i < tx.vout.size (); ++i) { |
|
|
|
for (unsigned i = 0; i < tx.vout.size (); ++i) { |
|
|
|
const CKevaScript op(tx.vout[i].scriptPubKey); |
|
|
|
const CKevaScript op(tx.vout[i].scriptPubKey); |
|
|
|
if (op.isKevaOp()) { |
|
|
|
if (op.isKevaOp()) { |
|
|
|
if (nameOut != -1) |
|
|
|
if (nameOut != -1) { |
|
|
|
return state.Invalid (error ("%s: multiple name outputs from" |
|
|
|
return state.Invalid (error ("%s: multiple name outputs from" |
|
|
|
" transaction %s", __func__, txid)); |
|
|
|
" transaction %s", __func__, txid)); |
|
|
|
|
|
|
|
} |
|
|
|
nameOut = i; |
|
|
|
nameOut = i; |
|
|
|
nameOpOut = op; |
|
|
|
nameOpOut = op; |
|
|
|
} |
|
|
|
} |
|
|
@ -349,11 +350,11 @@ CheckKevaTransaction (const CTransaction& tx, unsigned nHeight, |
|
|
|
|
|
|
|
|
|
|
|
if (!tx.IsKevacoin ()) { |
|
|
|
if (!tx.IsKevacoin ()) { |
|
|
|
if (nameIn != -1) |
|
|
|
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)); |
|
|
|
__func__, txid)); |
|
|
|
if (nameOut != -1) |
|
|
|
if (nameOut != -1) |
|
|
|
return state.Invalid (error ("%s: non-Namecoin tx %s at height %u" |
|
|
|
return state.Invalid (error ("%s: non-Kevacoin tx %s at height %u" |
|
|
|
" has name outputs", |
|
|
|
" has keva outputs", |
|
|
|
__func__, txid, nHeight)); |
|
|
|
__func__, txid, nHeight)); |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
@ -361,7 +362,7 @@ CheckKevaTransaction (const CTransaction& tx, unsigned nHeight, |
|
|
|
|
|
|
|
|
|
|
|
assert(tx.IsKevacoin ()); |
|
|
|
assert(tx.IsKevacoin ()); |
|
|
|
if (nameOut == -1) |
|
|
|
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)); |
|
|
|
__func__, txid)); |
|
|
|
|
|
|
|
|
|
|
|
/* Reject "greedy names". */ |
|
|
|
/* Reject "greedy names". */ |
|
|
@ -406,8 +407,7 @@ CheckKevaTransaction (const CTransaction& tx, unsigned nHeight, |
|
|
|
|
|
|
|
|
|
|
|
assert (nameOpOut.isAnyUpdate()); |
|
|
|
assert (nameOpOut.isAnyUpdate()); |
|
|
|
if (nameIn == -1) { |
|
|
|
if (nameIn == -1) { |
|
|
|
return state.Invalid(error("CheckNameTransaction: update without" |
|
|
|
return state.Invalid(error("CheckNameTransaction: update without previous keva input")); |
|
|
|
" previous name input")); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const valtype& key = nameOpOut.getOpKey(); |
|
|
|
const valtype& key = nameOpOut.getOpKey(); |
|
|
|