Split up large inputs or create fee sized inputs
| 1677 | |
| 1678 | // Split up large inputs or create fee sized inputs |
| 1679 | bool CDarkSendPool::MakeCollateralAmounts() { |
| 1680 | // make our change address |
| 1681 | CReserveKey reservekey(pwalletMain); |
| 1682 | |
| 1683 | CScript scriptChange; |
| 1684 | CPubKey vchPubKey; |
| 1685 | assert(reservekey.GetReservedKey(vchPubKey, false)); // should never fail, as we just unlocked |
| 1686 | scriptChange = GetScriptForDestination(vchPubKey.GetID()); |
| 1687 | |
| 1688 | CWalletTx wtx; |
| 1689 | int64_t nFeeRet = 0; |
| 1690 | std::string strFail = ""; |
| 1691 | std::vector<CRecipient> vecSend; |
| 1692 | |
| 1693 | CRecipient recipient = {scriptChange, (DARKSEND_COLLATERAL * 2) + DARKSEND_FEE, false}; |
| 1694 | vecSend.push_back(recipient); |
| 1695 | |
| 1696 | CCoinControl* coinControl = NULL; |
| 1697 | int nChangePos = -1; |
| 1698 | //int32_t nChangePos; |
| 1699 | // try to use non-denominated and not mn-like funds |
| 1700 | //bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey, nFeeRet, nChangePos, strFail, coinControl, ONLY_NONDENOMINATED_NOTMN); |
| 1701 | bool success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey, nFeeRet, nChangePos, strFail, coinControl, ONLY_NONDENOMINATED_NOTMN); |
| 1702 | if (!success) { |
| 1703 | // if we failed (most likeky not enough funds), try to use denominated instead - |
| 1704 | // MN-like funds should not be touched in any case and we can't mix denominated without collaterals anyway |
| 1705 | //success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey, nFeeRet, nChangePos, strFail, coinControl, ONLY_DENOMINATED); |
| 1706 | success = pwalletMain->CreateTransaction(vecSend, wtx, reservekey, nFeeRet, nChangePos, strFail, coinControl, ONLY_DENOMINATED); |
| 1707 | if (!success) { |
| 1708 | LogPrintf("MakeCollateralAmounts: Error - %s\n", strFail.c_str()); |
| 1709 | return false; |
| 1710 | } |
| 1711 | } |
| 1712 | |
| 1713 | // use the same cachedLastSuccess as for DS mixinx to prevent race |
| 1714 | if (pwalletMain->CommitTransaction(wtx, reservekey)) |
| 1715 | cachedLastSuccess = chainActive.Height(); |
| 1716 | |
| 1717 | LogPrintf("MakeCollateralAmounts Success: tx %s\n", wtx.GetHash().GetHex().c_str()); |
| 1718 | |
| 1719 | return true; |
| 1720 | } |
| 1721 | |
| 1722 | // Create denominations |
| 1723 | bool CDarkSendPool::CreateDenominated(int64_t nTotalValue) { |
nothing calls this directly
no test coverage detected