aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test/script_standard_tests.cpp6
-rw-r--r--src/wallet/wallet.cpp7
2 files changed, 11 insertions, 2 deletions
diff --git a/src/test/script_standard_tests.cpp b/src/test/script_standard_tests.cpp
index de990d9254..b185d3b4ac 100644
--- a/src/test/script_standard_tests.cpp
+++ b/src/test/script_standard_tests.cpp
@@ -13,6 +13,12 @@
BOOST_FIXTURE_TEST_SUITE(script_standard_tests, BasicTestingSetup)
+BOOST_AUTO_TEST_CASE(dest_default_is_no_dest)
+{
+ CTxDestination dest;
+ BOOST_CHECK(!IsValidDestination(dest));
+}
+
BOOST_AUTO_TEST_CASE(script_standard_Solver_success)
{
CKey keys[3];
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 004ec57eb6..2b45c6a536 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2713,7 +2713,10 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
error = _("Transaction needs a change address, but we can't generate it. Please call keypoolrefill first.");
}
scriptChange = GetScriptForDestination(dest);
- assert(!dest.empty() || scriptChange.empty());
+ // A valid destination implies a change script (and
+ // vice-versa). An empty change script will abort later, if the
+ // change keypool ran out, but change is required.
+ CHECK_NONFATAL(IsValidDestination(dest) != scriptChange.empty());
}
CTxOut change_prototype_txout(0, scriptChange);
coin_selection_params.change_output_size = GetSerializeSize(change_prototype_txout);
@@ -2930,7 +2933,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
continue;
}
- // Give up if change keypool ran out and we failed to find a solution without change:
+ // Give up if change keypool ran out and change is required
if (scriptChange.empty() && nChangePosInOut != -1) {
return false;
}