2018-07-20 15:57:08 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# Copyright (c) 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.
|
|
|
|
#
|
|
|
|
# Check for circular dependencies
|
|
|
|
|
|
|
|
export LC_ALL=C
|
|
|
|
|
|
|
|
EXPECTED_CIRCULAR_DEPENDENCIES=(
|
2021-06-27 08:33:13 +02:00
|
|
|
"chainparamsbase -> util/system -> chainparamsbase"
|
2018-07-20 15:57:08 +02:00
|
|
|
"checkpoints -> validation -> checkpoints"
|
2021-05-25 12:48:04 +02:00
|
|
|
"index/txindex -> validation -> index/txindex"
|
2018-07-20 15:57:08 +02:00
|
|
|
"policy/fees -> txmempool -> policy/fees"
|
|
|
|
"policy/policy -> validation -> policy/policy"
|
|
|
|
"qt/addresstablemodel -> qt/walletmodel -> qt/addresstablemodel"
|
|
|
|
"qt/bantablemodel -> qt/clientmodel -> qt/bantablemodel"
|
|
|
|
"qt/bitcoingui -> qt/utilitydialog -> qt/bitcoingui"
|
|
|
|
"qt/bitcoingui -> qt/walletframe -> qt/bitcoingui"
|
|
|
|
"qt/bitcoingui -> qt/walletview -> qt/bitcoingui"
|
|
|
|
"qt/clientmodel -> qt/peertablemodel -> qt/clientmodel"
|
|
|
|
"qt/paymentserver -> qt/walletmodel -> qt/paymentserver"
|
|
|
|
"qt/recentrequeststablemodel -> qt/walletmodel -> qt/recentrequeststablemodel"
|
|
|
|
"qt/transactiontablemodel -> qt/walletmodel -> qt/transactiontablemodel"
|
|
|
|
"qt/walletmodel -> qt/walletmodeltransaction -> qt/walletmodel"
|
|
|
|
"rpc/rawtransaction -> wallet/rpcwallet -> rpc/rawtransaction"
|
|
|
|
"txmempool -> validation -> txmempool"
|
|
|
|
"validation -> validationinterface -> validation"
|
|
|
|
"wallet/fees -> wallet/wallet -> wallet/fees"
|
|
|
|
"wallet/wallet -> wallet/walletdb -> wallet/wallet"
|
Merge #12257: [wallet] Use destination groups instead of coins in coin select
232f96f5c8a3920c09db92f4dbac2ad7d10ce8cf doc: Add release notes for -avoidpartialspends (Karl-Johan Alm)
e00b4699cc6d2ee5697d38dd6607eb2631c9b77a clean-up: Remove no longer used ivars from CInputCoin (Karl-Johan Alm)
43e04d13b1ffc02b1082176e87f420198b40c7b1 wallet: Remove deprecated OutputEligibleForSpending (Karl-Johan Alm)
0128121101fb3ee82f3abd3973a967a4226ffe0e test: Add basic testing for wallet groups (Karl-Johan Alm)
59d6f7b4e2f847ec1f2ff46c84e6157655984f85 wallet: Switch to using output groups instead of coins in coin selection (Karl-Johan Alm)
87ebce25d66952f5ce565bb5130dcf5e24049872 wallet: Add output grouping (Karl-Johan Alm)
bb629cb9dc567cc819724d9f4852652926e60cbf Add -avoidpartialspends and m_avoid_partial_spends (Karl-Johan Alm)
65b3eda458221644616d0fdd6ba0fe01bdbce893 wallet: Add input bytes to CInputCoin (Karl-Johan Alm)
a443d7a0ca333b0bae63e04b5d476f9ad9c7aeac moveonly: CoinElegibilityFilter into coinselection.h (Karl-Johan Alm)
173e18a289088c6087ba6fac708e322aa63b7a94 utils: Add insert() convenience templates (Karl-Johan Alm)
Pull request description:
This PR adds an optional (off by default) `-avoidpartialspends` flag, which changes coin select to use output groups rather than outputs, where each output group corresponds to all outputs with the same destination.
It is a privacy improvement, as each time you spend some output, any other output that is publicly associated with the destination (address) will also be spent at the same time, at the cost of fee increase for cases where coin select without group restriction would find a more optimal set of coins (see example below).
For regular use without address reuse, this PR should have no effect on the user experience whatsoever; it only affects users who, for some reason, have multiple outputs with the same destination (i.e. address reuse).
Nodes with this turned off will still try to avoid partial spending, if the fee of the resulting transaction is not greater than the fee of the original transaction.
Example: a node has four outputs linked to two addresses `A` and `B`:
* 1.0 btc to `A`
* 0.5 btc to `A`
* 1.0 btc to `B`
* 0.5 btc to `B`
The node sends 0.2 btc to `C`. Without `-avoidpartialspends`, the following coin selection will occur:
* 0.5 btc to `A` or `B` is picked
* 0.2 btc is output to `C`
* 0.3 - fee is output to (unique change address)
With `-avoidpartialspends`, the following will instead happen:
* Both of (0.5, 1.0) btc to `A` or `B` is picked (one or the other pair)
* 0.2 btc is output to `C`
* 1.3 - fee is output to (unique change address)
As noted, the pro here is that, assuming nobody sends to the address after you spend from it, you will only ever use one address once. The con is that the transaction becomes slightly larger in this case, because it is overpicking outputs to adhere to the no partial spending rule.
This complements #10386, in particular it addresses @luke-jr and @gmaxwell's concerns in https://github.com/bitcoin/bitcoin/pull/10386#issuecomment-300667926 and https://github.com/bitcoin/bitcoin/pull/10386#issuecomment-302361381.
Together with `-avoidreuse`, this fully addresses the concerns in #10065 I believe.
Tree-SHA512: 24687a4490ba59cf4198ed90052944ff4996653a4257833bb52ed24d058b3e924800c9b3790aeb6be6385b653b49e304453e5d7ff960e64c682fc23bfc447621
# Conflicts:
# src/Makefile.am
# src/bench/coin_selection.cpp
# src/wallet/coincontrol.h
# src/wallet/coinselection.cpp
# src/wallet/coinselection.h
# src/wallet/init.cpp
# src/wallet/test/coinselector_tests.cpp
# src/wallet/wallet.cpp
# src/wallet/wallet.h
# test/functional/test_runner.py
2018-07-24 15:06:21 +02:00
|
|
|
"wallet/coincontrol -> wallet/wallet -> wallet/coincontrol"
|
2018-07-20 15:57:08 +02:00
|
|
|
"policy/fees -> policy/policy -> validation -> policy/fees"
|
|
|
|
"qt/addressbookpage -> qt/bitcoingui -> qt/walletview -> qt/addressbookpage"
|
|
|
|
"txmempool -> validation -> validationinterface -> txmempool"
|
|
|
|
"qt/addressbookpage -> qt/bitcoingui -> qt/walletview -> qt/receivecoinsdialog -> qt/addressbookpage"
|
|
|
|
"qt/addressbookpage -> qt/bitcoingui -> qt/walletview -> qt/signverifymessagedialog -> qt/addressbookpage"
|
|
|
|
"qt/addressbookpage -> qt/bitcoingui -> qt/walletview -> qt/sendcoinsdialog -> qt/sendcoinsentry -> qt/addressbookpage"
|
2021-02-04 01:48:30 +01:00
|
|
|
# Dash
|
2021-03-17 23:36:11 +01:00
|
|
|
"coinjoin/coinjoin-server -> init -> coinjoin/coinjoin-server"
|
|
|
|
"coinjoin/coinjoin-server -> net_processing -> coinjoin/coinjoin-server"
|
|
|
|
"coinjoin/coinjoin-client -> init -> dsnotificationinterface -> coinjoin/coinjoin-client"
|
|
|
|
"coinjoin/coinjoin-client -> init -> masternode/masternode-utils -> coinjoin/coinjoin-client"
|
2021-02-04 01:48:30 +01:00
|
|
|
"evo/cbtx -> evo/simplifiedmns -> evo/cbtx"
|
|
|
|
"evo/cbtx -> evo/specialtx -> evo/cbtx"
|
|
|
|
"evo/deterministicmns -> evo/providertx -> evo/deterministicmns"
|
|
|
|
"evo/deterministicmns -> evo/simplifiedmns -> evo/deterministicmns"
|
|
|
|
"evo/deterministicmns -> evo/specialtx -> evo/deterministicmns"
|
|
|
|
"evo/deterministicmns -> llmq/quorums_commitment -> evo/deterministicmns"
|
|
|
|
"evo/deterministicmns -> llmq/quorums_utils -> evo/deterministicmns"
|
|
|
|
"evo/deterministicmns -> validation -> evo/deterministicmns"
|
|
|
|
"evo/mnauth -> net_processing -> evo/mnauth"
|
|
|
|
"evo/specialtx -> llmq/quorums_blockprocessor -> evo/specialtx"
|
|
|
|
"evo/specialtx -> llmq/quorums_commitment -> evo/specialtx"
|
|
|
|
"evo/specialtx -> validation -> evo/specialtx"
|
|
|
|
"governance/governance -> governance/governance-classes -> governance/governance"
|
|
|
|
"governance/governance -> governance/governance-object -> governance/governance"
|
|
|
|
"governance/governance -> init -> governance/governance"
|
|
|
|
"governance/governance -> masternode/masternode-sync -> governance/governance"
|
|
|
|
"governance/governance -> net_processing -> governance/governance"
|
|
|
|
"governance/governance-object -> governance/governance-validators -> governance/governance-object"
|
|
|
|
"init -> masternode/masternode-sync -> init"
|
|
|
|
"init -> masternode/masternode-utils -> init"
|
|
|
|
"init -> net_processing -> init"
|
|
|
|
"init -> netfulfilledman -> init"
|
|
|
|
"init -> rpc/server -> init"
|
|
|
|
"init -> txdb -> init"
|
|
|
|
"init -> validation -> init"
|
|
|
|
"init -> validationinterface -> init"
|
|
|
|
"llmq/quorums -> llmq/quorums_utils -> llmq/quorums"
|
|
|
|
"llmq/quorums_blockprocessor -> net_processing -> llmq/quorums_blockprocessor"
|
|
|
|
"llmq/quorums_chainlocks -> llmq/quorums_instantsend -> llmq/quorums_chainlocks"
|
|
|
|
"llmq/quorums_chainlocks -> net_processing -> llmq/quorums_chainlocks"
|
|
|
|
"llmq/quorums_dkgsessionmgr -> net_processing -> llmq/quorums_dkgsessionmgr"
|
|
|
|
"llmq/quorums_instantsend -> net_processing -> llmq/quorums_instantsend"
|
|
|
|
"llmq/quorums_instantsend -> txmempool -> llmq/quorums_instantsend"
|
|
|
|
"llmq/quorums_instantsend -> validation -> llmq/quorums_instantsend"
|
|
|
|
"llmq/quorums_signing -> llmq/quorums_signing_shares -> llmq/quorums_signing"
|
|
|
|
"llmq/quorums_signing -> net_processing -> llmq/quorums_signing"
|
|
|
|
"llmq/quorums_signing_shares -> net_processing -> llmq/quorums_signing_shares"
|
2021-06-27 08:33:13 +02:00
|
|
|
"logging -> util/system -> logging"
|
2021-02-04 01:48:30 +01:00
|
|
|
"masternode/masternode-payments -> validation -> masternode/masternode-payments"
|
|
|
|
"net -> netmessagemaker -> net"
|
|
|
|
"net_processing -> spork -> net_processing"
|
|
|
|
"netaddress -> netbase -> netaddress"
|
|
|
|
"qt/appearancewidget -> qt/guiutil -> qt/appearancewidget"
|
|
|
|
"qt/bitcoinaddressvalidator -> qt/guiutil -> qt/bitcoinaddressvalidator"
|
|
|
|
"qt/bitcoingui -> qt/guiutil -> qt/bitcoingui"
|
|
|
|
"qt/guiutil -> qt/optionsdialog -> qt/guiutil"
|
|
|
|
"qt/guiutil -> qt/qvalidatedlineedit -> qt/guiutil"
|
|
|
|
"core_io -> evo/cbtx -> evo/deterministicmns -> core_io"
|
|
|
|
"core_io -> evo/cbtx -> evo/simplifiedmns -> core_io"
|
|
|
|
"dsnotificationinterface -> governance/governance -> init -> dsnotificationinterface"
|
|
|
|
"evo/simplifiedmns -> llmq/quorums_blockprocessor -> net_processing -> evo/simplifiedmns"
|
|
|
|
"httprpc -> httpserver -> init -> httprpc"
|
|
|
|
"httpserver -> init -> httpserver"
|
|
|
|
"init -> llmq/quorums_init -> llmq/quorums_signing_shares -> init"
|
|
|
|
"llmq/quorums_dkgsession -> llmq/quorums_dkgsessionmgr -> llmq/quorums_dkgsessionhandler -> llmq/quorums_dkgsession"
|
2021-06-27 08:33:13 +02:00
|
|
|
"logging -> util/system -> random -> logging"
|
|
|
|
"logging -> util/system -> sync -> logging"
|
|
|
|
"logging -> util/system -> stacktraces -> logging"
|
2021-03-17 23:36:11 +01:00
|
|
|
"coinjoin/coinjoin-client -> coinjoin/coinjoin-util -> wallet/wallet -> coinjoin/coinjoin-client"
|
2021-02-04 01:48:30 +01:00
|
|
|
"qt/appearancewidget -> qt/guiutil -> qt/optionsdialog -> qt/appearancewidget"
|
|
|
|
"qt/bitcoinaddressvalidator -> qt/guiutil -> qt/qvalidatedlineedit -> qt/bitcoinaddressvalidator"
|
|
|
|
"qt/guiutil -> qt/optionsdialog -> qt/optionsmodel -> qt/guiutil"
|
|
|
|
"bloom -> evo/cbtx -> evo/simplifiedmns -> merkleblock -> bloom"
|
|
|
|
"bloom -> evo/cbtx -> llmq/quorums_blockprocessor -> net -> bloom"
|
|
|
|
"evo/deterministicmns -> evo/simplifiedmns -> llmq/quorums_blockprocessor -> llmq/quorums_debug -> evo/deterministicmns"
|
|
|
|
"evo/deterministicmns -> evo/simplifiedmns -> llmq/quorums_blockprocessor -> net_processing -> evo/deterministicmns"
|
|
|
|
"evo/specialtx -> llmq/quorums_blockprocessor -> net_processing -> txmempool -> evo/specialtx"
|
|
|
|
"evo/providertx -> evo/specialtx -> llmq/quorums_blockprocessor -> net_processing -> txmempool -> evo/providertx"
|
2021-03-26 13:21:41 +01:00
|
|
|
|
2021-04-16 05:41:16 +02:00
|
|
|
"coinjoin/coinjoin-client -> net_processing -> coinjoin/coinjoin-client"
|
|
|
|
"llmq/quorums -> net_processing -> llmq/quorums"
|
|
|
|
"llmq/quorums_commitment -> llmq/quorums_utils -> llmq/quorums_commitment"
|
|
|
|
"llmq/quorums_dkgsession -> llmq/quorums_dkgsessionmgr -> llmq/quorums_dkgsession"
|
|
|
|
"coinjoin/coinjoin -> masternode/activemasternode -> net -> coinjoin/coinjoin"
|
|
|
|
"evo/deterministicmns -> validationinterface -> txmempool -> evo/deterministicmns"
|
|
|
|
"llmq/quorums -> validation -> llmq/quorums_chainlocks -> llmq/quorums"
|
|
|
|
"llmq/quorums_chainlocks -> llmq/quorums_instantsend -> validation -> llmq/quorums_chainlocks"
|
|
|
|
"evo/deterministicmns -> evo/simplifiedmns -> llmq/quorums_blockprocessor -> net_processing -> masternode/masternode-payments -> evo/deterministicmns"
|
|
|
|
"core_io -> evo/cbtx -> llmq/quorums_blockprocessor -> net_processing -> masternode/masternode-payments -> governance/governance-classes -> core_io"
|
|
|
|
"evo/deterministicmns -> evo/simplifiedmns -> llmq/quorums_blockprocessor -> net_processing -> masternode/masternode-payments -> masternode/activemasternode -> evo/deterministicmns"
|
2021-04-20 21:32:27 +02:00
|
|
|
"evo/deterministicmns -> evo/simplifiedmns -> llmq/quorums_blockprocessor -> net -> masternode/masternode-sync -> evo/deterministicmns"
|
2021-04-23 00:32:03 +02:00
|
|
|
"governance/governance -> net_processing -> masternode/masternode-payments -> governance/governance"
|
|
|
|
"core_io -> evo/cbtx -> llmq/quorums_blockprocessor -> net_processing -> masternode/masternode-payments -> governance/governance-classes -> governance/governance-object -> core_io"
|
|
|
|
"evo/deterministicmns -> evo/simplifiedmns -> llmq/quorums_blockprocessor -> net_processing -> masternode/masternode-payments -> governance/governance-classes -> governance/governance-object -> evo/deterministicmns"
|
|
|
|
"evo/deterministicmns -> evo/simplifiedmns -> llmq/quorums_blockprocessor -> net -> evo/deterministicmns"
|
|
|
|
"evo/deterministicmns -> evo/simplifiedmns -> llmq/quorums_blockprocessor -> net_processing -> masternode/masternode-payments -> governance/governance-classes -> governance/governance-object -> governance/governance-vote -> evo/deterministicmns"
|
2021-05-25 12:48:04 +02:00
|
|
|
"index/txindex -> init -> index/txindex"
|
|
|
|
"index/txindex -> init -> llmq/quorums_init -> llmq/quorums_instantsend -> index/txindex"
|
|
|
|
"index/txindex -> init -> net_processing -> index/txindex"
|
|
|
|
"index/txindex -> init -> rpc/blockchain -> index/txindex"
|
2018-07-20 15:57:08 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
EXIT_CODE=0
|
|
|
|
|
|
|
|
CIRCULAR_DEPENDENCIES=()
|
|
|
|
|
|
|
|
IFS=$'\n'
|
|
|
|
for CIRC in $(cd src && ../contrib/devtools/circular-dependencies.py {*,*/*,*/*/*}.{h,cpp} | sed -e 's/^Circular dependency: //'); do
|
|
|
|
CIRCULAR_DEPENDENCIES+=($CIRC)
|
|
|
|
IS_EXPECTED_CIRC=0
|
|
|
|
for EXPECTED_CIRC in "${EXPECTED_CIRCULAR_DEPENDENCIES[@]}"; do
|
|
|
|
if [[ "${CIRC}" == "${EXPECTED_CIRC}" ]]; then
|
|
|
|
IS_EXPECTED_CIRC=1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [[ ${IS_EXPECTED_CIRC} == 0 ]]; then
|
|
|
|
echo "A new circular dependency in the form of \"${CIRC}\" appears to have been introduced."
|
|
|
|
echo
|
|
|
|
EXIT_CODE=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
for EXPECTED_CIRC in "${EXPECTED_CIRCULAR_DEPENDENCIES[@]}"; do
|
|
|
|
IS_PRESENT_EXPECTED_CIRC=0
|
|
|
|
for CIRC in "${CIRCULAR_DEPENDENCIES[@]}"; do
|
|
|
|
if [[ "${CIRC}" == "${EXPECTED_CIRC}" ]]; then
|
|
|
|
IS_PRESENT_EXPECTED_CIRC=1
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [[ ${IS_PRESENT_EXPECTED_CIRC} == 0 ]]; then
|
|
|
|
echo "Good job! The circular dependency \"${EXPECTED_CIRC}\" is no longer present."
|
|
|
|
echo "Please remove it from EXPECTED_CIRCULAR_DEPENDENCIES in $0"
|
|
|
|
echo "to make sure this circular dependency is not accidentally reintroduced."
|
|
|
|
echo
|
|
|
|
EXIT_CODE=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
exit ${EXIT_CODE}
|