From a01614f5f514e059dd7d6d2a849b94643ec00734 Mon Sep 17 00:00:00 2001 From: Brannon King Date: Tue, 9 Jul 2019 14:32:08 -0600 Subject: [PATCH] updated to support using bech32 addresses with claim ops --- src/bloom.cpp | 4 +- src/consensus/tx_verify.cpp | 3 +- src/policy/policy.cpp | 2 +- src/rpc/client.cpp | 3 + src/script/interpreter.cpp | 8 +- src/wallet/ismine.cpp | 46 ++--- src/wallet/rpcwallet.cpp | 258 ++++++++++++++++------------ src/wallet/test/claim_rpc_tests.cpp | 30 +++- src/wallet/wallet.cpp | 28 +-- 9 files changed, 221 insertions(+), 161 deletions(-) diff --git a/src/bloom.cpp b/src/bloom.cpp index a06192508..b8cdba3dd 100644 --- a/src/bloom.cpp +++ b/src/bloom.cpp @@ -3,6 +3,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include +#include #include #include @@ -155,7 +156,8 @@ bool CBloomFilter::IsRelevantAndUpdate(const CTransaction& tx) else if ((nFlags & BLOOM_UPDATE_MASK) == BLOOM_UPDATE_P2PUBKEY_ONLY) { std::vector > vSolutions; - txnouttype type = Solver(txout.scriptPubKey, vSolutions); + const CScript& scriptPubKey = StripClaimScriptPrefix(txout.scriptPubKey); + txnouttype type = Solver(scriptPubKey, vSolutions); if (type == TX_PUBKEY || type == TX_MULTISIG) { insert(COutPoint(hash, i)); } diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp index 319195230..0a2d5bd5b 100644 --- a/src/consensus/tx_verify.cpp +++ b/src/consensus/tx_verify.cpp @@ -154,7 +154,8 @@ int64_t GetTransactionSigOpCost(const CTransaction& tx, const CCoinsViewCache& i const Coin& coin = inputs.AccessCoin(tx.vin[i].prevout); assert(!coin.IsSpent()); const CTxOut &prevout = coin.out; - nSigOps += CountWitnessSigOps(tx.vin[i].scriptSig, prevout.scriptPubKey, &tx.vin[i].scriptWitness, flags); + const CScript& scriptPubKey = StripClaimScriptPrefix(prevout.scriptPubKey); + nSigOps += CountWitnessSigOps(tx.vin[i].scriptSig, scriptPubKey, &tx.vin[i].scriptWitness, flags); } return nSigOps; } diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp index aff46f5d2..3ac82b635 100644 --- a/src/policy/policy.cpp +++ b/src/policy/policy.cpp @@ -202,7 +202,7 @@ bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs) const CTxOut &prev = mapInputs.AccessCoin(tx.vin[i].prevout).out; // get the scriptPubKey corresponding to this input: - CScript prevScript = prev.scriptPubKey; + CScript prevScript = StripClaimScriptPrefix(prev.scriptPubKey); if (prevScript.IsPayToScriptHash()) { std::vector > stack; diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index c2714f9c8..086d2328a 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -169,6 +169,9 @@ static const CRPCConvertParam vRPCConvertParams[] = { "createwallet", 2, "blank"}, { "createwallet", 4, "avoid_reuse"}, { "getnodeaddresses", 0, "count"}, + { "listnameclaims", 0, "includesupports"}, + { "listnameclaims", 1, "activeonly"}, + { "listnameclaims", 2, "minconf"}, { "stop", 0, "wait" }, }; // clang-format on diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index b62e08b8f..fa777da78 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -4,6 +4,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include