Skip to content

Commit fa47cf9

Browse files
author
MarcoFalke
committed
wallet: Fix typo in assert that is compile-time true
1 parent ae32e5c commit fa47cf9

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/test/script_standard_tests.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313

1414
BOOST_FIXTURE_TEST_SUITE(script_standard_tests, BasicTestingSetup)
1515

16+
BOOST_AUTO_TEST_CASE(dest_default_is_no_dest)
17+
{
18+
CTxDestination dest;
19+
BOOST_CHECK(!IsValidDestination(dest));
20+
}
21+
1622
BOOST_AUTO_TEST_CASE(script_standard_Solver_success)
1723
{
1824
CKey keys[3];

src/wallet/wallet.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2777,7 +2777,10 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
27772777
strFailReason = _("Transaction needs a change address, but we can't generate it. Please call keypoolrefill first.").translated;
27782778
}
27792779
scriptChange = GetScriptForDestination(dest);
2780-
assert(!dest.empty() || scriptChange.empty());
2780+
// A valid destination implies a change script (and
2781+
// vice-versa). An empty change script will abort later, if the
2782+
// change keypool ran out, but change is required.
2783+
CHECK_NONFATAL(IsValidDestination(dest) != scriptChange.empty());
27812784
}
27822785
CTxOut change_prototype_txout(0, scriptChange);
27832786
coin_selection_params.change_output_size = GetSerializeSize(change_prototype_txout);
@@ -2994,7 +2997,7 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
29942997
continue;
29952998
}
29962999

2997-
// Give up if change keypool ran out and we failed to find a solution without change:
3000+
// Give up if change keypool ran out and change is required
29983001
if (scriptChange.empty() && nChangePosInOut != -1) {
29993002
return false;
30003003
}

0 commit comments

Comments
 (0)