From d18516e391094a523878bbecbad27c067f705c02 Mon Sep 17 00:00:00 2001 From: timemarkovqtum Date: Mon, 4 Mar 2024 16:27:08 +0100 Subject: [PATCH] Port rpc node --- src/Makefile.am | 6 + src/key_io.cpp | 38 +++ src/key_io.h | 1 + src/qtum/qtumstate.cpp | 2 +- src/qtum/storageresults.cpp | 1 + src/qtum/storageresults.h | 2 +- src/rpc/node.cpp | 554 +++++++++++++++++++++++++++++++++++- src/txmempool.h | 85 +++++- src/validation.cpp | 53 ++++ src/validation.h | 36 +++ 10 files changed, 773 insertions(+), 5 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 6e41d3693c..b1fce17fc2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -383,7 +383,10 @@ BITCOIN_CORE_H = \ zmq/zmqrpc.h \ zmq/zmqutil.h \ qtum/posutils.h \ + qtum/qtumstate.h \ qtum/qtumtransaction.h \ + qtum/qtumDGP.h \ + qtum/storageresults.h \ qtum/qtumutils.h \ qtum/qtumtoken.h \ qtum/qtumledger.h \ @@ -489,6 +492,8 @@ libbitcoin_node_a_SOURCES = \ validation.cpp \ validationinterface.cpp \ versionbits.cpp \ + qtum/qtumstate.cpp \ + qtum/storageresults.cpp \ qtum/qtumledger.cpp \ $(BITCOIN_CORE_H) @@ -733,6 +738,7 @@ libbitcoin_common_a_SOURCES = \ script/solver.cpp \ warnings.cpp \ qtum/qtumutils.cpp \ + qtum/qtumDGP.cpp \ qtum/qtumtoken.cpp \ qtum/delegationutils.cpp \ util/contractabi.cpp \ diff --git a/src/key_io.cpp b/src/key_io.cpp index 5bcbb8a069..5b0b6e009a 100644 --- a/src/key_io.cpp +++ b/src/key_io.cpp @@ -310,3 +310,41 @@ bool IsValidDestinationString(const std::string& str) { return IsValidDestinationString(str, Params()); } +bool DecodeIndexKey(const std::string &str, uint256 &hashBytes, int &type) +{ + CTxDestination dest = DecodeDestination(str); + if (IsValidDestination(dest)) + { + if(std::holds_alternative(dest)) + { + PKHash keyID = std::get(dest); + memcpy(hashBytes.data(), &keyID, 20); + type = 1; + return true; + } + + if(std::holds_alternative(dest)) + { + ScriptHash scriptID = std::get(dest); + memcpy(hashBytes.data(), &scriptID, 20); + type = 2; + return true; + } + + if (std::holds_alternative(dest)) { + WitnessV0ScriptHash witnessV0ScriptID = std::get(dest); + memcpy(hashBytes.data(), &witnessV0ScriptID, 32); + type = 3; + return true; + } + + if (std::holds_alternative(dest)) { + const WitnessV0KeyHash witnessV0KeyID = std::get(dest); + memcpy(hashBytes.data(), &witnessV0KeyID, 20); + type = 4; + return true; + } + } + + return false; +} diff --git a/src/key_io.h b/src/key_io.h index e387273e54..3156ad6a9b 100644 --- a/src/key_io.h +++ b/src/key_io.h @@ -26,5 +26,6 @@ CTxDestination DecodeDestination(const std::string& str); CTxDestination DecodeDestination(const std::string& str, std::string& error_msg, std::vector* error_locations = nullptr); bool IsValidDestinationString(const std::string& str); bool IsValidDestinationString(const std::string& str, const CChainParams& params); +bool DecodeIndexKey(const std::string& str, uint256& hashBytes, int& type); #endif // BITCOIN_KEY_IO_H diff --git a/src/qtum/qtumstate.cpp b/src/qtum/qtumstate.cpp index c352a9764b..537c34b5a5 100644 --- a/src/qtum/qtumstate.cpp +++ b/src/qtum/qtumstate.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include