@@ -3690,6 +3690,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
3690
3690
3691
3691
CAmount nFeePay = fUseInstantSend ? CTxLockRequest ().GetMinFee (true ) : 0 ;
3692
3692
std::string strOpType;
3693
+ CScript prevScriptPubKey;
3693
3694
3694
3695
CAmount nValue = 0 ;
3695
3696
int nChangePosRequest = nChangePosInOut;
@@ -3768,6 +3769,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
3768
3769
return false ;
3769
3770
}
3770
3771
if (strOpType == " bdap_new_account" ) {
3772
+ // Use BDAP credits first.
3771
3773
AvailableCoins (vAvailableCoins, true , coinControl, false , nCoinType, fUseInstantSend );
3772
3774
}
3773
3775
else if (strOpType == " bdap_update_account" || strOpType == " bdap_delete_account" ) {
@@ -3792,7 +3794,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
3792
3794
strFailReason = _ (" GetDomainEntryInfo failed to find previous domanin entry transaction." );
3793
3795
return false ;
3794
3796
}
3795
- CScript prevScriptPubKey;
3797
+
3796
3798
GetBDAPOpScript (prevTx, prevScriptPubKey);
3797
3799
GetBDAPCoins (vAvailableCoins, prevScriptPubKey);
3798
3800
}
@@ -3967,11 +3969,13 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
3967
3969
CScript scriptChange;
3968
3970
3969
3971
// coin control: send change to custom address
3970
- if (coinControl && !boost::get<CNoDestination>(&coinControl->destChange ))
3972
+ if (coinControl && !boost::get<CNoDestination>(&coinControl->destChange )) {
3971
3973
scriptChange = GetScriptForDestination (coinControl->destChange );
3972
-
3973
- // no coin control: send change to newly generated address
3974
- else {
3974
+ } else if (strOpType == " bdap_update_account" || strOpType == " bdap_delete_account" ) {
3975
+ // send deposit change back to original account.
3976
+ scriptChange = prevScriptPubKey;
3977
+ } else {
3978
+ // no coin control: send change to newly generated address
3975
3979
// Note: We use a new key here to keep it from being obvious which side is the change.
3976
3980
// The drawback is that by not reusing a previous key, the change may be lost if a
3977
3981
// backup is restored, if the backup doesn't have the new private key for the change.
@@ -4118,7 +4122,8 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
4118
4122
// if (dPriorityNeeded > 0 && dPriority >= dPriorityNeeded)
4119
4123
// break;
4120
4124
}
4121
- CAmount nFeeNeeded = std::max (nFeePay, GetMinimumFee (nBytes, currentConfirmationTarget, mempool));
4125
+ // Standard fee not needed for BDAP
4126
+ CAmount nFeeNeeded = !fIsBDAP ? std::max (nFeePay, GetMinimumFee (nBytes, currentConfirmationTarget, mempool)) : 0 ;
4122
4127
if (coinControl && nFeeNeeded > 0 && coinControl->nMinimumTotalFee > nFeeNeeded) {
4123
4128
nFeeNeeded = coinControl->nMinimumTotalFee ;
4124
4129
}
@@ -4132,7 +4137,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
4132
4137
4133
4138
// If we made it here and we aren't even able to meet the relay fee on the next pass, give up
4134
4139
// because we must be at the maximum allowed fee.
4135
- if (nFeeNeeded < ::minRelayTxFee.GetFee (nBytes)) {
4140
+ if (! fIsBDAP && nFeeNeeded < ::minRelayTxFee.GetFee (nBytes)) {
4136
4141
strFailReason = _ (" Transaction too large for fee policy" );
4137
4142
return false ;
4138
4143
}
0 commit comments