Browse Source

[wallet] Add change type to CCoinControl

0.16
João Barbosa 7 years ago
parent
commit
31dbd5af48
  1. 4
      src/wallet/coincontrol.h
  2. 8
      src/wallet/wallet.cpp
  3. 2
      src/wallet/wallet.h

4
src/wallet/coincontrol.h

@ -16,7 +16,10 @@
class CCoinControl class CCoinControl
{ {
public: public:
//! Custom change destination, if not set an address is generated
CTxDestination destChange; CTxDestination destChange;
//! Custom change type, ignored if destChange is set, defaults to g_change_type
OutputType change_type;
//! If false, allows unselected inputs, but requires all selected inputs be used //! If false, allows unselected inputs, but requires all selected inputs be used
bool fAllowOtherInputs; bool fAllowOtherInputs;
//! Includes watch only addresses which match the ISMINE_WATCH_SOLVABLE criteria //! Includes watch only addresses which match the ISMINE_WATCH_SOLVABLE criteria
@ -40,6 +43,7 @@ public:
void SetNull() void SetNull()
{ {
destChange = CNoDestination(); destChange = CNoDestination();
change_type = g_change_type;
fAllowOtherInputs = false; fAllowOtherInputs = false;
fAllowWatchOnly = false; fAllowWatchOnly = false;
setSelected.clear(); setSelected.clear();

8
src/wallet/wallet.cpp

@ -2674,11 +2674,11 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
return true; return true;
} }
OutputType CWallet::TransactionChangeType(const std::vector<CRecipient>& vecSend) OutputType CWallet::TransactionChangeType(OutputType change_type, const std::vector<CRecipient>& vecSend)
{ {
// If -changetype is specified, always use that change type. // If -changetype is specified, always use that change type.
if (g_change_type != OUTPUT_TYPE_NONE) { if (change_type != OUTPUT_TYPE_NONE) {
return g_change_type; return change_type;
} }
// if g_address_type is legacy, use legacy address as change (even // 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
return false; return false;
} }
const OutputType change_type = TransactionChangeType(vecSend); const OutputType change_type = TransactionChangeType(coin_control.change_type, vecSend);
LearnRelatedScripts(vchPubKey, change_type); LearnRelatedScripts(vchPubKey, change_type);
scriptChange = GetScriptForDestination(GetDestinationForKey(vchPubKey, change_type)); scriptChange = GetScriptForDestination(GetDestinationForKey(vchPubKey, change_type));

2
src/wallet/wallet.h

@ -965,7 +965,7 @@ public:
CAmount GetLegacyBalance(const isminefilter& filter, int minDepth, const std::string* account) const; CAmount GetLegacyBalance(const isminefilter& filter, int minDepth, const std::string* account) const;
CAmount GetAvailableBalance(const CCoinControl* coinControl = nullptr) const; CAmount GetAvailableBalance(const CCoinControl* coinControl = nullptr) const;
OutputType TransactionChangeType(const std::vector<CRecipient>& vecSend); OutputType TransactionChangeType(OutputType change_type, const std::vector<CRecipient>& vecSend);
/** /**
* Insert additional inputs into the transaction by * Insert additional inputs into the transaction by

Loading…
Cancel
Save