Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ task:
FILE_ENV: "./ci/test/00_setup_env_native_nowallet.sh"

task:
name: 'macOS 10.12 [gui, no tests] [bionic]'
name: 'macOS 10.12 [gui, no tests] [focal]'
<< : *GLOBAL_TASK_TEMPLATE
container:
image: ubuntu:focal
Expand Down
2 changes: 1 addition & 1 deletion ci/test/00_setup_env_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export LC_ALL=C.UTF-8

export CONTAINER_NAME=ci_macos_cross
export HOST=x86_64-apple-darwin
export PACKAGES="cmake libcap-dev libz-dev libbz2-dev python3-setuptools"
export PACKAGES="cmake libcap-dev libz-dev libbz2-dev libtinfo5 python3-setuptools"
export XCODE_VERSION=12.2
export XCODE_BUILD_ID=12B45b
export RUN_UNIT_TESTS=false
Expand Down
11 changes: 8 additions & 3 deletions contrib/seeds/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ that the list is as expected.

## Dependencies

Ubuntu:
Ubuntu, Debian:

sudo apt-get install python3-pip
pip3 install dnspython
sudo apt-get install python3-dnspython

and/or for other operating systems:

pip3 install dnspython3

See https://dnspython.readthedocs.io/en/latest/installation.html for more information.
1 change: 1 addition & 0 deletions doc/build-openbsd.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pkg_add autoconf # (select highest version, e.g. 2.69)
pkg_add automake # (select highest version, e.g. 1.15)
pkg_add python # (select highest version, e.g. 3.8)
pkg_add gmp
pkg_add bash
pkg_add boost

git clone https://github.com/dashpay/dash.git
Expand Down
2 changes: 1 addition & 1 deletion doc/descriptors.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Output descriptors currently support:
- `combo(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)` describes any P2PK, P2PKH with the specified public key.
- `multi(1,022f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4,025cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc)` describes a bare *1-of-2* multisig with the specified public key.
- `sortedmulti(1,022f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4,025cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc)` describes a bare *1-of-2* multisig with keys sorted lexicographically in the resulting redeemScript.
- `pkh(xpub68Gmy5EdvgibQVfPdqkBBCHxA5htiqg55crXYuXoQRKfDBFA1WEjWgP6LHhwBZeNK1VTsfTFUHCdrfp1bgwQ9xv5ski8PX9rL2dZXvgGDnw/1'/2)` describes a P2PKH output with child key *1'/2* of the specified xpub.
- `pkh(xpub68Gmy5EdvgibQVfPdqkBBCHxA5htiqg55crXYuXoQRKfDBFA1WEjWgP6LHhwBZeNK1VTsfTFUHCdrfp1bgwQ9xv5ski8PX9rL2dZXvgGDnw/1/2)` describes a P2PKH output with child key *1/2* of the specified xpub.
- `pkh([d34db33f/44'/0'/0']xpub6ERApfZwUNrhLCkDtcHTcxd75RbzS1ed54G1LkBUHQVHQKqhMkhgbmJbZRkrgZw4koxb5JaHWkY4ALHY2grBGRjaDMzQLcgJvLJuZZvRcEL/1/*)` describes a set of P2PKH outputs, but additionally specifies that the specified xpub is a child of a master with fingerprint `d34db33f`, and derived using path `44'/0'/0'`.

## Reference
Expand Down
1 change: 0 additions & 1 deletion doc/tor.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ versions of Tor see [Section 4](#4-automatically-listen-on-tor).*

HiddenServiceDir /var/lib/tor/dashcore-service/
HiddenServicePort 9999 127.0.0.1:9996
HiddenServicePort 19999 127.0.0.1:19996

The directory can be different of course, but virtual port numbers should be equal to
your dashd's P2P listen port (9999 by default), and target addresses and ports
Expand Down
2 changes: 1 addition & 1 deletion src/bench/duplicate_inputs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static void DuplicateInputs(benchmark::Bench& bench)
naughtyTx.vout[0].nValue = 0;
naughtyTx.vout[0].scriptPubKey = SCRIPT_PUB;

uint64_t n_inputs = (((MaxBlockSize() / ::GetSerializeSize(CTransaction(), PROTOCOL_VERSION)) - (CTransaction(coinbaseTx).GetTotalSize() + CTransaction(naughtyTx).GetTotalSize())) / 41) - 100;
uint64_t n_inputs = (((MaxBlockSize() / ::GetSerializeSize(CMutableTransaction(), PROTOCOL_VERSION)) - (CTransaction(coinbaseTx).GetTotalSize() + CTransaction(naughtyTx).GetTotalSize())) / 41) - 100;
for (uint64_t x = 0; x < (n_inputs - 1); ++x) {
naughtyTx.vin.emplace_back(GetRandHash(), 0, CScript(), 0);
}
Expand Down
4 changes: 3 additions & 1 deletion src/bitcoin-tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <consensus/consensus.h>
#include <core_io.h>
#include <key_io.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
#include <script/script.h>
#include <script/sign.h>
Expand Down Expand Up @@ -202,8 +203,9 @@ static CAmount ExtractAndValidateValue(const std::string& strValue)
static void MutateTxVersion(CMutableTransaction& tx, const std::string& cmdVal)
{
int64_t newVersion;
if (!ParseInt64(cmdVal, &newVersion) || newVersion < 1 || newVersion > CTransaction::MAX_STANDARD_VERSION)
if (!ParseInt64(cmdVal, &newVersion) || newVersion < 1 || newVersion > TX_MAX_STANDARD_VERSION) {
throw std::runtime_error("Invalid TX version requested: '" + cmdVal + "'");
}

tx.nVersion = (int) newVersion;
}
Expand Down
2 changes: 1 addition & 1 deletion src/blockencodings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include <unordered_map>

#define MIN_TRANSACTION_SIZE (::GetSerializeSize(CTransaction(), PROTOCOL_VERSION))
#define MIN_TRANSACTION_SIZE (::GetSerializeSize(CMutableTransaction(), PROTOCOL_VERSION))

CBlockHeaderAndShortTxIDs::CBlockHeaderAndShortTxIDs(const CBlock& block) :
nonce(GetRand(std::numeric_limits<uint64_t>::max())),
Expand Down
1 change: 1 addition & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ class CTestNetParams : public CChainParams {

checkpointData = {
{
{255, uint256S("0x0000080b600e06f4c07880673f027210f9314575f5f875fafe51971e268b886a")},
{261, uint256S("0x00000c26026d0815a7e2ce4fa270775f61403c040647ff2c3091f99e894a4618")},
{1999, uint256S("0x00000052e538d27fa53693efe6fb6892a0c1d26c0235f599171c48a3cce553b1")},
{2999, uint256S("0x0000024bc3f4f4cb30d29827c13d921ad77d2c6072e586c7f60d83c2722cdcc5")},
Expand Down
5 changes: 2 additions & 3 deletions src/coinjoin/coinjoin.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class CCoinJoinEntry
CService addr;

CCoinJoinEntry() :
txCollateral(MakeTransactionRef())
txCollateral(MakeTransactionRef(CMutableTransaction{}))
{
}

Expand Down Expand Up @@ -246,9 +246,8 @@ class CCoinJoinBroadcastTx
uint256 m_protxHash;
std::vector<unsigned char> vchSig;
int64_t sigTime{0};

CCoinJoinBroadcastTx() :
tx(MakeTransactionRef())
tx(MakeTransactionRef(CMutableTransaction{}))
{
}

Expand Down
2 changes: 1 addition & 1 deletion src/policy/policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ bool IsStandard(const CScript& scriptPubKey, TxoutType& whichType)

bool IsStandardTx(const CTransaction& tx, bool permit_bare_multisig, const CFeeRate& dust_relay_fee, std::string& reason)
{
if (tx.nVersion > CTransaction::MAX_STANDARD_VERSION || tx.nVersion < 1) {
if (tx.nVersion > TX_MAX_STANDARD_VERSION || tx.nVersion < 1) {
reason = "version";
return false;
}
Expand Down
25 changes: 16 additions & 9 deletions src/policy/policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,23 @@ CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFee);
bool IsDust(const CTxOut& txout, const CFeeRate& dustRelayFee);

bool IsStandard(const CScript& scriptPubKey, TxoutType& whichType);
/**
* Check for standard transaction types
* @return True if all outputs (scriptPubKeys) use only standard transaction forms
*/


// Changing the default transaction version requires a two step process: first
// adapting relay policy by bumping TX_MAX_STANDARD_VERSION, and then later
// allowing the new transaction version in the wallet/RPC.
static constexpr decltype(CTransaction::nVersion) TX_MAX_STANDARD_VERSION{3};
Copy link

@UdjinM6 UdjinM6 Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

20611: nit: could probably use CTransaction::SPECIAL_VERSION here

Suggested change
static constexpr decltype(CTransaction::nVersion) TX_MAX_STANDARD_VERSION{3};
static constexpr decltype(CTransaction::nVersion) TX_MAX_STANDARD_VERSION{CTransaction::SPECIAL_VERSION};

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's not dash code but backported, I'd prefer to keep as it is.

They do not re-use definitions:

static const int32_t CURRENT_VERSION=2;
static constexpr decltype(CTransaction::nVersion) TX_MAX_STANDARD_VERSION{2};


/**
* Check for standard transaction types
* @return True if all outputs (scriptPubKeys) use only standard transaction forms
*/
bool IsStandardTx(const CTransaction& tx, bool permit_bare_multisig, const CFeeRate& dust_relay_fee, std::string& reason);
/**
* Check for standard transaction types
* @param[in] mapInputs Map of previous transactions that have outputs we're spending
* @return True if all inputs (scriptSigs) use only standard transaction forms
*/
/**
* Check for standard transaction types
* @param[in] mapInputs Map of previous transactions that have outputs we're spending
* @return True if all inputs (scriptSigs) use only standard transaction forms
*/
bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs);

/** Compute the virtual transaction size (taking sigops into account). */
Expand Down
2 changes: 0 additions & 2 deletions src/primitives/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ uint256 CTransaction::ComputeHash() const
return SerializeHash(*this);
}

/* For backward compatibility, the hash is initialized to 0. TODO: remove the need for this default constructor entirely. */
CTransaction::CTransaction() : vin(), vout(), nVersion(CTransaction::CURRENT_VERSION), nType(TRANSACTION_NORMAL), nLockTime(0), hash{} {}
CTransaction::CTransaction(const CMutableTransaction& tx) : vin(tx.vin), vout(tx.vout), nVersion(tx.nVersion), nType(tx.nType), nLockTime(tx.nLockTime), vExtraPayload(tx.vExtraPayload), hash{ComputeHash()} {}
CTransaction::CTransaction(CMutableTransaction&& tx) : vin(std::move(tx.vin)), vout(std::move(tx.vout)), nVersion(tx.nVersion), nType(tx.nType), nLockTime(tx.nLockTime), vExtraPayload(tx.vExtraPayload), hash{ComputeHash()} {}

Expand Down
14 changes: 2 additions & 12 deletions src/primitives/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,6 @@ class CTransaction
// Special transaction version
static const int32_t SPECIAL_VERSION = 3;

// Changing the default transaction version requires a two step process: first
// adapting relay policy by bumping MAX_STANDARD_VERSION, and then later date
// bumping the default CURRENT_VERSION at which point both CURRENT_VERSION and
// MAX_STANDARD_VERSION will be equal.
static const int32_t MAX_STANDARD_VERSION = SPECIAL_VERSION;

// The local variables are made const to prevent unintended modification
// without updating the cached hash value. However, CTransaction is not
// actually immutable; deserialization and assignment are implemented,
Expand All @@ -212,12 +206,9 @@ class CTransaction
uint256 ComputeHash() const;

public:
/** Construct a CTransaction that qualifies as IsNull() */
CTransaction();

/** Convert a CMutableTransaction into a CTransaction. */
explicit CTransaction(const CMutableTransaction &tx);
CTransaction(CMutableTransaction &&tx);
explicit CTransaction(const CMutableTransaction& tx);
CTransaction(CMutableTransaction&& tx);

template <typename Stream>
inline void Serialize(Stream& s) const {
Expand Down Expand Up @@ -319,7 +310,6 @@ struct CMutableTransaction
};

typedef std::shared_ptr<const CTransaction> CTransactionRef;
static inline CTransactionRef MakeTransactionRef() { return std::make_shared<const CTransaction>(); }
template <typename Tx> static inline CTransactionRef MakeTransactionRef(Tx&& txIn) { return std::make_shared<const CTransaction>(std::forward<Tx>(txIn)); }

/** Implementation of BIP69
Expand Down
2 changes: 1 addition & 1 deletion src/test/fuzz/addition_overflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#if __has_builtin(__builtin_add_overflow)
#define HAVE_BUILTIN_ADD_OVERFLOW
#endif
#elif defined(__GNUC__) && (__GNUC__ >= 5)
#elif defined(__GNUC__)
#define HAVE_BUILTIN_ADD_OVERFLOW
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/test/fuzz/script_sigcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ FUZZ_TARGET_INIT(script_sigcache, initialize_script_sigcache)
FuzzedDataProvider fuzzed_data_provider(buffer.data(), buffer.size());

const std::optional<CMutableTransaction> mutable_transaction = ConsumeDeserializable<CMutableTransaction>(fuzzed_data_provider);
const CTransaction tx = mutable_transaction ? CTransaction{*mutable_transaction} : CTransaction{};
const CTransaction tx{mutable_transaction ? *mutable_transaction : CMutableTransaction{}};
const unsigned int n_in = fuzzed_data_provider.ConsumeIntegral<unsigned int>();
const CAmount amount = ConsumeMoney(fuzzed_data_provider);
const bool store = fuzzed_data_provider.ConsumeBool();
Expand Down
2 changes: 1 addition & 1 deletion src/test/fuzz/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ FUZZ_TARGET_INIT(transaction, initialize_transaction)
return CTransaction(deserialize, ds);
} catch (const std::ios_base::failure&) {
valid_tx = false;
return CTransaction();
return CTransaction{CMutableTransaction{}};
}
}();
bool valid_mutable_tx = true;
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/test/coinjoin_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ class CTransactionBuilderTestSetup : public TestChain100Setup
CompactTallyItem GetTallyItem(const std::vector<CAmount>& vecAmounts)
{
CompactTallyItem tallyItem;
CTransactionRef tx;
ReserveDestination reserveDest(wallet.get());
CAmount nFeeRet;
int nChangePosRet = -1;
Expand All @@ -185,6 +184,7 @@ class CTransactionBuilderTestSetup : public TestChain100Setup
BOOST_CHECK(reserveDest.GetReservedDestination(tallyItem.txdest, false));
}
for (CAmount nAmount : vecAmounts) {
CTransactionRef tx;
BOOST_CHECK(wallet->CreateTransaction({{GetScriptForDestination(tallyItem.txdest), nAmount, false}}, tx, nFeeRet, nChangePosRet, strError, coinControl));
{
LOCK2(wallet->cs_wallet, cs_main);
Expand Down
3 changes: 2 additions & 1 deletion src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3760,7 +3760,7 @@ bool CWallet::CreateTransaction(
int nExtraPayloadSize)
{
int nChangePosIn = nChangePosInOut;
CTransactionRef tx2 = tx;
Assert(!tx); // tx is an out-param. TODO change the return type from bool to tx (or nullptr)
bool res = CreateTransactionInternal(vecSend, tx, nFeeRet, nChangePosInOut, error, coin_control, sign, nExtraPayloadSize);
// try with avoidpartialspends unless it's enabled already
if (res && nFeeRet > 0 /* 0 means non-functional fee rate estimation */ && m_max_aps_fee > -1 && !coin_control.m_avoid_partial_spends) {
Expand All @@ -3774,6 +3774,7 @@ bool CWallet::CreateTransaction(
}

CAmount nFeeRet2;
CTransactionRef tx2;
int nChangePosInOut2 = nChangePosIn;
bilingual_str error2; // fired and forgotten; if an error occurs, we discard the results
if (CreateTransactionInternal(vecSend, tx2, nFeeRet2, nChangePosInOut2, error2, tmp_cc, sign, nExtraPayloadSize)) {
Expand Down
Loading