[build] Add several util units
Adds the following util units and adds them to libbitcoin_util: - `util/url.cpp` takes `urlDecode` from `httpserver.cpp` - `util/error.cpp` takes `TransactionErrorString` from `node/transaction.cpp` and `AmountHighWarn` and `AmountErrMsg` from `ui_interface.cpp` - `util/fees.cpp` takes `StringForFeeReason` and `FeeModeFromString` from `policy/fees.cpp` - `util/rbf.cpp` takes `SignalsOptInRBF` from `policy/rbf.cpp` - 'util/validation.cpp` takes `FormatStateMessage` and `strMessageMagic` from 'validation.cpp`
This commit is contained in:
parent
99517866b6
commit
91a25d1e71
39 changed files with 282 additions and 143 deletions
|
@ -203,10 +203,15 @@ BITCOIN_CORE_H = \
|
|||
undo.h \
|
||||
util/bip32.h \
|
||||
util/bytevectorhash.h \
|
||||
util/error.h \
|
||||
util/fees.h \
|
||||
util/system.h \
|
||||
util/memory.h \
|
||||
util/moneystr.h \
|
||||
util/rbf.h \
|
||||
util/time.h \
|
||||
util/url.h \
|
||||
util/validation.h \
|
||||
validation.h \
|
||||
validationinterface.h \
|
||||
versionbits.h \
|
||||
|
@ -471,10 +476,15 @@ libbitcoin_util_a_SOURCES = \
|
|||
threadinterrupt.cpp \
|
||||
util/bip32.cpp \
|
||||
util/bytevectorhash.cpp \
|
||||
util/error.cpp \
|
||||
util/fees.cpp \
|
||||
util/system.cpp \
|
||||
util/moneystr.cpp \
|
||||
util/rbf.cpp \
|
||||
util/strencodings.cpp \
|
||||
util/time.cpp \
|
||||
util/url.cpp \
|
||||
util/validation.cpp \
|
||||
$(BITCOIN_CORE_H)
|
||||
|
||||
if GLIBC_BACK_COMPAT
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <script/script.h>
|
||||
#include <script/sign.h>
|
||||
#include <univalue.h>
|
||||
#include <util/rbf.h>
|
||||
#include <util/system.h>
|
||||
#include <util/moneystr.h>
|
||||
#include <util/strencodings.h>
|
||||
|
|
|
@ -655,15 +655,3 @@ void UnregisterHTTPHandler(const std::string &prefix, bool exactMatch)
|
|||
pathHandlers.erase(i);
|
||||
}
|
||||
}
|
||||
|
||||
std::string urlDecode(const std::string &urlEncoded) {
|
||||
std::string res;
|
||||
if (!urlEncoded.empty()) {
|
||||
char *decoded = evhttp_uridecode(urlEncoded.c_str(), false, nullptr);
|
||||
if (decoded) {
|
||||
res = std::string(decoded);
|
||||
free(decoded);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -148,6 +148,4 @@ private:
|
|||
struct event* ev;
|
||||
};
|
||||
|
||||
std::string urlDecode(const std::string &urlEncoded);
|
||||
|
||||
#endif // BITCOIN_HTTPSERVER_H
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include <ui_interface.h>
|
||||
#include <util/system.h>
|
||||
#include <util/moneystr.h>
|
||||
#include <util/validation.h>
|
||||
#include <validationinterface.h>
|
||||
#include <warnings.h>
|
||||
#include <walletinitinterface.h>
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <timedata.h>
|
||||
#include <util/moneystr.h>
|
||||
#include <util/system.h>
|
||||
#include <util/validation.h>
|
||||
#include <validationinterface.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <util/system.h>
|
||||
#include <util/moneystr.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/validation.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
|
|
@ -6,38 +6,13 @@
|
|||
#include <consensus/validation.h>
|
||||
#include <net.h>
|
||||
#include <txmempool.h>
|
||||
#include <util/validation.h>
|
||||
#include <validation.h>
|
||||
#include <validationinterface.h>
|
||||
#include <node/transaction.h>
|
||||
|
||||
#include <future>
|
||||
|
||||
std::string TransactionErrorString(const TransactionError err)
|
||||
{
|
||||
switch (err) {
|
||||
case TransactionError::OK:
|
||||
return "No error";
|
||||
case TransactionError::MISSING_INPUTS:
|
||||
return "Missing inputs";
|
||||
case TransactionError::ALREADY_IN_CHAIN:
|
||||
return "Transaction already in block chain";
|
||||
case TransactionError::P2P_DISABLED:
|
||||
return "Peer-to-peer functionality missing or disabled";
|
||||
case TransactionError::MEMPOOL_REJECTED:
|
||||
return "Transaction rejected by AcceptToMemoryPool";
|
||||
case TransactionError::MEMPOOL_ERROR:
|
||||
return "AcceptToMemoryPool failed";
|
||||
case TransactionError::INVALID_PSBT:
|
||||
return "PSBT is not sane";
|
||||
case TransactionError::PSBT_MISMATCH:
|
||||
return "PSBTs not compatible (different transactions)";
|
||||
case TransactionError::SIGHASH_MISMATCH:
|
||||
return "Specified sighash value does not match existing value";
|
||||
// no default case, so the compiler can warn about missing cases
|
||||
}
|
||||
assert(false);
|
||||
}
|
||||
|
||||
TransactionError BroadcastTransaction(const CTransactionRef tx, uint256& hashTx, std::string& err_string, const CAmount& highfee)
|
||||
{
|
||||
std::promise<void> promise;
|
||||
|
|
|
@ -8,20 +8,7 @@
|
|||
#include <attributes.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <uint256.h>
|
||||
|
||||
enum class TransactionError {
|
||||
OK, //!< No error
|
||||
MISSING_INPUTS,
|
||||
ALREADY_IN_CHAIN,
|
||||
P2P_DISABLED,
|
||||
MEMPOOL_REJECTED,
|
||||
MEMPOOL_ERROR,
|
||||
INVALID_PSBT,
|
||||
PSBT_MISMATCH,
|
||||
SIGHASH_MISMATCH,
|
||||
};
|
||||
|
||||
std::string TransactionErrorString(const TransactionError error);
|
||||
#include <util/error.h>
|
||||
|
||||
/**
|
||||
* Broadcast a transaction
|
||||
|
|
|
@ -27,40 +27,6 @@ std::string StringForFeeEstimateHorizon(FeeEstimateHorizon horizon) {
|
|||
return horizon_string->second;
|
||||
}
|
||||
|
||||
std::string StringForFeeReason(FeeReason reason) {
|
||||
static const std::map<FeeReason, std::string> fee_reason_strings = {
|
||||
{FeeReason::NONE, "None"},
|
||||
{FeeReason::HALF_ESTIMATE, "Half Target 60% Threshold"},
|
||||
{FeeReason::FULL_ESTIMATE, "Target 85% Threshold"},
|
||||
{FeeReason::DOUBLE_ESTIMATE, "Double Target 95% Threshold"},
|
||||
{FeeReason::CONSERVATIVE, "Conservative Double Target longer horizon"},
|
||||
{FeeReason::MEMPOOL_MIN, "Mempool Min Fee"},
|
||||
{FeeReason::PAYTXFEE, "PayTxFee set"},
|
||||
{FeeReason::FALLBACK, "Fallback fee"},
|
||||
{FeeReason::REQUIRED, "Minimum Required Fee"},
|
||||
{FeeReason::MAXTXFEE, "MaxTxFee limit"}
|
||||
};
|
||||
auto reason_string = fee_reason_strings.find(reason);
|
||||
|
||||
if (reason_string == fee_reason_strings.end()) return "Unknown";
|
||||
|
||||
return reason_string->second;
|
||||
}
|
||||
|
||||
bool FeeModeFromString(const std::string& mode_string, FeeEstimateMode& fee_estimate_mode) {
|
||||
static const std::map<std::string, FeeEstimateMode> fee_modes = {
|
||||
{"UNSET", FeeEstimateMode::UNSET},
|
||||
{"ECONOMICAL", FeeEstimateMode::ECONOMICAL},
|
||||
{"CONSERVATIVE", FeeEstimateMode::CONSERVATIVE},
|
||||
};
|
||||
auto mode = fee_modes.find(mode_string);
|
||||
|
||||
if (mode == fee_modes.end()) return false;
|
||||
|
||||
fee_estimate_mode = mode->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* We will instantiate an instance of this class to track transactions that were
|
||||
* included in a block. We will lump transactions into a bucket according to their
|
||||
|
|
|
@ -46,8 +46,6 @@ enum class FeeReason {
|
|||
MAXTXFEE,
|
||||
};
|
||||
|
||||
std::string StringForFeeReason(FeeReason reason);
|
||||
|
||||
/* Used to determine type of fee estimation requested */
|
||||
enum class FeeEstimateMode {
|
||||
UNSET, //!< Use default settings based on other criteria
|
||||
|
@ -55,8 +53,6 @@ enum class FeeEstimateMode {
|
|||
CONSERVATIVE, //!< Force estimateSmartFee to use conservative estimates
|
||||
};
|
||||
|
||||
bool FeeModeFromString(const std::string& mode_string, FeeEstimateMode& fee_estimate_mode);
|
||||
|
||||
/* Used to return detailed information about a feerate bucket */
|
||||
struct EstimatorBucket
|
||||
{
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <policy/policy.h>
|
||||
|
||||
#include <consensus/validation.h>
|
||||
#include <validation.h>
|
||||
#include <coins.h>
|
||||
#include <policy/settings.h>
|
||||
#include <tinyformat.h>
|
||||
|
|
|
@ -3,16 +3,7 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <policy/rbf.h>
|
||||
|
||||
bool SignalsOptInRBF(const CTransaction &tx)
|
||||
{
|
||||
for (const CTxIn &txin : tx.vin) {
|
||||
if (txin.nSequence <= MAX_BIP125_RBF_SEQUENCE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#include <util/rbf.h>
|
||||
|
||||
RBFTransactionState IsRBFOptIn(const CTransaction& tx, const CTxMemPool& pool)
|
||||
{
|
||||
|
|
|
@ -7,18 +7,12 @@
|
|||
|
||||
#include <txmempool.h>
|
||||
|
||||
static const uint32_t MAX_BIP125_RBF_SEQUENCE = 0xfffffffd;
|
||||
|
||||
enum class RBFTransactionState {
|
||||
UNKNOWN,
|
||||
REPLACEABLE_BIP125,
|
||||
FINAL
|
||||
};
|
||||
|
||||
// Check whether the sequence numbers on this transaction are signaling
|
||||
// opt-in to replace-by-fee, according to BIP 125
|
||||
bool SignalsOptInRBF(const CTransaction &tx);
|
||||
|
||||
// Determine whether an in-mempool transaction is signaling opt-in to RBF
|
||||
// according to BIP 125
|
||||
// This involves checking sequence numbers of the transaction, as well
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <qt/walletmodel.h>
|
||||
|
||||
#include <key_io.h>
|
||||
#include <validation.h> // For strMessageMagic
|
||||
#include <util/validation.h> // For strMessageMagic
|
||||
#include <wallet/wallet.h>
|
||||
|
||||
#include <string>
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <txmempool.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/system.h>
|
||||
#include <util/validation.h>
|
||||
#include <validation.h>
|
||||
#include <validationinterface.h>
|
||||
#include <versionbitsinfo.h>
|
||||
|
|
|
@ -21,8 +21,10 @@
|
|||
#include <rpc/util.h>
|
||||
#include <shutdown.h>
|
||||
#include <txmempool.h>
|
||||
#include <util/fees.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/system.h>
|
||||
#include <util/validation.h>
|
||||
#include <validation.h>
|
||||
#include <validationinterface.h>
|
||||
#include <versionbitsinfo.h>
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <timedata.h>
|
||||
#include <util/system.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/validation.h>
|
||||
#include <warnings.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
#include <key_io.h>
|
||||
#include <keystore.h>
|
||||
#include <policy/policy.h>
|
||||
#include <policy/rbf.h>
|
||||
#include <primitives/transaction.h>
|
||||
#include <rpc/protocol.h>
|
||||
#include <rpc/util.h>
|
||||
#include <tinyformat.h>
|
||||
#include <univalue.h>
|
||||
#include <util/rbf.h>
|
||||
#include <util/strencodings.h>
|
||||
|
||||
CMutableTransaction ConstructTransaction(const UniValue& inputs_in, const UniValue& outputs_in, const UniValue& locktime, const UniValue& rbf)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <script/sigcache.h>
|
||||
#include <streams.h>
|
||||
#include <ui_interface.h>
|
||||
#include <util/validation.h>
|
||||
#include <validation.h>
|
||||
|
||||
const std::function<std::string(const char*)> G_TRANSLATION_FUN = nullptr;
|
||||
|
|
|
@ -69,13 +69,3 @@ void InitWarning(const std::string& str)
|
|||
{
|
||||
uiInterface.ThreadSafeMessageBox(str, "", CClientUIInterface::MSG_WARNING);
|
||||
}
|
||||
|
||||
std::string AmountHighWarn(const std::string& optname)
|
||||
{
|
||||
return strprintf(_("%s is set very high!"), optname);
|
||||
}
|
||||
|
||||
std::string AmountErrMsg(const char* const optname, const std::string& strValue)
|
||||
{
|
||||
return strprintf(_("Invalid amount for -%s=<amount>: '%s'"), optname, strValue);
|
||||
}
|
||||
|
|
|
@ -129,10 +129,6 @@ void InitWarning(const std::string& str);
|
|||
/** Show error message **/
|
||||
bool InitError(const std::string& str);
|
||||
|
||||
std::string AmountHighWarn(const std::string& optname);
|
||||
|
||||
std::string AmountErrMsg(const char* const optname, const std::string& strValue);
|
||||
|
||||
extern CClientUIInterface uiInterface;
|
||||
|
||||
#endif // BITCOIN_UI_INTERFACE_H
|
||||
|
|
43
src/util/error.cpp
Normal file
43
src/util/error.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
// Copyright (c) 2010-2018 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <util/error.h>
|
||||
|
||||
#include <util/system.h>
|
||||
|
||||
std::string TransactionErrorString(const TransactionError err)
|
||||
{
|
||||
switch (err) {
|
||||
case TransactionError::OK:
|
||||
return "No error";
|
||||
case TransactionError::MISSING_INPUTS:
|
||||
return "Missing inputs";
|
||||
case TransactionError::ALREADY_IN_CHAIN:
|
||||
return "Transaction already in block chain";
|
||||
case TransactionError::P2P_DISABLED:
|
||||
return "Peer-to-peer functionality missing or disabled";
|
||||
case TransactionError::MEMPOOL_REJECTED:
|
||||
return "Transaction rejected by AcceptToMemoryPool";
|
||||
case TransactionError::MEMPOOL_ERROR:
|
||||
return "AcceptToMemoryPool failed";
|
||||
case TransactionError::INVALID_PSBT:
|
||||
return "PSBT is not sane";
|
||||
case TransactionError::PSBT_MISMATCH:
|
||||
return "PSBTs not compatible (different transactions)";
|
||||
case TransactionError::SIGHASH_MISMATCH:
|
||||
return "Specified sighash value does not match existing value";
|
||||
// no default case, so the compiler can warn about missing cases
|
||||
}
|
||||
assert(false);
|
||||
}
|
||||
|
||||
std::string AmountHighWarn(const std::string& optname)
|
||||
{
|
||||
return strprintf(_("%s is set very high!"), optname);
|
||||
}
|
||||
|
||||
std::string AmountErrMsg(const char* const optname, const std::string& strValue)
|
||||
{
|
||||
return strprintf(_("Invalid amount for -%s=<amount>: '%s'"), optname, strValue);
|
||||
}
|
38
src/util/error.h
Normal file
38
src/util/error.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
// Copyright (c) 2010-2018 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_UTIL_ERROR_H
|
||||
#define BITCOIN_UTIL_ERROR_H
|
||||
|
||||
/**
|
||||
* util/error.h is a common place for definitions of simple error types and
|
||||
* string functions. Types and functions defined here should not require any
|
||||
* outside dependencies.
|
||||
*
|
||||
* Error types defined here can be used in different parts of the bitcoin
|
||||
* codebase, to avoid the need to write boilerplate code catching and
|
||||
* translating errors passed across wallet/node/rpc/gui code boundaries.
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
|
||||
enum class TransactionError {
|
||||
OK, //!< No error
|
||||
MISSING_INPUTS,
|
||||
ALREADY_IN_CHAIN,
|
||||
P2P_DISABLED,
|
||||
MEMPOOL_REJECTED,
|
||||
MEMPOOL_ERROR,
|
||||
INVALID_PSBT,
|
||||
PSBT_MISMATCH,
|
||||
SIGHASH_MISMATCH,
|
||||
};
|
||||
|
||||
std::string TransactionErrorString(const TransactionError error);
|
||||
|
||||
std::string AmountHighWarn(const std::string& optname);
|
||||
|
||||
std::string AmountErrMsg(const char* const optname, const std::string& strValue);
|
||||
|
||||
#endif // BITCOIN_UTIL_ERROR_H
|
42
src/util/fees.cpp
Normal file
42
src/util/fees.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2018 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <policy/fees.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
std::string StringForFeeReason(FeeReason reason) {
|
||||
static const std::map<FeeReason, std::string> fee_reason_strings = {
|
||||
{FeeReason::NONE, "None"},
|
||||
{FeeReason::HALF_ESTIMATE, "Half Target 60% Threshold"},
|
||||
{FeeReason::FULL_ESTIMATE, "Target 85% Threshold"},
|
||||
{FeeReason::DOUBLE_ESTIMATE, "Double Target 95% Threshold"},
|
||||
{FeeReason::CONSERVATIVE, "Conservative Double Target longer horizon"},
|
||||
{FeeReason::MEMPOOL_MIN, "Mempool Min Fee"},
|
||||
{FeeReason::PAYTXFEE, "PayTxFee set"},
|
||||
{FeeReason::FALLBACK, "Fallback fee"},
|
||||
{FeeReason::REQUIRED, "Minimum Required Fee"},
|
||||
{FeeReason::MAXTXFEE, "MaxTxFee limit"}
|
||||
};
|
||||
auto reason_string = fee_reason_strings.find(reason);
|
||||
|
||||
if (reason_string == fee_reason_strings.end()) return "Unknown";
|
||||
|
||||
return reason_string->second;
|
||||
}
|
||||
|
||||
bool FeeModeFromString(const std::string& mode_string, FeeEstimateMode& fee_estimate_mode) {
|
||||
static const std::map<std::string, FeeEstimateMode> fee_modes = {
|
||||
{"UNSET", FeeEstimateMode::UNSET},
|
||||
{"ECONOMICAL", FeeEstimateMode::ECONOMICAL},
|
||||
{"CONSERVATIVE", FeeEstimateMode::CONSERVATIVE},
|
||||
};
|
||||
auto mode = fee_modes.find(mode_string);
|
||||
|
||||
if (mode == fee_modes.end()) return false;
|
||||
|
||||
fee_estimate_mode = mode->second;
|
||||
return true;
|
||||
}
|
16
src/util/fees.h
Normal file
16
src/util/fees.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2018 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#ifndef BITCOIN_UTIL_FEES_H
|
||||
#define BITCOIN_UTIL_FEES_H
|
||||
|
||||
#include <string>
|
||||
|
||||
enum class FeeEstimateMode;
|
||||
enum class FeeReason;
|
||||
|
||||
bool FeeModeFromString(const std::string& mode_string, FeeEstimateMode& fee_estimate_mode);
|
||||
std::string StringForFeeReason(FeeReason reason);
|
||||
|
||||
#endif // BITCOIN_UTIL_FEES_H
|
17
src/util/rbf.cpp
Normal file
17
src/util/rbf.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
// Copyright (c) 2016-2018 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <util/rbf.h>
|
||||
|
||||
#include <primitives/transaction.h>
|
||||
|
||||
bool SignalsOptInRBF(const CTransaction &tx)
|
||||
{
|
||||
for (const CTxIn &txin : tx.vin) {
|
||||
if (txin.nSequence <= MAX_BIP125_RBF_SEQUENCE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
18
src/util/rbf.h
Normal file
18
src/util/rbf.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Copyright (c) 2016-2018 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_UTIL_RBF_H
|
||||
#define BITCOIN_UTIL_RBF_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
class CTransaction;
|
||||
|
||||
static const uint32_t MAX_BIP125_RBF_SEQUENCE = 0xfffffffd;
|
||||
|
||||
// Check whether the sequence numbers on this transaction are signaling
|
||||
// opt-in to replace-by-fee, according to BIP 125
|
||||
bool SignalsOptInRBF(const CTransaction &tx);
|
||||
|
||||
#endif // BITCOIN_UTIL_RBF_H
|
21
src/util/url.cpp
Normal file
21
src/util/url.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
// Copyright (c) 2015-2018 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <util/url.h>
|
||||
|
||||
#include <event2/http.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
|
||||
std::string urlDecode(const std::string &urlEncoded) {
|
||||
std::string res;
|
||||
if (!urlEncoded.empty()) {
|
||||
char *decoded = evhttp_uridecode(urlEncoded.c_str(), false, nullptr);
|
||||
if (decoded) {
|
||||
res = std::string(decoded);
|
||||
free(decoded);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
12
src/util/url.h
Normal file
12
src/util/url.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
// Copyright (c) 2015-2018 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_UTIL_URL_H
|
||||
#define BITCOIN_UTIL_URL_H
|
||||
|
||||
#include <string>
|
||||
|
||||
std::string urlDecode(const std::string &urlEncoded);
|
||||
|
||||
#endif // BITCOIN_UTIL_URL_H
|
20
src/util/validation.cpp
Normal file
20
src/util/validation.cpp
Normal file
|
@ -0,0 +1,20 @@
|
|||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2019 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <util/validation.h>
|
||||
|
||||
#include <consensus/validation.h>
|
||||
#include <tinyformat.h>
|
||||
|
||||
/** Convert CValidationState to a human-readable message for logging */
|
||||
std::string FormatStateMessage(const CValidationState &state)
|
||||
{
|
||||
return strprintf("%s%s (code %i)",
|
||||
state.GetRejectReason(),
|
||||
state.GetDebugMessage().empty() ? "" : ", "+state.GetDebugMessage(),
|
||||
state.GetRejectCode());
|
||||
}
|
||||
|
||||
const std::string strMessageMagic = "Bitcoin Signed Message:\n";
|
18
src/util/validation.h
Normal file
18
src/util/validation.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2019 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#ifndef BITCOIN_UTIL_VALIDATION_H
|
||||
#define BITCOIN_UTIL_VALIDATION_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class CValidationState;
|
||||
|
||||
/** Convert CValidationState to a human-readable message for logging */
|
||||
std::string FormatStateMessage(const CValidationState &state);
|
||||
|
||||
extern const std::string strMessageMagic;
|
||||
|
||||
#endif // BITCOIN_UTIL_VALIDATION_H
|
|
@ -39,8 +39,10 @@
|
|||
#include <ui_interface.h>
|
||||
#include <undo.h>
|
||||
#include <util/moneystr.h>
|
||||
#include <util/rbf.h>
|
||||
#include <util/strencodings.h>
|
||||
#include <util/system.h>
|
||||
#include <util/validation.h>
|
||||
#include <validationinterface.h>
|
||||
#include <warnings.h>
|
||||
|
||||
|
@ -259,8 +261,6 @@ std::atomic_bool g_is_mempool_loaded{false};
|
|||
/** Constant stuff for coinbase transactions we create: */
|
||||
CScript COINBASE_FLAGS;
|
||||
|
||||
const std::string strMessageMagic = "Bitcoin Signed Message:\n";
|
||||
|
||||
// Internal stuff
|
||||
namespace {
|
||||
CBlockIndex *&pindexBestInvalid = g_chainstate.pindexBestInvalid;
|
||||
|
@ -462,15 +462,6 @@ static void LimitMempoolSize(CTxMemPool& pool, size_t limit, unsigned long age)
|
|||
pcoinsTip->Uncache(removed);
|
||||
}
|
||||
|
||||
/** Convert CValidationState to a human-readable message for logging */
|
||||
std::string FormatStateMessage(const CValidationState &state)
|
||||
{
|
||||
return strprintf("%s%s (code %i)",
|
||||
state.GetRejectReason(),
|
||||
state.GetDebugMessage().empty() ? "" : ", "+state.GetDebugMessage(),
|
||||
state.GetRejectCode());
|
||||
}
|
||||
|
||||
static bool IsCurrentForFeeEstimation() EXCLUSIVE_LOCKS_REQUIRED(cs_main)
|
||||
{
|
||||
AssertLockHeld(cs_main);
|
||||
|
|
|
@ -150,7 +150,6 @@ extern CTxMemPool mempool;
|
|||
extern std::atomic_bool g_is_mempool_loaded;
|
||||
typedef std::unordered_map<uint256, CBlockIndex*, BlockHasher> BlockMap;
|
||||
extern BlockMap& mapBlockIndex GUARDED_BY(cs_main);
|
||||
extern const std::string strMessageMagic;
|
||||
extern Mutex g_best_block_mutex;
|
||||
extern std::condition_variable g_best_block_cv;
|
||||
extern uint256 g_best_block;
|
||||
|
@ -298,9 +297,6 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
|||
bool* pfMissingInputs, std::list<CTransactionRef>* plTxnReplaced,
|
||||
bool bypass_limits, const CAmount nAbsurdFee, bool test_accept=false) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||
|
||||
/** Convert CValidationState to a human-readable message for logging */
|
||||
std::string FormatStateMessage(const CValidationState &state);
|
||||
|
||||
/** Get the BIP9 state for a given deployment at the current tip. */
|
||||
ThresholdState VersionBitsTipState(const Consensus::Params& params, Consensus::DeploymentPos pos);
|
||||
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
#include <validation.h> //for mempool access
|
||||
#include <txmempool.h>
|
||||
#include <util/moneystr.h>
|
||||
#include <util/rbf.h>
|
||||
#include <util/system.h>
|
||||
#include <util/validation.h>
|
||||
#include <net.h>
|
||||
|
||||
//! Check whether transaction has descendant in wallet or mempool, or has been
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <net.h>
|
||||
#include <scheduler.h>
|
||||
#include <outputtype.h>
|
||||
#include <util/error.h>
|
||||
#include <util/system.h>
|
||||
#include <util/moneystr.h>
|
||||
#include <validation.h>
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
#include <chain.h>
|
||||
#include <consensus/validation.h>
|
||||
#include <core_io.h>
|
||||
#include <httpserver.h>
|
||||
#include <init.h>
|
||||
#include <interfaces/chain.h>
|
||||
#include <validation.h>
|
||||
|
@ -27,8 +26,11 @@
|
|||
#include <shutdown.h>
|
||||
#include <timedata.h>
|
||||
#include <util/bip32.h>
|
||||
#include <util/fees.h>
|
||||
#include <util/system.h>
|
||||
#include <util/moneystr.h>
|
||||
#include <util/url.h>
|
||||
#include <util/validation.h>
|
||||
#include <wallet/coincontrol.h>
|
||||
#include <wallet/feebumper.h>
|
||||
#include <wallet/psbtwallet.h>
|
||||
|
|
|
@ -29,7 +29,11 @@
|
|||
#include <timedata.h>
|
||||
#include <txmempool.h>
|
||||
#include <util/bip32.h>
|
||||
#include <util/error.h>
|
||||
#include <util/fees.h>
|
||||
#include <util/moneystr.h>
|
||||
#include <util/rbf.h>
|
||||
#include <util/validation.h>
|
||||
#include <wallet/fees.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
|
|
@ -30,8 +30,7 @@ EXPECTED_CIRCULAR_DEPENDENCIES=(
|
|||
"wallet/coincontrol -> wallet/wallet -> wallet/coincontrol"
|
||||
"wallet/fees -> wallet/wallet -> wallet/fees"
|
||||
"wallet/wallet -> wallet/walletdb -> wallet/wallet"
|
||||
"policy/fees -> policy/policy -> validation -> policy/fees"
|
||||
"policy/policy -> validation -> policy/policy"
|
||||
"policy/fees -> txmempool -> validation -> policy/fees"
|
||||
"policy/rbf -> txmempool -> validation -> policy/rbf"
|
||||
"qt/addressbookpage -> qt/bitcoingui -> qt/walletview -> qt/addressbookpage"
|
||||
"qt/guiutil -> qt/walletmodel -> qt/optionsmodel -> qt/guiutil"
|
||||
|
|
Loading…
Add table
Reference in a new issue