MCPcopy Create free account
hub / github.com/LUX-Core/lux / MakeCollateralAmounts

Method MakeCollateralAmounts

src/darksend.cpp:1679–1720  ·  view source on GitHub ↗

Split up large inputs or create fee sized inputs

Source from the content-addressed store, hash-verified

1677
1678// Split up large inputs or create fee sized inputs
1679bool 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
1723bool CDarkSendPool::CreateDenominated(int64_t nTotalValue) {

Callers

nothing calls this directly

Calls 9

GetScriptForDestinationFunction · 0.85
GetReservedKeyMethod · 0.80
CreateTransactionMethod · 0.80
CommitTransactionMethod · 0.80
HeightMethod · 0.80
GetIDMethod · 0.45
push_backMethod · 0.45
GetHexMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected