Skip to content

Commit 31dbd5a

Browse files
committed
[wallet] Add change type to CCoinControl
1 parent 9594139 commit 31dbd5a

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/wallet/coincontrol.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
class CCoinControl
1717
{
1818
public:
19+
//! Custom change destination, if not set an address is generated
1920
CTxDestination destChange;
21+
//! Custom change type, ignored if destChange is set, defaults to g_change_type
22+
OutputType change_type;
2023
//! If false, allows unselected inputs, but requires all selected inputs be used
2124
bool fAllowOtherInputs;
2225
//! Includes watch only addresses which match the ISMINE_WATCH_SOLVABLE criteria
@@ -40,6 +43,7 @@ class CCoinControl
4043
void SetNull()
4144
{
4245
destChange = CNoDestination();
46+
change_type = g_change_type;
4347
fAllowOtherInputs = false;
4448
fAllowWatchOnly = false;
4549
setSelected.clear();

src/wallet/wallet.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2674,11 +2674,11 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
26742674
return true;
26752675
}
26762676

2677-
OutputType CWallet::TransactionChangeType(const std::vector<CRecipient>& vecSend)
2677+
OutputType CWallet::TransactionChangeType(OutputType change_type, const std::vector<CRecipient>& vecSend)
26782678
{
26792679
// If -changetype is specified, always use that change type.
2680-
if (g_change_type != OUTPUT_TYPE_NONE) {
2681-
return g_change_type;
2680+
if (change_type != OUTPUT_TYPE_NONE) {
2681+
return change_type;
26822682
}
26832683

26842684
// if g_address_type is legacy, use legacy address as change (even
@@ -2797,7 +2797,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
27972797
return false;
27982798
}
27992799

2800-
const OutputType change_type = TransactionChangeType(vecSend);
2800+
const OutputType change_type = TransactionChangeType(coin_control.change_type, vecSend);
28012801

28022802
LearnRelatedScripts(vchPubKey, change_type);
28032803
scriptChange = GetScriptForDestination(GetDestinationForKey(vchPubKey, change_type));

src/wallet/wallet.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ class CWallet final : public CCryptoKeyStore, public CValidationInterface
965965
CAmount GetLegacyBalance(const isminefilter& filter, int minDepth, const std::string* account) const;
966966
CAmount GetAvailableBalance(const CCoinControl* coinControl = nullptr) const;
967967

968-
OutputType TransactionChangeType(const std::vector<CRecipient>& vecSend);
968+
OutputType TransactionChangeType(OutputType change_type, const std::vector<CRecipient>& vecSend);
969969

970970
/**
971971
* Insert additional inputs into the transaction by

0 commit comments

Comments
 (0)