diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6224f1f5ac..a94a56bbb2 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -5759,6 +5759,8 @@ CWalletTx CWallet::SpendAndStoreSpark( bool CWallet::LelantusToSpark(std::string& strFailReason) { std::list coins = GetAvailableLelantusCoins(); + std::list sigmaCoins = GetAvailableCoins(); + CScript scriptChange; { // Reserve a new key pair from key pool @@ -5774,21 +5776,29 @@ bool CWallet::LelantusToSpark(std::string& strFailReason) { scriptChange = GetScriptForDestination(vchPubKey.GetID()); } - while (coins.size() > 0) { + while (coins.size() > 0 || sigmaCoins.size() > 0) { bool addMoreCoins = true; std::size_t selectedNum = 0; CCoinControl coinControl; CAmount spendValue = 0; while (true) { - auto coin = coins.begin(); COutPoint outPoint; - lelantus::GetOutPoint(outPoint, coin->value); - coinControl.Select(outPoint); - spendValue += coin->amount; - selectedNum ++; - coins.erase(coin); - if (!coins.size()) - break; + if (sigmaCoins.size() > 0) { + auto coin = sigmaCoins.begin(); + sigma::GetOutPoint(outPoint, coin->value); + coinControl.Select(outPoint); + spendValue += coin->get_denomination_value(); + selectedNum++; + sigmaCoins.erase(coin); + } else if (coins.size() > 0) { + auto coin = coins.begin(); + lelantus::GetOutPoint(outPoint, coin->value); + coinControl.Select(outPoint); + spendValue += coin->amount; + selectedNum++; + coins.erase(coin); + } else + break; if ((spendValue + coins.begin()->amount) > Params().GetConsensus().nMaxValueLelantusSpendPerTransaction) break;