diff --git a/src/core_write.cpp b/src/core_write.cpp index 34a9d2360..ca89c6ca1 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -15,6 +15,7 @@ #include #include #include +#include UniValue ValueFromAmount(const CAmount& amount) { @@ -147,12 +148,20 @@ void ScriptToUniv(const CScript& script, UniValue& out, bool include_address) out.pushKV("hex", HexStr(script.begin(), script.end())); std::vector> solns; - txnouttype type; - Solver(script, type, solns); - out.pushKV("type", GetTxnOutputType(type)); + txnouttype type; int claimOp; + auto stripped = StripClaimScriptPrefix(script, claimOp); + Solver(stripped, type, solns); + if (claimOp >= 0) { + out.pushKV("isclaim", UniValue(claimOp == OP_CLAIM_NAME || claimOp == OP_UPDATE_CLAIM)); + out.pushKV("issupport", UniValue(claimOp == OP_SUPPORT_CLAIM)); + out.pushKV("subtype", GetTxnOutputType(type)); + out.pushKV("type", GetTxnOutputType(TX_NONSTANDARD)); // trying to keep backwards compatibility + } + else + out.pushKV("type", GetTxnOutputType(type)); // trying to keep backwards compatibility CTxDestination address; - if (include_address && ExtractDestination(script, address)) { + if (include_address && ExtractDestination(stripped, address)) { out.pushKV("address", EncodeDestination(address)); } } @@ -168,19 +177,27 @@ void ScriptPubKeyToUniv(const CScript& scriptPubKey, if (fIncludeHex) out.pushKV("hex", HexStr(scriptPubKey.begin(), scriptPubKey.end())); - if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired)) { + int claimOp; + auto stripped = StripClaimScriptPrefix(scriptPubKey, claimOp); + auto extracted = ExtractDestinations(stripped, type, addresses, nRequired); + + if (claimOp >= 0) { + out.pushKV("isclaim", UniValue(claimOp == OP_CLAIM_NAME || claimOp == OP_UPDATE_CLAIM)); + out.pushKV("issupport", UniValue(claimOp == OP_SUPPORT_CLAIM)); + out.pushKV("subtype", GetTxnOutputType(type)); + out.pushKV("type", GetTxnOutputType(TX_NONSTANDARD)); + } + else out.pushKV("type", GetTxnOutputType(type)); - return; - } - out.pushKV("reqSigs", nRequired); - out.pushKV("type", GetTxnOutputType(type)); - - UniValue a(UniValue::VARR); - for (const CTxDestination& addr : addresses) { - a.push_back(EncodeDestination(addr)); + if (extracted) { + out.pushKV("reqSigs", nRequired); + UniValue a(UniValue::VARR); + for (const CTxDestination &addr : addresses) { + a.push_back(EncodeDestination(addr)); + } + out.pushKV("addresses", a); } - out.pushKV("addresses", a); } void TxToUniv(const CTransaction& tx, const uint256& hashBlock, UniValue& entry, bool include_hex, int serialize_flags) diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp index d9f82da39..25b477633 100644 --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -193,6 +193,7 @@ bool CDBWrapper::WriteBatch(CDBBatch& batch, bool fSync) if (log_memory) { mem_before = DynamicMemoryUsage() / 1024.0 / 1024; } + assert(pdb); leveldb::Status status = pdb->Write(fSync ? syncoptions : writeoptions, &batch.batch); dbwrapper_private::HandleError(status); if (log_memory) { diff --git a/src/dbwrapper.h b/src/dbwrapper.h index fa0e38026..a73aad349 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -151,7 +151,7 @@ public: * with a zero'd byte array. */ CDBWrapper(const fs::path& path, size_t nCacheSize, bool fMemory = false, bool fWipe = false, bool obfuscate = false); - ~CDBWrapper(); + virtual ~CDBWrapper(); CDBWrapper(const CDBWrapper&) = delete; /* CDBWrapper& operator=(const CDBWrapper&) = delete; */ @@ -159,6 +159,7 @@ public: template bool Read(const K& key, V& value) const { + assert(ssKey.empty()); ssKey << key; leveldb::Slice slKey(ssKey.data(), ssKey.size()); diff --git a/src/index/base.h b/src/index/base.h index 04ee6e6cc..146694899 100644 --- a/src/index/base.h +++ b/src/index/base.h @@ -28,6 +28,8 @@ protected: DB(const fs::path& path, size_t n_cache_size, bool f_memory = false, bool f_wipe = false, bool f_obfuscate = false); + ~DB() override {} + /// Read block locator of the chain that the txindex is in sync with. bool ReadBestBlock(CBlockLocator& locator) const; diff --git a/src/index/txindex.cpp b/src/index/txindex.cpp index 0b7f520b4..1e9749322 100644 --- a/src/index/txindex.cpp +++ b/src/index/txindex.cpp @@ -29,6 +29,7 @@ class TxIndex::DB : public BaseIndex::DB { public: explicit DB(size_t n_cache_size, bool f_memory = false, bool f_wipe = false); + ~DB() override {} /// Read the disk location of the transaction data with the given hash. Returns false if the /// transaction hash is not indexed. diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp index ccc9d141f..98d853849 100644 --- a/src/policy/policy.cpp +++ b/src/policy/policy.cpp @@ -115,7 +115,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason) unsigned int nDataOut = 0; txnouttype whichType; for (const CTxOut& txout : tx.vout) { - if (!::IsStandard(txout.scriptPubKey, whichType)) { + if (!::IsStandard(StripClaimScriptPrefix(txout.scriptPubKey), whichType)) { reason = "scriptpubkey"; return false; } diff --git a/src/policy/policy.h b/src/policy/policy.h index 3d47ac126..d8dfc29cd 100644 --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -45,7 +45,7 @@ static const unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE = 3600; * standard and should be done with care and ideally rarely. It makes sense to * only increase the dust limit after prior releases were already not creating * outputs below the new threshold */ -static const unsigned int DUST_RELAY_TX_FEE = 3000; +static const unsigned int DUST_RELAY_TX_FEE = 1000; /** * Standard script verification flags that standard transactions will comply * with. However scripts violating these flags may still be present in valid diff --git a/src/rpc/claimtrie.cpp b/src/rpc/claimtrie.cpp index 12e9b5e74..a3af23a20 100644 --- a/src/rpc/claimtrie.cpp +++ b/src/rpc/claimtrie.cpp @@ -111,7 +111,7 @@ std::string escapeNonUtf8(const std::string& name) static bool extractValue(const CScript& scriptPubKey, std::string& sValue) { int op; - std::vector > vvchParams; + std::vector> vvchParams; if (!DecodeClaimScript(scriptPubKey, op, vvchParams)) return false; diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index b5cc90eb0..68c87e2d9 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -549,14 +549,15 @@ static UniValue decoderawtransaction(const JSONRPCRequest& request) " ],\n" " \"vout\" : [ (array of json objects)\n" " {\n" - " \"value\" : x.xxx, (numeric) The value in " + CURRENCY_UNIT + "\n" - " \"n\" : n, (numeric) index\n" - " \"scriptPubKey\" : { (json object)\n" - " \"asm\" : \"asm\", (string) the asm\n" - " \"hex\" : \"hex\", (string) the hex\n" - " \"reqSigs\" : n, (numeric) The required sigs\n" - " \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n" - " \"addresses\" : [ (json array of string)\n" + " \"value\" : x.xxx, (numeric) The value in " + CURRENCY_UNIT + "\n" + " \"n\" : n, (numeric) index\n" + " \"scriptPubKey\" : { (json object)\n" + " \"asm\" : \"asm\", (string) the asm\n" + " \"hex\" : \"hex\", (string) the hex\n" + " \"reqSigs\" : n, (numeric) The required sigs\n" + " \"subtype\" : \"pubkeyhash\", (numeric) For claims and supports, this represents the type of suffix\n" + " \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n" + " \"addresses\" : [ (json array of string)\n" " \"12tvKAXCxZjSmdNbao16dKXC8tRWfcF5oc\" (string) lbry address\n" " ,...\n" " ]\n" diff --git a/src/script/sign.cpp b/src/script/sign.cpp index a95a8609b..b6fb4a2ef 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -6,6 +6,7 @@ #include