@@ -4706,14 +4706,28 @@ bool CWallet::CheckCoinSpend(libzerocoin::CoinSpend& spend, libzerocoin::Accumul
47064706 return true ;
47074707}
47084708
4709- bool CWallet::MintToTxIn (CZerocoinMint mint, const uint256& hashTxOut, CTxIn& newTxIn, CZerocoinSpendReceipt& receipt, libzerocoin::SpendType spendType, CBlockIndex* pindexCheckpoint)
4709+ bool CWallet::MintToTxIn (
4710+ CZerocoinMint mint,
4711+ const uint256& hashTxOut,
4712+ CTxIn& newTxIn,
4713+ CZerocoinSpendReceipt& receipt,
4714+ libzerocoin::SpendType spendType,
4715+ CBlockIndex* pindexCheckpoint,
4716+ bool publicCoinSpend)
47104717{
47114718 std::map<CBigNum, CZerocoinMint> mapMints;
47124719 mapMints.insert (std::make_pair (mint.GetValue (), mint));
47134720 std::vector<CTxIn> vin;
4714- if (MintsToInputVectorPublicSpend (mapMints, hashTxOut, vin, receipt, spendType, pindexCheckpoint)) {
4715- newTxIn = vin[0 ];
4716- return true ;
4721+ if (publicCoinSpend) {
4722+ if (MintsToInputVectorPublicSpend (mapMints, hashTxOut, vin, receipt, spendType, pindexCheckpoint)) {
4723+ newTxIn = vin[0 ];
4724+ return true ;
4725+ }
4726+ } else {
4727+ if (MintsToInputVector (mapMints, hashTxOut, vin, receipt, spendType, pindexCheckpoint)) {
4728+ newTxIn = vin[0 ];
4729+ return true ;
4730+ }
47174731 }
47184732
47194733 return false ;
@@ -4901,7 +4915,17 @@ bool CWallet::MintsToInputVectorPublicSpend(std::map<CBigNum, CZerocoinMint>& ma
49014915 return true ;
49024916}
49034917
4904- bool CWallet::CreateZerocoinSpendTransaction (CAmount nValue, CWalletTx& wtxNew, CReserveKey& reserveKey, CZerocoinSpendReceipt& receipt, vector<CZerocoinMint>& vSelectedMints, vector<CDeterministicMint>& vNewMints, bool fMintChange , bool fMinimizeChange , CBitcoinAddress* address)
4918+ bool CWallet::CreateZerocoinSpendTransaction (
4919+ CAmount nValue,
4920+ CWalletTx& wtxNew,
4921+ CReserveKey& reserveKey,
4922+ CZerocoinSpendReceipt& receipt,
4923+ vector<CZerocoinMint>& vSelectedMints,
4924+ vector<CDeterministicMint>& vNewMints,
4925+ bool fMintChange ,
4926+ bool fMinimizeChange ,
4927+ CBitcoinAddress* address,
4928+ bool isPublicSpend)
49054929{
49064930 // Check available funds
49074931 int nStatus = ZPIV_TRX_FUNDS_PROBLEMS;
@@ -5095,8 +5119,15 @@ bool CWallet::CreateZerocoinSpendTransaction(CAmount nValue, CWalletTx& wtxNew,
50955119
50965120 // add all of the mints to the transaction as inputs
50975121 std::vector<CTxIn> vin;
5098- if (!MintsToInputVectorPublicSpend (mapSelectedMints, hashTxOut, vin, receipt, libzerocoin::SpendType::SPEND, pindexCheckpoint))
5099- return false ;
5122+ if (isPublicSpend) {
5123+ if (!MintsToInputVectorPublicSpend (mapSelectedMints, hashTxOut, vin, receipt,
5124+ libzerocoin::SpendType::SPEND, pindexCheckpoint))
5125+ return false ;
5126+ } else {
5127+ if (!MintsToInputVector (mapSelectedMints, hashTxOut, vin, receipt,
5128+ libzerocoin::SpendType::SPEND, pindexCheckpoint))
5129+ return false ;
5130+ }
51005131 txNew.vin = vin;
51015132
51025133 // Limit size
@@ -5402,7 +5433,7 @@ string CWallet::MintZerocoin(CAmount nValue, CWalletTx& wtxNew, vector<CDetermin
54025433 return " " ;
54035434}
54045435
5405- bool CWallet::SpendZerocoin (CAmount nAmount, CWalletTx& wtxNew, CZerocoinSpendReceipt& receipt, vector<CZerocoinMint>& vMintsSelected, bool fMintChange , bool fMinimizeChange , CBitcoinAddress* addressTo)
5436+ bool CWallet::SpendZerocoin (CAmount nAmount, CWalletTx& wtxNew, CZerocoinSpendReceipt& receipt, vector<CZerocoinMint>& vMintsSelected, bool fMintChange , bool fMinimizeChange , CBitcoinAddress* addressTo, bool isPublicSpend )
54065437{
54075438 // Default: assume something goes wrong. Depending on the problem this gets more specific below
54085439 int nStatus = ZPIV_SPEND_ERROR;
@@ -5414,7 +5445,7 @@ bool CWallet::SpendZerocoin(CAmount nAmount, CWalletTx& wtxNew, CZerocoinSpendRe
54145445
54155446 CReserveKey reserveKey (this );
54165447 vector<CDeterministicMint> vNewMints;
5417- if (!CreateZerocoinSpendTransaction (nAmount, wtxNew, reserveKey, receipt, vMintsSelected, vNewMints, fMintChange , fMinimizeChange , addressTo)) {
5448+ if (!CreateZerocoinSpendTransaction (nAmount, wtxNew, reserveKey, receipt, vMintsSelected, vNewMints, fMintChange , fMinimizeChange , addressTo, isPublicSpend )) {
54185449 return false ;
54195450 }
54205451
0 commit comments