From e3c69da4f2d802aa6450ebc8e8f59a329396ce55 Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Tue, 20 Jul 2021 15:35:31 +0200 Subject: [PATCH 1/9] Merge bitcoin/bitcoin#22232: refactor: Pass interpreter flags as uint32_t instead of signed int BACKPORT NOTE: Prior work is done here: https://github.com/dashpay/dash/pull/5663/commits/c338cd69d419a923dc65edaa22e302b8844ff81d#diff-060e8fd790fc1c3e18c64327a7395bb5b2d6d57db9792cc666bd8d7354a40c0b Missing changes in tx_verify.h included in this PR, but changes in src/test/sigopcount_tests.cpp and src/test/transaction_tests.cpp are irrelevant because they are segwit-related fa621ededdfe31a200b77a8787de7e3d2e667aec refactor: Pass script verify flags as uint32_t (MarcoFalke) Pull request description: The flags are cast to unsigned in the interpreter anyway, so avoid the confusion (and fuzz crashes) by just passing them as unsigned from the beginning. Also, the flags are often inverted bit-wise with the `~` operator, which also works on signed integers, but might cause confusion as the sign bit is flipped. Fixes #22233 ACKs for top commit: theStack: Concept and code review ACK fa621ededdfe31a200b77a8787de7e3d2e667aec kristapsk: ACK fa621ededdfe31a200b77a8787de7e3d2e667aec jonatack: ACK fa621ededdfe31a200b77a8787de7e3d2e667aec Tree-SHA512: ea0720f32f823fa7f075309978672aa39773c6019d12b6c1c9d611fc1983a76115b7fe2a28d50814673bb6415c311ccc05b99d6e871575fb6900faf75ed17769 --- src/consensus/tx_verify.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/consensus/tx_verify.h b/src/consensus/tx_verify.h index 199f8c94a7..4fbae4c540 100644 --- a/src/consensus/tx_verify.h +++ b/src/consensus/tx_verify.h @@ -49,7 +49,7 @@ unsigned int GetP2SHSigOpCount(const CTransaction& tx, const CCoinsViewCache& ma * Count total signature operations for a transaction. * @param[in] tx Transaction for which we are counting sigops * @param[in] inputs Map of previous transactions that have outputs we're spending - * @param[out] flags Script verification flags + * @param[in] flags Script verification flags * @return Total signature operation count for a tx */ unsigned int GetTransactionSigOpCount(const CTransaction& tx, const CCoinsViewCache& inputs, uint32_t flags); From 42a0cf0709b2d93ca1d5a31104fe9f86ff86d52b Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Wed, 28 Jul 2021 16:31:35 +0200 Subject: [PATCH 2/9] Merge bitcoin/bitcoin#21562: [net processing] Various tidying up of PeerManagerImpl ctor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fde1bf4f6136638e84cdf9806eedaae08e841bbf [net processing] Default initialize m_recent_confirmed_transactions (John Newbery) 37dcd12d539e4a875581fa049aa0f7fafeb932a4 scripted-diff: Rename recentRejects (John Newbery) cd9902ac5054c01228d52616bf85f7196364d4ff [net processing] Default initialize recentRejects (John Newbery) a28bfd1d4cfa523a6abf3832dbfd6183cd546944 [net processing] Default initialize m_stale_tip_check_time (John Newbery) 9190b01d8dcf03b74e9b9e1653688a97ac171b37 [net processing] Add Orphanage empty consistency check (John Newbery) Pull request description: - Use default initialization of PeerManagerImpl members where possible - Remove unique_ptr indirection where it's not needed ACKs for top commit: MarcoFalke: ACK fde1bf4f6136638e84cdf9806eedaae08e841bbf 👞 theStack: re-ACK fde1bf4f6136638e84cdf9806eedaae08e841bbf Tree-SHA512: 7ddedcc972df8e933e1fbe5c88b8ea17df89e1e58fc769518512c5540e49dc8eddb3f47e78d1329a6fc5644d2c1d11c981f681fd633f5218bfa4b3e6a86f3d7b --- src/net_processing.cpp | 3 ++- src/txorphanage.h | 7 +++++++ test/functional/p2p_permissions.py | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index e0af64376b..e5fad5fe61 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -872,7 +872,7 @@ private: * million to make it highly unlikely for users to have issues with this * filter. * - * Memory used: 1.3MB + * Memory used: 1.3 MB */ CRollingBloomFilter m_recent_rejects GUARDED_BY(::cs_main){120'000, 0.000'001}; uint256 hashRecentRejectsChainTip GUARDED_BY(cs_main); @@ -1620,6 +1620,7 @@ void PeerManagerImpl::FinalizeNode(const CNode& node) { assert(m_num_preferred_download_peers == 0); assert(m_peers_downloading_from == 0); assert(m_outbound_peers_with_protect_from_disconnect == 0); + assert(m_orphanage.Size() == 0); } } // cs_main diff --git a/src/txorphanage.h b/src/txorphanage.h index d8ef7a5c44..d3d06c8e53 100644 --- a/src/txorphanage.h +++ b/src/txorphanage.h @@ -50,6 +50,13 @@ public: * (ie orphans that may have found their final missing parent, and so should be reconsidered for the mempool) */ void AddChildrenToWorkSet(const CTransaction& tx, std::set& orphan_work_set) const EXCLUSIVE_LOCKS_REQUIRED(g_cs_orphans); + /** Return how many entries exist in the orphange */ + size_t Size() LOCKS_EXCLUDED(::g_cs_orphans) + { + LOCK(::g_cs_orphans); + return m_orphans.size(); + } + protected: struct OrphanTx { CTransactionRef tx; diff --git a/test/functional/p2p_permissions.py b/test/functional/p2p_permissions.py index e7e82eccb5..71ebfd38f9 100755 --- a/test/functional/p2p_permissions.py +++ b/test/functional/p2p_permissions.py @@ -133,7 +133,7 @@ class P2PPermissionsTests(BitcoinTestFramework): tx.vout[0].nValue += 1 txid = tx.rehash() # Send the transaction twice. The first time, it'll be rejected by ATMP because it conflicts - # with a mempool transaction. The second time, it'll be in the recentRejects filter. + # with a mempool transaction. The second time, it'll be in the m_recent_rejects filter. p2p_rebroadcast_wallet.send_txs_and_test( [tx], self.nodes[1], From 5a803ae7653a6d52832b6f28d0733e15e7eaf6dd Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Mon, 2 Aug 2021 15:51:42 +0200 Subject: [PATCH 3/9] Merge bitcoin/bitcoin#22378: test: remove confusing `MAX_BLOCK_BASE_SIZE` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 607076d01bf23c69ac21950c17b01fb4e1130774 test: remove confusing `MAX_BLOCK_BASE_SIZE` (Sebastian Falbesoner) 4af97c74edcda56cd15523bf3a335adea2bad14a test: introduce `get_weight()` helper for CBlock (Sebastian Falbesoner) a084ebe1330bcec15715e08b0f65319142927ad1 test: introduce `get_weight()` helper for CTransaction (Sebastian Falbesoner) Pull request description: This is a very late follow-up PR to #10618, which removed the constant `MAX_BLOCK_BASE_SIZE` from the core implementation about four years ago (see also #10608 in why it was considered confusing and superfluous). Since there is also no point in still keeping it in the functional test framework, the PR switches to weight-based accounting on the relevant test code parts and use `MAX_BLOCK_WEIGHT` instead for the block limit checks. To prepare that, the first two commits introduce `get_weight()` helpers for the classes CTransaction and CBlock, respectively. ACKs for top commit: MarcoFalke: review ACK 607076d01bf23c69ac21950c17b01fb4e1130774 🚴 Tree-SHA512: d59aa0b6b3dfd0a849b8063e66de275d252f705f99e25cd3bf6daec028b47d946777ee5b42a060f5283cb18e917ac073119c2c0e11bbc21211f69ef0a6ed335a --- test/functional/feature_block.py | 26 +++++++++---------- .../mining_prioritisetransaction.py | 4 +-- test/functional/test_framework/messages.py | 5 ++++ 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/test/functional/feature_block.py b/test/functional/feature_block.py index 9776a549d0..973f7d0fa8 100755 --- a/test/functional/feature_block.py +++ b/test/functional/feature_block.py @@ -329,24 +329,24 @@ class FullBlockTest(BitcoinTestFramework): self.move_tip(15) b23 = self.next_block(23, spend=out[6]) tx = CTransaction() - script_length = MAX_BLOCK_SIZE - len(b23.serialize()) - 69 + script_length = MAX_BLOCK_SIZE - b23.get_weight() - 69 script_output = CScript([b'\x00' * script_length]) tx.vout.append(CTxOut(0, script_output)) tx.vin.append(CTxIn(COutPoint(b23.vtx[1].sha256, 0))) b23 = self.update_block(23, [tx]) # Make sure the math above worked out to produce a max-sized block - assert_equal(len(b23.serialize()), MAX_BLOCK_SIZE) + assert_equal(b23.get_weight(), MAX_BLOCK_SIZE) self.send_blocks([b23], True) self.save_spendable_output() self.log.info("Reject a block of size MAX_BLOCK_SIZE + 1") self.move_tip(15) b24 = self.next_block(24, spend=out[6]) - script_length = MAX_BLOCK_SIZE - len(b24.serialize()) - 69 + script_length = MAX_BLOCK_SIZE - b24.get_weight() - 69 script_output = CScript([b'\x00' * (script_length + 1)]) tx.vout = [CTxOut(0, script_output)] b24 = self.update_block(24, [tx]) - assert_equal(len(b24.serialize()), MAX_BLOCK_SIZE + 1) + assert_equal(b24.get_weight(), MAX_BLOCK_SIZE + 1) self.send_blocks([b24], success=False, reject_reason='bad-blk-length', reconnect=True) b25 = self.next_block(25, spend=out[7]) @@ -500,13 +500,13 @@ class FullBlockTest(BitcoinTestFramework): # Until block is full, add tx's with 1 satoshi to p2sh_script, the rest to OP_TRUE tx_new = None tx_last = tx - total_size = len(b39.serialize()) - while(total_size < MAX_BLOCK_SIZE): + total_weight = b39.get_weight() + while total_weight < MAX_BLOCK_SIZE: tx_new = self.create_tx(tx_last, 1, 1, p2sh_script) tx_new.vout.append(CTxOut(tx_last.vout[1].nValue - 1, CScript([OP_TRUE]))) tx_new.rehash() - total_size += len(tx_new.serialize()) - if total_size >= MAX_BLOCK_SIZE: + total_weight += tx_new.get_weight() + if total_weight >= MAX_BLOCK_SIZE: break b39.vtx.append(tx_new) # add tx to block tx_last = tx_new @@ -517,7 +517,7 @@ class FullBlockTest(BitcoinTestFramework): # Make sure we didn't accidentally make too big a block. Note that the # size of the block has non-determinism due to the ECDSA signature in # the first transaction. - while (len(b39.serialize()) >= MAX_BLOCK_SIZE): + while b39.get_weight() >= MAX_BLOCK_SIZE: del b39.vtx[-1] b39 = self.update_block(39, []) @@ -938,7 +938,7 @@ class FullBlockTest(BitcoinTestFramework): tx.vout.append(CTxOut(0, script_output)) tx.vin.append(CTxIn(COutPoint(b64a.vtx[1].sha256, 0))) b64a = self.update_block("64a", [tx]) - assert_equal(len(b64a.serialize()), MAX_BLOCK_SIZE + 8) + assert_equal(b64a.get_weight(), MAX_BLOCK_SIZE + 8) self.send_blocks([b64a], success=False, reject_reason='non-canonical ReadCompactSize()') # dashd doesn't disconnect us for sending a bloated block, but if we subsequently @@ -952,7 +952,7 @@ class FullBlockTest(BitcoinTestFramework): b64 = CBlock(b64a) b64.vtx = copy.deepcopy(b64a.vtx) assert_equal(b64.hash, b64a.hash) - assert_equal(len(b64.serialize()), MAX_BLOCK_SIZE) + assert_equal(b64.get_weight(), MAX_BLOCK_SIZE) self.blocks[64] = b64 b64 = self.update_block(64, []) self.send_blocks([b64], True) @@ -1290,12 +1290,12 @@ class FullBlockTest(BitcoinTestFramework): for i in range(89, LARGE_REORG_SIZE + 89): b = self.next_block(i, spend) tx = CTransaction() - script_length = MAX_BLOCK_SIZE - len(b.serialize()) - 69 + script_length = MAX_BLOCK_SIZE - b.get_weight() - 69 script_output = CScript([b'\x00' * script_length]) tx.vout.append(CTxOut(0, script_output)) tx.vin.append(CTxIn(COutPoint(b.vtx[1].sha256, 0))) b = self.update_block(i, [tx]) - assert_equal(len(b.serialize()), MAX_BLOCK_SIZE) + assert_equal(b.get_weight(), MAX_BLOCK_SIZE) blocks.append(b) self.save_spendable_output() spend = self.get_spendable_output() diff --git a/test/functional/mining_prioritisetransaction.py b/test/functional/mining_prioritisetransaction.py index 31b0c15adb..6fee0e876e 100755 --- a/test/functional/mining_prioritisetransaction.py +++ b/test/functional/mining_prioritisetransaction.py @@ -55,8 +55,8 @@ class PrioritiseTransactionTest(BitcoinTestFramework): txids[i] = create_lots_of_big_transactions(self.nodes[0], self.txouts, utxos[start_range:end_range], end_range - start_range, (i+1)*base_fee) # Make sure that the size of each group of transactions exceeds - # MAX_BLOCK_SIZE -- otherwise the test needs to be revised to create - # more transactions. + # MAX_BLOCK_SIZE -- otherwise the test needs to be revised to + # create more transactions. mempool = self.nodes[0].getrawmempool(True) sizes = [0, 0, 0] for i in range(3): diff --git a/test/functional/test_framework/messages.py b/test/functional/test_framework/messages.py index 100b91c9a2..7611ec118c 100755 --- a/test/functional/test_framework/messages.py +++ b/test/functional/test_framework/messages.py @@ -546,6 +546,7 @@ class CTransaction: def get_vsize(self): return len(self.serialize()) + # it's just a helper that return vsize to reduce conflicts during backporting def get_weight(self): return self.get_vsize() @@ -681,6 +682,10 @@ class CBlock(CBlockHeader): self.nNonce += 1 self.rehash() + # it's just a helper that return vsize to reduce conflicts during backporting + def get_weight(self): + return len(self.serialize()) + def __repr__(self): return "CBlock(nVersion=%i hashPrevBlock=%064x hashMerkleRoot=%064x nTime=%s nBits=%08x nNonce=%08x vtx=%s)" \ % (self.nVersion, self.hashPrevBlock, self.hashMerkleRoot, From 1ff42b40e3982f8dc92b592a543fc2449b54ad19 Mon Sep 17 00:00:00 2001 From: Samuel Dobson Date: Mon, 9 Aug 2021 13:37:09 +1200 Subject: [PATCH 4/9] Merge bitcoin/bitcoin#21500: wallet, rpc: add an option to list private descriptors bb822a7af86897a9b6a5d616f193c258e8e76729 wallet, rpc: add listdescriptors private option (S3RK) Pull request description: Rationale: make it possible to backup your wallet with `listdescriptors` command * The default behaviour is still to show public version * For private version only the root xprv is returned Example use-case: ``` > bitcoin-cli -regtest -named createwallet wallet_name=old descriptors=true > bitcoin-cli -regtest -rpcwallet=old listdescriptors true | jq '.descriptors' > descriptors.txt > bitcoin-cli -regtest -named createwallet wallet_name=new descriptors=true blank=true > bitcoin-cli -regtest -rpcwallet=new importdescriptors "$(cat descriptors.txt)" ``` In case of watch-only wallet without private keys there will be following output: ``` error code: -4 error message: Can't get descriptor string. ``` ACKs for top commit: achow101: re-ACK bb822a7af86897a9b6a5d616f193c258e8e76729 Rspigler: tACK bb822a7af86897a9b6a5d616f193c258e8e76729 jonatack: ACK bb822a7af86897a9b6a5d616f193c258e8e76729 per `git diff 2854ddc bb822a7` prayank23: tACK https://github.com/bitcoin/bitcoin/pull/21500/commits/bb822a7af86897a9b6a5d616f193c258e8e76729 meshcollider: Code review ACK bb822a7af86897a9b6a5d616f193c258e8e76729 Tree-SHA512: f6dddc72a74e5667071ccd77f8dce578382e8e29e7ed6a0834ac2e114a6d3918b59c2f194f4079b3259e13d9ba3b4f405619940c3ecb7a1a0344615aed47c43d --- src/rpc/client.cpp | 1 + src/wallet/rpcdump.cpp | 17 ++++++++++---- src/wallet/rpcwallet.cpp | 2 +- src/wallet/scriptpubkeyman.cpp | 9 +++++++- src/wallet/scriptpubkeyman.h | 2 +- test/functional/wallet_listdescriptors.py | 28 +++++++++++++++++++++++ 6 files changed, 52 insertions(+), 7 deletions(-) diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index c97421afd2..2479040381 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -164,6 +164,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "importmulti", 0, "requests" }, { "importmulti", 1, "options" }, { "importdescriptors", 0, "requests" }, + { "listdescriptors", 0, "private" }, { "verifychain", 0, "checklevel" }, { "verifychain", 1, "nblocks" }, { "getblockstats", 0, "hash_or_height" }, diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index d4e93d5d15..3a69d4337f 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -1941,8 +1941,10 @@ RPCHelpMan listdescriptors() { return RPCHelpMan{ "listdescriptors", - "\nList descriptors imported into a descriptor-enabled wallet.", - {}, + "\nList descriptors imported into a descriptor-enabled wallet.\n", + { + {"private", RPCArg::Type::BOOL, RPCArg::Default{false}, "Show private descriptors."} + }, RPCResult{RPCResult::Type::OBJ, "", "", { {RPCResult::Type::STR, "wallet_name", "Name of wallet this operation was performed on"}, {RPCResult::Type::ARR, "descriptors", "Array of descriptor objects", @@ -1962,6 +1964,7 @@ RPCHelpMan listdescriptors() }}, RPCExamples{ HelpExampleCli("listdescriptors", "") + HelpExampleRpc("listdescriptors", "") + + HelpExampleCli("listdescriptors", "true") + HelpExampleRpc("listdescriptors", "true") }, [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue { @@ -1972,6 +1975,11 @@ RPCHelpMan listdescriptors() throw JSONRPCError(RPC_WALLET_ERROR, "listdescriptors is not available for non-descriptor wallets"); } + const bool priv = !request.params[0].isNull() && request.params[0].get_bool(); + if (priv) { + EnsureWalletIsUnlocked(*wallet); + } + LOCK(wallet->cs_wallet); UniValue descriptors(UniValue::VARR); @@ -1985,8 +1993,9 @@ RPCHelpMan listdescriptors() LOCK(desc_spk_man->cs_desc_man); const auto& wallet_descriptor = desc_spk_man->GetWalletDescriptor(); std::string descriptor; - if (!desc_spk_man->GetDescriptorString(descriptor)) { - throw JSONRPCError(RPC_WALLET_ERROR, "Can't get normalized descriptor string."); + + if (!desc_spk_man->GetDescriptorString(descriptor, priv)) { + throw JSONRPCError(RPC_WALLET_ERROR, "Can't get descriptor string."); } spk.pushKV("desc", descriptor); spk.pushKV("timestamp", wallet_descriptor.creation_time); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 4c48f4621d..cbd98674a4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4009,7 +4009,7 @@ RPCHelpMan getaddressinfo() DescriptorScriptPubKeyMan* desc_spk_man = dynamic_cast(pwallet->GetScriptPubKeyMan(scriptPubKey)); if (desc_spk_man) { std::string desc_str; - if (desc_spk_man->GetDescriptorString(desc_str)) { + if (desc_spk_man->GetDescriptorString(desc_str, /* priv */ false)) { ret.pushKV("parent_desc", desc_str); } } diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp index 2a0a19a5da..29ad2f0df8 100644 --- a/src/wallet/scriptpubkeyman.cpp +++ b/src/wallet/scriptpubkeyman.cpp @@ -2403,13 +2403,20 @@ const std::vector DescriptorScriptPubKeyMan::GetScriptPubKeys() const return script_pub_keys; } -bool DescriptorScriptPubKeyMan::GetDescriptorString(std::string& out) const +bool DescriptorScriptPubKeyMan::GetDescriptorString(std::string& out, const bool priv) const { LOCK(cs_desc_man); FlatSigningProvider provider; provider.keys = GetKeys(); + if (priv) { + // For the private version, always return the master key to avoid + // exposing child private keys. The risk implications of exposing child + // private keys together with the parent xpub may be non-obvious for users. + return m_wallet_descriptor.descriptor->ToPrivateString(provider, out); + } + return m_wallet_descriptor.descriptor->ToNormalizedString(provider, out, &m_wallet_descriptor.cache); } diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 7b248d7736..0c833a207d 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -600,7 +600,7 @@ public: const WalletDescriptor GetWalletDescriptor() const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man); const std::vector GetScriptPubKeys() const; - bool GetDescriptorString(std::string& out) const; + bool GetDescriptorString(std::string& out, const bool priv) const; void UpgradeDescriptorCache(); }; diff --git a/test/functional/wallet_listdescriptors.py b/test/functional/wallet_listdescriptors.py index 8896a765f0..b6c82e64e9 100755 --- a/test/functional/wallet_listdescriptors.py +++ b/test/functional/wallet_listdescriptors.py @@ -72,11 +72,39 @@ class ListDescriptorsTest(BitcoinTestFramework): ], } assert_equal(expected, wallet.listdescriptors()) + assert_equal(expected, wallet.listdescriptors(False)) + + self.log.info('Test list private descriptors') + expected_private = { + 'wallet_name': 'w2', + 'descriptors': [ + {'desc': descsum_create('pkh(' + xprv + hardened_path + '/0/*)'), + 'timestamp': 1296688602, + 'active': False, + 'range': [0, 0], + 'next': 0}, + ], + } + assert_equal(expected_private, wallet.listdescriptors(True)) self.log.info("Test listdescriptors with encrypted wallet") wallet.encryptwallet("pass") assert_equal(expected, wallet.listdescriptors()) + self.log.info('Test list private descriptors with encrypted wallet') + assert_raises_rpc_error(-13, 'Please enter the wallet passphrase with walletpassphrase first.', wallet.listdescriptors, True) + wallet.walletpassphrase(passphrase="pass", timeout=1000000) + assert_equal(expected_private, wallet.listdescriptors(True)) + + self.log.info('Test list private descriptors with watch-only wallet') + node.createwallet(wallet_name='watch-only', descriptors=True, disable_private_keys=True) + watch_only_wallet = node.get_wallet_rpc('watch-only') + watch_only_wallet.importdescriptors([{ + 'desc': descsum_create('pkh(' + xpub_acc + ')'), + 'timestamp': 1296688602, + }]) + assert_raises_rpc_error(-4, 'Can\'t get descriptor string', watch_only_wallet.listdescriptors, True) + self.log.info('Test non-active non-range combo descriptor') node.createwallet(wallet_name='w4', blank=True, descriptors=True) wallet = node.get_wallet_rpc('w4') From 62b5358a9c238a670434893973a88f884a20d70f Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Tue, 6 Feb 2018 15:48:56 +0100 Subject: [PATCH 5/9] Merge #11909: contrib: Replace developer keys with list of pgp fingerprints fabb72b contrib: Remove xpired 522739F6 key (MarcoFalke) faeab66 contrib: Replace developer keys with list of pgp fingerprints (MarcoFalke) Pull request description: Having to host a copy of the keys in this repo was a common source of discussion and distraction, caused by problems such as: * Outdated keys. Unclear whether and when to replace by fresh copies. * Unclear when to add a key of a new developer or Gitian builder. The problems are solved by * Having no keys but only the fingerprints * Adding a rule of thumb, when to add a new key Moving the keys to a different repo solves none of these issues, but since the keys are not bound to releases or git branches of Bitcoin Core, they should live somewhere else. Obviously, all keys are hosted and distributed on key servers, but were added to the repo solely for convenience and redundancy. Moving the mirror of those keys to a different repo makes it less distracting to update them -- let's say -- prior to every major release. I updated our `doc/release-process.md` to reflect the new location. DEPENDS_ON https://github.com/bitcoin-core/gitian.sigs/pull/621 Tree-SHA512: c00795a07603190e26dc4526f6ce11e492fb048dc7ef54b38f859b77dcde25f58ec4449f5cf3f85a5e9c2dd2743bde53f7ff03c8eccf0d75d51784a6b164e47d --- contrib/builder-keys/README.md | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/contrib/builder-keys/README.md b/contrib/builder-keys/README.md index c883b3fa6f..e31ac6fa87 100644 --- a/contrib/builder-keys/README.md +++ b/contrib/builder-keys/README.md @@ -1,15 +1,26 @@ -PGP keys -======== +## PGP keys of builders and Developers -This folder contains the public keys of developers and active contributors. +The file `keys.txt` contains fingerprints of the public keys of builders and +active developers. The keys are mainly used to sign git commits or the build results of builds. -You can import the keys into gpg as follows. Also, make sure to fetch the -latest version from the key server to see if any key was revoked in the -meantime. +The most recent version of each pgp key can be found on most pgp key servers. + +Fetch the latest version from the key server to see if any key was revoked in +the meantime. +To fetch the latest version of all pgp keys in your gpg homedir, ```sh -gpg --import ./*.pgp gpg --refresh-keys ``` + +To fetch keys of builders and active developers, feed the list of fingerprints +of the primary keys into gpg: + +```sh +while read fingerprint keyholder_name; do gpg --keyserver hkp://subset.pool.sks-keyservers.net --recv-keys ${fingerprint}; done < ./keys.txt +``` + +Add your key to the list if you provided Guix attestations for two major or +minor releases of Dash Core. From 40a8b925db0bc6decfbb154e283ffccc3914f7f3 Mon Sep 17 00:00:00 2001 From: fanquake Date: Tue, 17 Aug 2021 16:05:02 +0800 Subject: [PATCH 6/9] Merge bitcoin/bitcoin#22688: contrib: use `keys.openpgp.org` to retrieve builder keys 4c43b7d41d11072f382f938379d21cd2e0bcbb47 contrib: use hkps://keys.openpgp.org to retrieve builder keys (fanquake) Pull request description: `hkps://hkps.pool.sks-keyservers.net` is essentially no-longer functional, and a number of distributions and GPG tools have since switched to using the `keys.openpgp.org` key server as their default. See this Debian patch for additional context: https://salsa.debian.org/debian/gnupg2/-/blob/debian/main/debian/patches/Use-hkps-keys.openpgp.org-as-the-default-keyserver.patch Switch to using keys.openpgp.org in the CI as well. ACKs for top commit: MarcoFalke: cr ACK 4c43b7d41d11072f382f938379d21cd2e0bcbb47 Zero-1729: ACK 4c43b7d41d11072f382f938379d21cd2e0bcbb47 Tree-SHA512: e6c72b67778b76f81c659eee0e4195fea9e579587c64921affd35b9d46a077d4e8754b7fb85ca90a9a4bbc5cd5a47b0c6e4c9dbf9a335418a12f774d665e5a19 --- ci/lint/06_script.sh | 2 +- contrib/builder-keys/README.md | 2 +- contrib/verify-commits/README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/lint/06_script.sh b/ci/lint/06_script.sh index 72d0e1c1e5..8da9744bcd 100755 --- a/ci/lint/06_script.sh +++ b/ci/lint/06_script.sh @@ -25,7 +25,7 @@ test/lint/lint-all.sh if [ "$CIRRUS_REPO_FULL_NAME" = "dashpay/dash" ] && [ -n "$CIRRUS_CRON" ]; then git log --merges --before="2 days ago" -1 --format='%H' > ./contrib/verify-commits/trusted-sha512-root-commit - ${CI_RETRY_EXE} gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys $( Date: Thu, 22 Jul 2021 09:47:13 +0200 Subject: [PATCH 7/9] Merge bitcoin-core/gui#381: refactor: Make BitcoinCore class reusable 8169fc4e73a87331e02502fc24e293831765c8b1 qt, refactor: Fix code styling of moved InitExecutor class (Hennadii Stepanov) c82165a55701fe4ff604d7f30163051cd47c2363 qt, refactor: Move InitExecutor class into its own module (Hennadii Stepanov) dbcf56b6c6e939923673b3f07bed7bb3632dbeb1 scripted-diff: Rename BitcoinCore class to InitExecutor (Hennadii Stepanov) 19a1d008310f250b69b7aa764a9f26384d5a4a85 qt: Add BitcoinCore::m_thread member (Hennadii Stepanov) Pull request description: This PR makes the `BitcoinCore` class reusable, i.e., it can be used by the widget-based GUI or by the [QML-based](https://github.com/bitcoin-core/gui-qml/tree/main/src/qml) one, and it makes the divergence between these two repos minimal. The small benefit to the current branch is more structured code. Actually, this PR is ported from https://github.com/bitcoin-core/gui-qml/pull/10. The example of the re-using of the `BitcoinCore` class is https://github.com/bitcoin-core/gui-qml/pull/11. ACKs for top commit: laanwj: ACK 8169fc4e73a87331e02502fc24e293831765c8b1 ryanofsky: Code review ACK 8169fc4e73a87331e02502fc24e293831765c8b1. Only change is switching from `m_executor` from pointer to optional type (thanks for update!) Tree-SHA512: a0552c32d26d9acf42921eb12bcdf68f02d52f7183c688c43257b1a58679f64e45f193ee2d316850c7f0f516561e17abe989fe545bfa05e158ad3f4c66d19bca --- src/Makefile.qt.include | 3 + src/qt/bitcoin.cpp | 124 ++++++++------------------------------ src/qt/bitcoin.h | 35 ++--------- src/qt/initexecutor.cpp | 85 ++++++++++++++++++++++++++ src/qt/initexecutor.h | 47 +++++++++++++++ src/qt/test/test_main.cpp | 1 + 6 files changed, 166 insertions(+), 129 deletions(-) create mode 100644 src/qt/initexecutor.cpp create mode 100644 src/qt/initexecutor.h diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index a97956c48d..4e41925193 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -58,6 +58,7 @@ QT_MOC_CPP = \ qt/moc_editaddressdialog.cpp \ qt/moc_governancelist.cpp \ qt/moc_guiutil.cpp \ + qt/moc_initexecutor.cpp \ qt/moc_intro.cpp \ qt/moc_macdockiconhandler.cpp \ qt/moc_macnotificationhandler.cpp \ @@ -133,6 +134,7 @@ BITCOIN_QT_H = \ qt/governancelist.h \ qt/guiconstants.h \ qt/guiutil.h \ + qt/initexecutor.h \ qt/intro.h \ qt/macdockiconhandler.h \ qt/macnotificationhandler.h \ @@ -222,6 +224,7 @@ BITCOIN_QT_BASE_CPP = \ qt/clientmodel.cpp \ qt/csvmodelwriter.cpp \ qt/guiutil.cpp \ + qt/initexecutor.cpp \ qt/intro.cpp \ qt/modaloverlay.cpp \ qt/networkstyle.cpp \ diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 47b5801c51..1e29750bdd 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -8,21 +8,34 @@ #endif #include -#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include +#include #include -#include #include #include #include #include #include +#include +#include #include +#include +#include +#include +#include #ifdef ENABLE_WALLET #include @@ -30,19 +43,6 @@ #include #endif // ENABLE_WALLET -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - #include #include @@ -52,7 +52,6 @@ #include #include #include -#include #include #include #include @@ -208,72 +207,11 @@ void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, cons } } -BitcoinCore::BitcoinCore(interfaces::Node& node) : - QObject(), m_node(node) -{ -} - -void BitcoinCore::handleRunawayException(const std::exception_ptr e) -{ - PrintExceptionContinue(e, "Runaway exception"); - Q_EMIT runawayException(QString::fromStdString(m_node.getWarnings().translated)); -} - -void BitcoinCore::initialize() -{ - try - { - util::ThreadRename("qt-init"); - qDebug() << __func__ << ": Running initialization in thread"; - interfaces::BlockAndHeaderTipInfo tip_info; - bool rv = m_node.appInitMain(&tip_info); - Q_EMIT initializeResult(rv, tip_info); - } catch (...) { - handleRunawayException(std::current_exception()); - } -} - -void BitcoinCore::restart(QStringList args) -{ - static bool executing_restart{false}; - - if(!executing_restart) { // Only restart 1x, no matter how often a user clicks on a restart-button - executing_restart = true; - try - { - qDebug() << __func__ << ": Running Restart in thread"; - m_node.appPrepareShutdown(); - qDebug() << __func__ << ": Shutdown finished"; - Q_EMIT shutdownResult(); - CExplicitNetCleanup::callCleanup(); - QProcess::startDetached(QApplication::applicationFilePath(), args); - qDebug() << __func__ << ": Restart initiated..."; - QApplication::quit(); - } catch (...) { - handleRunawayException(std::current_exception()); - } - } -} - -void BitcoinCore::shutdown() -{ - try - { - qDebug() << __func__ << ": Running Shutdown in thread"; - m_node.appShutdown(); - qDebug() << __func__ << ": Shutdown finished"; - Q_EMIT shutdownResult(); - } catch (...) { - handleRunawayException(std::current_exception()); - } -} - static int qt_argc = 1; static const char* qt_argv = "dash-qt"; BitcoinApplication::BitcoinApplication(): QApplication(qt_argc, const_cast(&qt_argv)), - coreThread(nullptr), optionsModel(nullptr), clientModel(nullptr), window(nullptr), @@ -287,13 +225,7 @@ BitcoinApplication::BitcoinApplication(): BitcoinApplication::~BitcoinApplication() { - if(coreThread) - { - qDebug() << __func__ << ": Stopping thread"; - coreThread->quit(); - coreThread->wait(); - qDebug() << __func__ << ": Stopped thread"; - } + m_executor.reset(); delete window; window = nullptr; @@ -350,23 +282,16 @@ bool BitcoinApplication::baseInitialize() void BitcoinApplication::startThread() { - if(coreThread) - return; - coreThread = new QThread(this); - BitcoinCore *executor = new BitcoinCore(node()); - executor->moveToThread(coreThread); + assert(!m_executor); + m_executor.emplace(node()); /* communication to and from thread */ - connect(executor, &BitcoinCore::initializeResult, this, &BitcoinApplication::initializeResult); - connect(executor, &BitcoinCore::shutdownResult, this, &BitcoinApplication::shutdownResult); - connect(executor, &BitcoinCore::runawayException, this, &BitcoinApplication::handleRunawayException); - connect(this, &BitcoinApplication::requestedInitialize, executor, &BitcoinCore::initialize); - connect(this, &BitcoinApplication::requestedShutdown, executor, &BitcoinCore::shutdown); - connect(window, &BitcoinGUI::requestedRestart, executor, &BitcoinCore::restart); - /* make sure executor object is deleted in its own thread */ - connect(coreThread, &QThread::finished, executor, &QObject::deleteLater); - - coreThread->start(); + connect(&m_executor.value(), &InitExecutor::initializeResult, this, &BitcoinApplication::initializeResult); + connect(&m_executor.value(), &InitExecutor::shutdownResult, this, &BitcoinApplication::shutdownResult); + connect(&m_executor.value(), &InitExecutor::runawayException, this, &BitcoinApplication::handleRunawayException); + connect(this, &BitcoinApplication::requestedInitialize, &m_executor.value(), &InitExecutor::initialize); + connect(this, &BitcoinApplication::requestedShutdown, &m_executor.value(), &InitExecutor::shutdown); + connect(window, &BitcoinGUI::requestedRestart, &m_executor.value(), &InitExecutor::restart); } void BitcoinApplication::parameterSetup() @@ -399,7 +324,6 @@ void BitcoinApplication::requestShutdown() shutdownWindow.reset(ShutdownWindow::showShutdownWindow(window)); qDebug() << __func__ << ": Requesting shutdown"; - startThread(); window->hide(); // Must disconnect node signals otherwise current thread can deadlock since // no event loop is running. diff --git a/src/qt/bitcoin.h b/src/qt/bitcoin.h index 76ebdb4486..934b841795 100644 --- a/src/qt/bitcoin.h +++ b/src/qt/bitcoin.h @@ -9,11 +9,14 @@ #include #endif -#include +#include +#include + #include #include +#include -#include +#include class BitcoinGUI; class ClientModel; @@ -25,32 +28,6 @@ class WalletController; class WalletModel; -/** Class encapsulating Bitcoin Core startup and shutdown. - * Allows running startup and shutdown in a different thread from the UI thread. - */ -class BitcoinCore: public QObject -{ - Q_OBJECT -public: - explicit BitcoinCore(interfaces::Node& node); - -public Q_SLOTS: - void initialize(); - void shutdown(); - void restart(QStringList args); - -Q_SIGNALS: - void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info); - void shutdownResult(); - void runawayException(const QString &message); - -private: - /// Pass fatal exception message to UI thread - void handleRunawayException(const std::exception_ptr e); - - interfaces::Node& m_node; -}; - /** Main Bitcoin application object */ class BitcoinApplication: public QApplication { @@ -113,7 +90,7 @@ protected: bool event(QEvent* e) override; private: - QThread *coreThread; + std::optional m_executor; OptionsModel *optionsModel; ClientModel *clientModel; BitcoinGUI *window; diff --git a/src/qt/initexecutor.cpp b/src/qt/initexecutor.cpp new file mode 100644 index 0000000000..87d9ecda5b --- /dev/null +++ b/src/qt/initexecutor.cpp @@ -0,0 +1,85 @@ +// Copyright (c) 2014-2021 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 + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +InitExecutor::InitExecutor(interfaces::Node& node) + : QObject(), m_node(node) +{ + this->moveToThread(&m_thread); + m_thread.start(); +} + +InitExecutor::~InitExecutor() +{ + qDebug() << __func__ << ": Stopping thread"; + m_thread.quit(); + m_thread.wait(); + qDebug() << __func__ << ": Stopped thread"; +} + +void InitExecutor::handleRunawayException(const std::exception_ptr e) +{ + PrintExceptionContinue(e, "Runaway exception"); + Q_EMIT runawayException(QString::fromStdString(m_node.getWarnings().translated)); +} + +void InitExecutor::initialize() +{ + try { + util::ThreadRename("qt-init"); + qDebug() << __func__ << ": Running initialization in thread"; + interfaces::BlockAndHeaderTipInfo tip_info; + bool rv = m_node.appInitMain(&tip_info); + Q_EMIT initializeResult(rv, tip_info); + } catch (...) { + handleRunawayException(std::current_exception()); + } +} + +void InitExecutor::restart(QStringList args) +{ + static bool executing_restart{false}; + + if(!executing_restart) { // Only restart 1x, no matter how often a user clicks on a restart-button + executing_restart = true; + try { + qDebug() << __func__ << ": Running Restart in thread"; + m_node.appPrepareShutdown(); + qDebug() << __func__ << ": Shutdown finished"; + Q_EMIT shutdownResult(); + CExplicitNetCleanup::callCleanup(); + QProcess::startDetached(QApplication::applicationFilePath(), args); + qDebug() << __func__ << ": Restart initiated..."; + QApplication::quit(); + } catch (...) { + handleRunawayException(std::current_exception()); + } + } +} + +void InitExecutor::shutdown() +{ + try { + qDebug() << __func__ << ": Running Shutdown in thread"; + m_node.appShutdown(); + qDebug() << __func__ << ": Shutdown finished"; + Q_EMIT shutdownResult(); + } catch (...) { + handleRunawayException(std::current_exception()); + } +} diff --git a/src/qt/initexecutor.h b/src/qt/initexecutor.h new file mode 100644 index 0000000000..f4f11fca8b --- /dev/null +++ b/src/qt/initexecutor.h @@ -0,0 +1,47 @@ +// Copyright (c) 2014-2021 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_QT_INITEXECUTOR_H +#define BITCOIN_QT_INITEXECUTOR_H + +#include + +#include + +#include +#include + +QT_BEGIN_NAMESPACE +class QString; +QT_END_NAMESPACE + +/** Class encapsulating Bitcoin Core startup and shutdown. + * Allows running startup and shutdown in a different thread from the UI thread. + */ +class InitExecutor : public QObject +{ + Q_OBJECT +public: + explicit InitExecutor(interfaces::Node& node); + ~InitExecutor(); + +public Q_SLOTS: + void initialize(); + void shutdown(); + void restart(QStringList args); + +Q_SIGNALS: + void initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info); + void shutdownResult(); + void runawayException(const QString& message); + +private: + /// Pass fatal exception message to UI thread + void handleRunawayException(const std::exception_ptr e); + + interfaces::Node& m_node; + QThread m_thread; +}; + +#endif // BITCOIN_QT_INITEXECUTOR_H diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp index 4bf49ba8a0..465bc62060 100644 --- a/src/qt/test/test_main.cpp +++ b/src/qt/test/test_main.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include From 368a6ef5120beb61df3319c37ce10e6c661a5866 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 12 Aug 2021 02:26:18 +0300 Subject: [PATCH 8/9] Merge bitcoin-core/gui#390: Add SubFeeFromAmount to options 62b125fd197879f112322a1f67a318d6ab22e67a qt, refactor: Fix indentation (Prateek Sancheti) ad28b66e98c9bb3bc7af2545654842544a798601 qt: Add SubFeeFromAmount option (Prateek Sancheti) Pull request description: This PR adds **_SubFeeFromAmount_** option which lets the user select their preferred setting of whether fee for a transaction is to be subtracted from the amount or not for future transactions. The setting chosen by the user is remembered even when the GUI mode is turned off. **_Functionality and Usage:_** - Go to `Settings > Options > Wallet` on _Windows/Linux_ or `bitcoin-qt > Preferences > Wallet` on _macOS_. - The checkbox **Subtract Fee From Amount** corresponds to the added option **SubFeeFromAmount**. - The preferred setting intended to be the default for all future send transactions should be selected by the user. - Click on **OK**. - Go to the **Send** tab in the wallet. - You shall notice, any new Send transaction created will have the preferred setting as chosen by the user.
(Try clicking on Add recipient or even restarting the Node in GUI) Attaching ScreenRecordings to explain the added feature. > Master.mov: Master Branch https://user-images.githubusercontent.com/54016434/127763378-be91837d-d0ab-4ae5-87c0-d303fa70a336.mov > PR.mov: PullRequest https://user-images.githubusercontent.com/54016434/127763404-05b834c1-4082-4fbd-9b05-1528ac898a21.mov Close #386 ACKs for top commit: Talkless: tACK 62b125fd197879f112322a1f67a318d6ab22e67a, tested on Debian Sid with 5.15.2 and it works as described. hebasto: re-ACK 62b125fd197879f112322a1f67a318d6ab22e67a, only removed the unused `SubFeeFromAmountChanged` signal since my [previous](https://github.com/bitcoin-core/gui/pull/390#pullrequestreview-726531766) review. meshcollider: utACK 62b125fd197879f112322a1f67a318d6ab22e67a Tree-SHA512: 932ca89ae578a1e1c426561400d87cf005c231944feaf0f662ff8d88f32bdd65a927a090ea41510a15f8ec0ebcd5529672e9917720eb5ea85f413f081e45d5bb --- src/qt/forms/optionsdialog.ui | 12 +++++++++++- src/qt/optionsdialog.cpp | 1 + src/qt/optionsmodel.cpp | 11 +++++++++++ src/qt/optionsmodel.h | 3 +++ src/qt/sendcoinsentry.cpp | 4 +++- 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index 8f53b2fa8c..300e2520e9 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -139,7 +139,7 @@ true - + @@ -315,6 +315,16 @@ + + + + Whether to set subtract fee from amount as default or not. + + + Subtract &fee from amount by default + + + diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index a5587373bb..5337fb163c 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -325,6 +325,7 @@ void OptionsDialog::setMapper() /* Wallet */ mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures); + mapper->addMapping(ui->subFeeFromAmount, OptionsModel::SubFeeFromAmount); mapper->addMapping(ui->keepChangeAddress, OptionsModel::KeepChangeAddress); mapper->addMapping(ui->showMasternodesTab, OptionsModel::ShowMasternodesTab); mapper->addMapping(ui->showGovernanceTab, OptionsModel::ShowGovernanceTab); diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 874a255b84..fcf84bf5ec 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -222,6 +222,11 @@ void OptionsModel::Init(bool resetSettings) if (!gArgs.SoftSetBoolArg("-spendzeroconfchange", settings.value("bSpendZeroConfChange").toBool())) addOverriddenOption("-spendzeroconfchange"); + if (!settings.contains("SubFeeFromAmount")) { + settings.setValue("SubFeeFromAmount", false); + } + m_sub_fee_from_amount = settings.value("SubFeeFromAmount", false).toBool(); + // CoinJoin if (!settings.contains("nCoinJoinSessions")) settings.setValue("nCoinJoinSessions", DEFAULT_COINJOIN_SESSIONS); @@ -458,6 +463,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const #ifdef ENABLE_WALLET case SpendZeroConfChange: return settings.value("bSpendZeroConfChange"); + case SubFeeFromAmount: + return m_sub_fee_from_amount; case ShowMasternodesTab: return settings.value("fShowMasternodesTab"); case ShowGovernanceTab: @@ -633,6 +640,10 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in setRestartRequired(true); } break; + case SubFeeFromAmount: + m_sub_fee_from_amount = value.toBool(); + settings.setValue("SubFeeFromAmount", m_sub_fee_from_amount); + break; case ShowGovernanceTab: if (settings.value("fShowGovernanceTab") != value) { settings.setValue("fShowGovernanceTab", value); diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index b34804ed21..eaf4a8f6f8 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -67,6 +67,7 @@ public: FontWeightBold, // int Language, // QString CoinControlFeatures, // bool + SubFeeFromAmount, // bool KeepChangeAddress, // bool ThreadsScriptVerif, // int Prune, // bool @@ -105,6 +106,7 @@ public: int getDisplayUnit() const { return nDisplayUnit; } QString getThirdPartyTxUrls() const { return strThirdPartyTxUrls; } bool getCoinControlFeatures() const { return fCoinControlFeatures; } + bool getSubFeeFromAmount() const { return m_sub_fee_from_amount; } bool getKeepChangeAddress() const { return fKeepChangeAddress; } bool getShowAdvancedCJUI() { return fShowAdvancedCJUI; } const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; } @@ -132,6 +134,7 @@ private: int nDisplayUnit; QString strThirdPartyTxUrls; bool fCoinControlFeatures; + bool m_sub_fee_from_amount; bool fKeepChangeAddress; bool fShowAdvancedCJUI; /* settings that were overridden by command-line */ diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index 7fea4dcbec..004c7853c0 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -103,7 +103,9 @@ void SendCoinsEntry::clear() ui->payTo->clear(); ui->addAsLabel->clear(); ui->payAmount->clear(); - ui->checkboxSubtractFeeFromAmount->setCheckState(Qt::Unchecked); + if (model && model->getOptionsModel()) { + ui->checkboxSubtractFeeFromAmount->setChecked(model->getOptionsModel()->getSubFeeFromAmount()); + } ui->messageTextLabel->clear(); ui->messageTextLabel->hide(); ui->messageLabel->hide(); From 750447e345d9f3fcae3d8a63fe7baac5224bfac0 Mon Sep 17 00:00:00 2001 From: "W. J. van der Laan" Date: Fri, 27 Aug 2021 08:26:01 +0200 Subject: [PATCH 9/9] Merge bitcoin/bitcoin#20586: Fix Windows build with --enable-werror BACKPORT NOTE: Missing changes in src/fs.cpp are removed in bitcoin/bitcoin#20744 which is already backported b367745cfe19f6de3f44b3adc90fa08e36e44bb6 ci: Make Cirrus CI Windows build with --enable-werror (Hennadii Stepanov) c713bb2b243881a771ab288340ffeb623c82d7f6 Fix Windows build with --enable-werror on Ubuntu Focal (Hennadii Stepanov) Pull request description: This PR makes possible to cross-compile Windows build with `--enable-werror --enable-suppress-external-warnings`. Some problems are fixed, others are silenced. Also `--enable-werror` is enabled for Cirrus CI Windows build (the last one on Cirrus CI without `--enable-werror`). ACKs for top commit: practicalswift: cr ACK b367745cfe19f6de3f44b3adc90fa08e36e44bb6: patch looks correct laanwj: Code review ACK b367745cfe19f6de3f44b3adc90fa08e36e44bb6 vasild: ACK b367745cfe19f6de3f44b3adc90fa08e36e44bb6 jarolrod: ACK b367745cfe19f6de3f44b3adc90fa08e36e44bb6 Tree-SHA512: 64f5c99b7dad4c0efce80cd45d7074f275bd8411235dc9e0841287bdab64b812c6f8f9d632c35531d0b8210148531f53aaaac77be7699b29d2d6aaae304dbee0 --- ci/test/00_setup_env_win64.sh | 4 ---- configure.ac | 8 +++++++- src/qt/winshutdownmonitor.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/ci/test/00_setup_env_win64.sh b/ci/test/00_setup_env_win64.sh index 487f90e43c..d43a9d0379 100755 --- a/ci/test/00_setup_env_win64.sh +++ b/ci/test/00_setup_env_win64.sh @@ -15,7 +15,3 @@ export RUN_SECURITY_TESTS="false" export GOAL="deploy" export BITCOIN_CONFIG="--enable-gui --enable-reduce-exports --disable-miner --without-boost-process" export DIRECT_WINE_EXEC_TESTS=true - -# Compiler for MinGW-w64 causes false -Wreturn-type warning. -# See https://sourceforge.net/p/mingw-w64/bugs/306/ -export NO_WERROR=1 diff --git a/configure.ac b/configure.ac index 50441b50fb..b8dfee0532 100644 --- a/configure.ac +++ b/configure.ac @@ -462,7 +462,13 @@ if test "x$enable_werror" = "xyes"; then AX_CHECK_COMPILE_FLAG([-Werror=range-loop-analysis],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=range-loop-analysis"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Werror=unused-variable],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unused-variable"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Werror=date-time],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=date-time"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=return-type],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=return-type"],,[[$CXXFLAG_WERROR]]) + + dnl -Wreturn-type is broken in GCC for MinGW-w64. + dnl https://sourceforge.net/p/mingw-w64/bugs/306/ + AX_CHECK_COMPILE_FLAG([-Werror=return-type], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=return-type"], [], [$CXXFLAG_WERROR], + [AC_LANG_SOURCE([[#include + int f(){ assert(false); }]])]) + AX_CHECK_COMPILE_FLAG([-Werror=conditional-uninitialized],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=conditional-uninitialized"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Werror=sign-compare],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=sign-compare"],,[[$CXXFLAG_WERROR]]) dnl -Wsuggest-override is broken with GCC before 9.2 diff --git a/src/qt/winshutdownmonitor.h b/src/qt/winshutdownmonitor.h index c8a523a538..02aad606c1 100644 --- a/src/qt/winshutdownmonitor.h +++ b/src/qt/winshutdownmonitor.h @@ -17,7 +17,7 @@ class WinShutdownMonitor : public QAbstractNativeEventFilter { public: /** Implements QAbstractNativeEventFilter interface for processing Windows messages */ - bool nativeEventFilter(const QByteArray &eventType, void *pMessage, long *pnResult); + bool nativeEventFilter(const QByteArray &eventType, void *pMessage, long *pnResult) override; /** Register the reason for blocking shutdown on Windows to allow clean client exit */ static void registerShutdownBlockReason(const QString& strReason, const HWND& mainWinId);