mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 21:12:48 +01:00
enable fees, add collateral charging when missing transaction after queuing, require large fee for collateral to stop double spending
This commit is contained in:
parent
4b2a5696ce
commit
b3cbbd104e
@ -227,10 +227,35 @@ void CDarkSendPool::Check()
|
||||
// until the transaction is either complete or fails.
|
||||
//
|
||||
void CDarkSendPool::ChargeFees(){
|
||||
return;
|
||||
|
||||
if(fMasterNode) {
|
||||
int i = 0;
|
||||
|
||||
BOOST_FOREACH(const CTransaction& txCollateral, vecSessionCollateral) {
|
||||
bool found = false;
|
||||
BOOST_FOREACH(const CDarkSendEntry v, entries) {
|
||||
if(v.collateral == txCollateral) found = false;
|
||||
}
|
||||
|
||||
// This queue entry didn't send us the promised transaction
|
||||
if(!found){
|
||||
LogPrintf("CDarkSendPool::ChargeFees -- found uncooperative node (didn't send transaction). charging fees. %u\n", i);
|
||||
|
||||
CWalletTx wtxCollateral = CWalletTx(pwalletMain, txCollateral);
|
||||
|
||||
// Broadcast
|
||||
if (!wtxCollateral.AcceptToMemoryPool(true, false))
|
||||
{
|
||||
// This must not fail. The transaction has already been signed and recorded.
|
||||
LogPrintf("CDarkSendPool::ChargeFees() : Error: Transaction not valid");
|
||||
}
|
||||
wtxCollateral.RelayWalletTransaction();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
||||
// who didn't sign?
|
||||
BOOST_FOREACH(const CDarkSendEntry v, entries) {
|
||||
BOOST_FOREACH(const CDarkSendEntryVin s, v.sev) {
|
||||
@ -396,6 +421,12 @@ bool CDarkSendPool::IsCollateralValid(const CTransaction& txCollateral){
|
||||
if(fDebug) LogPrintf ("CDarkSendPool::IsCollateralValid - not correct amount or addr (0)\n");
|
||||
return false;
|
||||
}
|
||||
//collateral transactions are required to have abnormally large fees associated, to make double
|
||||
//spending very expensive.
|
||||
if(txCollateral.GetValueOut() < DARKSEND_COLLATERAL*2) {
|
||||
if(fDebug) LogPrintf ("CDarkSendPool::IsCollateralValid - did not include enough fees in transaction\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
LogPrintf("CDarkSendPool::IsCollateralValid %s\n", txCollateral.ToString().c_str());
|
||||
|
||||
@ -1743,6 +1774,7 @@ bool CDarkSendPool::IsCompatibleWithSession(int64 nAmount, CTransaction txCollat
|
||||
|
||||
sessionUsers++;
|
||||
lastTimeChanged = GetTimeMillis();
|
||||
vecSessionCollateral.push_back(txCollateral);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ extern std::string strMasterNodePrivKey;
|
||||
extern std::vector<CDarksendQueue> vecDarksendQueue;
|
||||
extern std::vector<CTxIn> vecMasternodeAskedFor;
|
||||
|
||||
static const int64 DARKSEND_COLLATERAL = 0.025*COIN;
|
||||
static const int64 DARKSEND_COLLATERAL = 0.0125*COIN;
|
||||
static const int64 DARKSEND_FEE = 0.0125*COIN;
|
||||
|
||||
|
||||
@ -312,6 +312,7 @@ public:
|
||||
int sessionUsers; //N Users have said they'll join
|
||||
bool sessionFoundMasternode; //If we've found a compatible masternode
|
||||
int sessionTries;
|
||||
std::vector<CTransaction> vecSessionCollateral;
|
||||
|
||||
int lastSplitUpBlock;
|
||||
int splitUpInARow; // how many splits we've done since a success?
|
||||
|
@ -1772,7 +1772,12 @@ int64 CWallet::GetTotalValue(std::vector<CTxIn> vCoins) {
|
||||
|
||||
bool CWallet::CreateCollateralTransaction(CTransaction& txCollateral, std::string strReason)
|
||||
{
|
||||
int64 nFeeRet = 0.001*COIN; ///need to get a better fee calc
|
||||
/*
|
||||
To doublespend a collateral transaction, it will require a fee higher than this. So there's
|
||||
still a significant cost.
|
||||
*/
|
||||
int64 nFeeRet = DARKSEND_COLLATERAL;
|
||||
|
||||
CReserveKey reservekey(this);
|
||||
int64 nValueIn2 = 0;
|
||||
std::vector<CTxIn> vCoinsCollateral;
|
||||
|
Loading…
Reference in New Issue
Block a user