mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 21:42:47 +01:00
Preparations for upcoming backport of Bitcoin #8580
Instead of deriving from CTransaction, we now have a CTransactionRef member in CTxLockCandidate. This is needed for the next backported PR #8580, which will make CTransaction immutable. Also use CTransactionRef in CDarkSendEntry, CDarksendBroadcastTx and CPrivateSendServer
This commit is contained in:
parent
cb61441e2e
commit
1e62969fa6
@ -91,7 +91,7 @@ bool CInstantSend::ProcessTxLockRequest(const CTxLockRequest& txLockRequest, CCo
|
|||||||
uint256 txHash = txLockRequest.GetHash();
|
uint256 txHash = txLockRequest.GetHash();
|
||||||
|
|
||||||
// Check to see if we conflict with existing completed lock
|
// Check to see if we conflict with existing completed lock
|
||||||
BOOST_FOREACH(const CTxIn& txin, txLockRequest.vin) {
|
BOOST_FOREACH(const CTxIn& txin, txLockRequest.tx->vin) {
|
||||||
std::map<COutPoint, uint256>::iterator it = mapLockedOutpoints.find(txin.prevout);
|
std::map<COutPoint, uint256>::iterator it = mapLockedOutpoints.find(txin.prevout);
|
||||||
if(it != mapLockedOutpoints.end() && it->second != txLockRequest.GetHash()) {
|
if(it != mapLockedOutpoints.end() && it->second != txLockRequest.GetHash()) {
|
||||||
// Conflicting with complete lock, proceed to see if we should cancel them both
|
// Conflicting with complete lock, proceed to see if we should cancel them both
|
||||||
@ -102,7 +102,7 @@ bool CInstantSend::ProcessTxLockRequest(const CTxLockRequest& txLockRequest, CCo
|
|||||||
|
|
||||||
// Check to see if there are votes for conflicting request,
|
// Check to see if there are votes for conflicting request,
|
||||||
// if so - do not fail, just warn user
|
// if so - do not fail, just warn user
|
||||||
BOOST_FOREACH(const CTxIn& txin, txLockRequest.vin) {
|
BOOST_FOREACH(const CTxIn& txin, txLockRequest.tx->vin) {
|
||||||
std::map<COutPoint, std::set<uint256> >::iterator it = mapVotedOutpoints.find(txin.prevout);
|
std::map<COutPoint, std::set<uint256> >::iterator it = mapVotedOutpoints.find(txin.prevout);
|
||||||
if(it != mapVotedOutpoints.end()) {
|
if(it != mapVotedOutpoints.end()) {
|
||||||
BOOST_FOREACH(const uint256& hash, it->second) {
|
BOOST_FOREACH(const uint256& hash, it->second) {
|
||||||
@ -145,7 +145,7 @@ bool CInstantSend::CreateTxLockCandidate(const CTxLockRequest& txLockRequest)
|
|||||||
|
|
||||||
CTxLockCandidate txLockCandidate(txLockRequest);
|
CTxLockCandidate txLockCandidate(txLockRequest);
|
||||||
// all inputs should already be checked by txLockRequest.IsValid() above, just use them now
|
// all inputs should already be checked by txLockRequest.IsValid() above, just use them now
|
||||||
BOOST_REVERSE_FOREACH(const CTxIn& txin, txLockRequest.vin) {
|
BOOST_REVERSE_FOREACH(const CTxIn& txin, txLockRequest.tx->vin) {
|
||||||
txLockCandidate.AddOutPointLock(txin.prevout);
|
txLockCandidate.AddOutPointLock(txin.prevout);
|
||||||
}
|
}
|
||||||
mapTxLockCandidates.insert(std::make_pair(txHash, txLockCandidate));
|
mapTxLockCandidates.insert(std::make_pair(txHash, txLockCandidate));
|
||||||
@ -159,7 +159,7 @@ bool CInstantSend::CreateTxLockCandidate(const CTxLockRequest& txLockRequest)
|
|||||||
LogPrintf("CInstantSend::CreateTxLockCandidate -- update empty, txid=%s\n", txHash.ToString());
|
LogPrintf("CInstantSend::CreateTxLockCandidate -- update empty, txid=%s\n", txHash.ToString());
|
||||||
|
|
||||||
// all inputs should already be checked by txLockRequest.IsValid() above, just use them now
|
// all inputs should already be checked by txLockRequest.IsValid() above, just use them now
|
||||||
BOOST_REVERSE_FOREACH(const CTxIn& txin, txLockRequest.vin) {
|
BOOST_REVERSE_FOREACH(const CTxIn& txin, txLockRequest.tx->vin) {
|
||||||
itLockCandidate->second.AddOutPointLock(txin.prevout);
|
itLockCandidate->second.AddOutPointLock(txin.prevout);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -446,7 +446,7 @@ bool CInstantSend::IsEnoughOrphanVotesForTx(const CTxLockRequest& txLockRequest)
|
|||||||
// There could be a situation when we already have quite a lot of votes
|
// There could be a situation when we already have quite a lot of votes
|
||||||
// but tx lock request still wasn't received. Let's scan through
|
// but tx lock request still wasn't received. Let's scan through
|
||||||
// orphan votes to check if this is the case.
|
// orphan votes to check if this is the case.
|
||||||
BOOST_FOREACH(const CTxIn& txin, txLockRequest.vin) {
|
BOOST_FOREACH(const CTxIn& txin, txLockRequest.tx->vin) {
|
||||||
if(!IsEnoughOrphanVotesForTxAndOutPoint(txLockRequest.GetHash(), txin.prevout)) {
|
if(!IsEnoughOrphanVotesForTxAndOutPoint(txLockRequest.GetHash(), txin.prevout)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -483,7 +483,7 @@ void CInstantSend::TryToFinalizeLockCandidate(const CTxLockCandidate& txLockCand
|
|||||||
#endif
|
#endif
|
||||||
LOCK(cs_instantsend);
|
LOCK(cs_instantsend);
|
||||||
|
|
||||||
uint256 txHash = txLockCandidate.txLockRequest.GetHash();
|
uint256 txHash = txLockCandidate.txLockRequest.tx->GetHash();
|
||||||
if(txLockCandidate.IsAllOutPointsReady() && !IsLockedInstantSendTransaction(txHash)) {
|
if(txLockCandidate.IsAllOutPointsReady() && !IsLockedInstantSendTransaction(txHash)) {
|
||||||
// we have enough votes now
|
// we have enough votes now
|
||||||
LogPrint("instantsend", "CInstantSend::TryToFinalizeLockCandidate -- Transaction Lock is ready to complete, txid=%s\n", txHash.ToString());
|
LogPrint("instantsend", "CInstantSend::TryToFinalizeLockCandidate -- Transaction Lock is ready to complete, txid=%s\n", txHash.ToString());
|
||||||
@ -520,7 +520,7 @@ void CInstantSend::UpdateLockedTransaction(const CTxLockCandidate& txLockCandida
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GetMainSignals().NotifyTransactionLock(txLockCandidate.txLockRequest);
|
GetMainSignals().NotifyTransactionLock(*txLockCandidate.txLockRequest.tx);
|
||||||
|
|
||||||
LogPrint("instantsend", "CInstantSend::UpdateLockedTransaction -- done, txid=%s\n", txHash.ToString());
|
LogPrint("instantsend", "CInstantSend::UpdateLockedTransaction -- done, txid=%s\n", txHash.ToString());
|
||||||
}
|
}
|
||||||
@ -564,7 +564,7 @@ bool CInstantSend::ResolveConflicts(const CTxLockCandidate& txLockCandidate)
|
|||||||
|
|
||||||
LOCK(mempool.cs); // protect mempool.mapNextTx
|
LOCK(mempool.cs); // protect mempool.mapNextTx
|
||||||
|
|
||||||
BOOST_FOREACH(const CTxIn& txin, txLockCandidate.txLockRequest.vin) {
|
BOOST_FOREACH(const CTxIn& txin, txLockCandidate.txLockRequest.tx->vin) {
|
||||||
uint256 hashConflicting;
|
uint256 hashConflicting;
|
||||||
if(GetLockedOutPointTxHash(txin.prevout, hashConflicting) && txHash != hashConflicting) {
|
if(GetLockedOutPointTxHash(txin.prevout, hashConflicting) && txHash != hashConflicting) {
|
||||||
// completed lock which conflicts with another completed one?
|
// completed lock which conflicts with another completed one?
|
||||||
@ -615,7 +615,7 @@ bool CInstantSend::ResolveConflicts(const CTxLockCandidate& txLockCandidate)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Not in block yet, make sure all its inputs are still unspent
|
// Not in block yet, make sure all its inputs are still unspent
|
||||||
BOOST_FOREACH(const CTxIn& txin, txLockCandidate.txLockRequest.vin) {
|
BOOST_FOREACH(const CTxIn& txin, txLockCandidate.txLockRequest.tx->vin) {
|
||||||
Coin coin;
|
Coin coin;
|
||||||
if(!GetUTXOCoin(txin.prevout, coin)) {
|
if(!GetUTXOCoin(txin.prevout, coin)) {
|
||||||
// Not in UTXO anymore? A conflicting tx was mined while we were waiting for votes.
|
// Not in UTXO anymore? A conflicting tx was mined while we were waiting for votes.
|
||||||
@ -927,21 +927,21 @@ std::string CInstantSend::ToString()
|
|||||||
|
|
||||||
bool CTxLockRequest::IsValid() const
|
bool CTxLockRequest::IsValid() const
|
||||||
{
|
{
|
||||||
if(vout.size() < 1) return false;
|
if(tx->vout.size() < 1) return false;
|
||||||
|
|
||||||
if(vin.size() > WARN_MANY_INPUTS) {
|
if(tx->vin.size() > WARN_MANY_INPUTS) {
|
||||||
LogPrint("instantsend", "CTxLockRequest::IsValid -- WARNING: Too many inputs: tx=%s", ToString());
|
LogPrint("instantsend", "CTxLockRequest::IsValid -- WARNING: Too many inputs: tx=%s", ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
if(!CheckFinalTx(*this)) {
|
if(!CheckFinalTx(*tx)) {
|
||||||
LogPrint("instantsend", "CTxLockRequest::IsValid -- Transaction is not final: tx=%s", ToString());
|
LogPrint("instantsend", "CTxLockRequest::IsValid -- Transaction is not final: tx=%s", ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAmount nValueIn = 0;
|
CAmount nValueIn = 0;
|
||||||
|
|
||||||
BOOST_FOREACH(const CTxIn& txin, vin) {
|
BOOST_FOREACH(const CTxIn& txin, tx->vin) {
|
||||||
|
|
||||||
Coin coin;
|
Coin coin;
|
||||||
|
|
||||||
@ -968,7 +968,7 @@ bool CTxLockRequest::IsValid() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAmount nValueOut = GetValueOut();
|
CAmount nValueOut = tx->GetValueOut();
|
||||||
|
|
||||||
if(nValueIn - nValueOut < GetMinFee()) {
|
if(nValueIn - nValueOut < GetMinFee()) {
|
||||||
LogPrint("instantsend", "CTxLockRequest::IsValid -- did not include enough fees in transaction: fees=%d, tx=%s", nValueOut - nValueIn, ToString());
|
LogPrint("instantsend", "CTxLockRequest::IsValid -- did not include enough fees in transaction: fees=%d, tx=%s", nValueOut - nValueIn, ToString());
|
||||||
@ -981,12 +981,12 @@ bool CTxLockRequest::IsValid() const
|
|||||||
CAmount CTxLockRequest::GetMinFee() const
|
CAmount CTxLockRequest::GetMinFee() const
|
||||||
{
|
{
|
||||||
CAmount nMinFee = MIN_FEE;
|
CAmount nMinFee = MIN_FEE;
|
||||||
return std::max(nMinFee, CAmount(vin.size() * nMinFee));
|
return std::max(nMinFee, CAmount(tx->vin.size() * nMinFee));
|
||||||
}
|
}
|
||||||
|
|
||||||
int CTxLockRequest::GetMaxSignatures() const
|
int CTxLockRequest::GetMaxSignatures() const
|
||||||
{
|
{
|
||||||
return vin.size() * COutPointLock::SIGNATURES_TOTAL;
|
return tx->vin.size() * COutPointLock::SIGNATURES_TOTAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -1204,7 +1204,7 @@ bool CTxLockCandidate::IsTimedOut() const
|
|||||||
|
|
||||||
void CTxLockCandidate::Relay(CConnman& connman) const
|
void CTxLockCandidate::Relay(CConnman& connman) const
|
||||||
{
|
{
|
||||||
connman.RelayTransaction(txLockRequest);
|
connman.RelayTransaction(*txLockRequest.tx);
|
||||||
std::map<COutPoint, COutPointLock>::const_iterator itOutpointLock = mapOutPointLocks.begin();
|
std::map<COutPoint, COutPointLock>::const_iterator itOutpointLock = mapOutPointLocks.begin();
|
||||||
while(itOutpointLock != mapOutPointLocks.end()) {
|
while(itOutpointLock != mapOutPointLocks.end()) {
|
||||||
itOutpointLock->second.Relay(connman);
|
itOutpointLock->second.Relay(connman);
|
||||||
|
@ -119,7 +119,7 @@ public:
|
|||||||
std::string ToString();
|
std::string ToString();
|
||||||
};
|
};
|
||||||
|
|
||||||
class CTxLockRequest : public CTransaction
|
class CTxLockRequest
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
static const CAmount MIN_FEE = 0.0001 * COIN;
|
static const CAmount MIN_FEE = 0.0001 * COIN;
|
||||||
@ -127,13 +127,40 @@ private:
|
|||||||
public:
|
public:
|
||||||
static const int WARN_MANY_INPUTS = 100;
|
static const int WARN_MANY_INPUTS = 100;
|
||||||
|
|
||||||
CTxLockRequest() = default;
|
CTransactionRef tx;
|
||||||
CTxLockRequest(const CTransaction& tx) : CTransaction(tx) {};
|
|
||||||
|
CTxLockRequest() : tx(MakeTransactionRef()) {}
|
||||||
|
CTxLockRequest(const CTransaction& _tx) : tx(MakeTransactionRef(_tx)) {};
|
||||||
|
|
||||||
|
ADD_SERIALIZE_METHODS;
|
||||||
|
|
||||||
|
template <typename Stream, typename Operation>
|
||||||
|
inline void SerializationOp(Stream& s, Operation ser_action) {
|
||||||
|
READWRITE(tx);
|
||||||
|
}
|
||||||
|
|
||||||
bool IsValid() const;
|
bool IsValid() const;
|
||||||
CAmount GetMinFee() const;
|
CAmount GetMinFee() const;
|
||||||
int GetMaxSignatures() const;
|
int GetMaxSignatures() const;
|
||||||
|
|
||||||
|
const uint256 &GetHash() const {
|
||||||
|
return tx->GetHash();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ToString() const {
|
||||||
|
return tx->ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
friend bool operator==(const CTxLockRequest& a, const CTxLockRequest& b)
|
||||||
|
{
|
||||||
|
return *a.tx == *b.tx;
|
||||||
|
}
|
||||||
|
|
||||||
|
friend bool operator!=(const CTxLockRequest& a, const CTxLockRequest& b)
|
||||||
|
{
|
||||||
|
return *a.tx != *b.tx;
|
||||||
|
}
|
||||||
|
|
||||||
explicit operator bool() const
|
explicit operator bool() const
|
||||||
{
|
{
|
||||||
return *this != CTxLockRequest();
|
return *this != CTxLockRequest();
|
||||||
|
@ -1621,11 +1621,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
vRecv >> tx;
|
vRecv >> tx;
|
||||||
} else if(strCommand == NetMsgType::TXLOCKREQUEST) {
|
} else if(strCommand == NetMsgType::TXLOCKREQUEST) {
|
||||||
vRecv >> txLockRequest;
|
vRecv >> txLockRequest;
|
||||||
tx = txLockRequest;
|
tx = *txLockRequest.tx;
|
||||||
nInvType = MSG_TXLOCK_REQUEST;
|
nInvType = MSG_TXLOCK_REQUEST;
|
||||||
} else if (strCommand == NetMsgType::DSTX) {
|
} else if (strCommand == NetMsgType::DSTX) {
|
||||||
vRecv >> dstx;
|
vRecv >> dstx;
|
||||||
tx = dstx.tx;
|
tx = *dstx.tx;
|
||||||
nInvType = MSG_DSTX;
|
nInvType = MSG_DSTX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, std::string& strCommand, C
|
|||||||
CDarkSendEntry entry;
|
CDarkSendEntry entry;
|
||||||
vRecv >> entry;
|
vRecv >> entry;
|
||||||
|
|
||||||
LogPrint("privatesend", "DSVIN -- txCollateral %s", entry.txCollateral.ToString());
|
LogPrint("privatesend", "DSVIN -- txCollateral %s", entry.txCollateral->ToString());
|
||||||
|
|
||||||
if(entry.vecTxDSIn.size() > PRIVATESEND_ENTRY_MAX_SIZE) {
|
if(entry.vecTxDSIn.size() > PRIVATESEND_ENTRY_MAX_SIZE) {
|
||||||
LogPrintf("DSVIN -- ERROR: too many inputs! %d/%d\n", entry.vecTxDSIn.size(), PRIVATESEND_ENTRY_MAX_SIZE);
|
LogPrintf("DSVIN -- ERROR: too many inputs! %d/%d\n", entry.vecTxDSIn.size(), PRIVATESEND_ENTRY_MAX_SIZE);
|
||||||
@ -398,13 +398,13 @@ void CPrivateSendServer::ChargeFees(CConnman& connman)
|
|||||||
//we don't need to charge collateral for every offence.
|
//we don't need to charge collateral for every offence.
|
||||||
if(GetRandInt(100) > 33) return;
|
if(GetRandInt(100) > 33) return;
|
||||||
|
|
||||||
std::vector<CTransaction> vecOffendersCollaterals;
|
std::vector<CTransactionRef> vecOffendersCollaterals;
|
||||||
|
|
||||||
if(nState == POOL_STATE_ACCEPTING_ENTRIES) {
|
if(nState == POOL_STATE_ACCEPTING_ENTRIES) {
|
||||||
BOOST_FOREACH(const CTransaction& txCollateral, vecSessionCollaterals) {
|
BOOST_FOREACH(CTransactionRef txCollateral, vecSessionCollaterals) {
|
||||||
bool fFound = false;
|
bool fFound = false;
|
||||||
BOOST_FOREACH(const CDarkSendEntry& entry, vecEntries)
|
BOOST_FOREACH(const CDarkSendEntry& entry, vecEntries)
|
||||||
if(entry.txCollateral == txCollateral)
|
if(*entry.txCollateral == *txCollateral)
|
||||||
fFound = true;
|
fFound = true;
|
||||||
|
|
||||||
// This queue entry didn't send us the promised transaction
|
// This queue entry didn't send us the promised transaction
|
||||||
@ -441,17 +441,17 @@ void CPrivateSendServer::ChargeFees(CConnman& connman)
|
|||||||
|
|
||||||
if(nState == POOL_STATE_ACCEPTING_ENTRIES || nState == POOL_STATE_SIGNING) {
|
if(nState == POOL_STATE_ACCEPTING_ENTRIES || nState == POOL_STATE_SIGNING) {
|
||||||
LogPrintf("CPrivateSendServer::ChargeFees -- found uncooperative node (didn't %s transaction), charging fees: %s\n",
|
LogPrintf("CPrivateSendServer::ChargeFees -- found uncooperative node (didn't %s transaction), charging fees: %s\n",
|
||||||
(nState == POOL_STATE_SIGNING) ? "sign" : "send", vecOffendersCollaterals[0].ToString());
|
(nState == POOL_STATE_SIGNING) ? "sign" : "send", vecOffendersCollaterals[0]->ToString());
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
bool fMissingInputs;
|
bool fMissingInputs;
|
||||||
if(!AcceptToMemoryPool(mempool, state, vecOffendersCollaterals[0], false, &fMissingInputs, false, maxTxFee)) {
|
if(!AcceptToMemoryPool(mempool, state, *vecOffendersCollaterals[0], false, &fMissingInputs, false, maxTxFee)) {
|
||||||
// should never really happen
|
// should never really happen
|
||||||
LogPrintf("CPrivateSendServer::ChargeFees -- ERROR: AcceptToMemoryPool failed!\n");
|
LogPrintf("CPrivateSendServer::ChargeFees -- ERROR: AcceptToMemoryPool failed!\n");
|
||||||
} else {
|
} else {
|
||||||
connman.RelayTransaction(vecOffendersCollaterals[0]);
|
connman.RelayTransaction(*vecOffendersCollaterals[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -474,19 +474,19 @@ void CPrivateSendServer::ChargeRandomFees(CConnman& connman)
|
|||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
BOOST_FOREACH(const CTransaction& txCollateral, vecSessionCollaterals) {
|
BOOST_FOREACH(CTransactionRef txCollateral, vecSessionCollaterals) {
|
||||||
|
|
||||||
if(GetRandInt(100) > 10) return;
|
if(GetRandInt(100) > 10) return;
|
||||||
|
|
||||||
LogPrintf("CPrivateSendServer::ChargeRandomFees -- charging random fees, txCollateral=%s", txCollateral.ToString());
|
LogPrintf("CPrivateSendServer::ChargeRandomFees -- charging random fees, txCollateral=%s", txCollateral->ToString());
|
||||||
|
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
bool fMissingInputs;
|
bool fMissingInputs;
|
||||||
if(!AcceptToMemoryPool(mempool, state, txCollateral, false, &fMissingInputs, false, maxTxFee)) {
|
if(!AcceptToMemoryPool(mempool, state, *txCollateral, false, &fMissingInputs, false, maxTxFee)) {
|
||||||
// should never really happen
|
// should never really happen
|
||||||
LogPrintf("CPrivateSendServer::ChargeRandomFees -- ERROR: AcceptToMemoryPool failed!\n");
|
LogPrintf("CPrivateSendServer::ChargeRandomFees -- ERROR: AcceptToMemoryPool failed!\n");
|
||||||
} else {
|
} else {
|
||||||
connman.RelayTransaction(txCollateral);
|
connman.RelayTransaction(*txCollateral);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -590,7 +590,7 @@ bool CPrivateSendServer::AddEntry(const CDarkSendEntry& entryNew, PoolMessage& n
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!CPrivateSend::IsCollateralValid(entryNew.txCollateral)) {
|
if(!CPrivateSend::IsCollateralValid(*entryNew.txCollateral)) {
|
||||||
LogPrint("privatesend", "CPrivateSendServer::AddEntry -- collateral not valid!\n");
|
LogPrint("privatesend", "CPrivateSendServer::AddEntry -- collateral not valid!\n");
|
||||||
nMessageIDRet = ERR_INVALID_COLLATERAL;
|
nMessageIDRet = ERR_INVALID_COLLATERAL;
|
||||||
return false;
|
return false;
|
||||||
@ -738,7 +738,7 @@ bool CPrivateSendServer::CreateNewSession(int nDenom, CTransaction txCollateral,
|
|||||||
vecDarksendQueue.push_back(dsq);
|
vecDarksendQueue.push_back(dsq);
|
||||||
}
|
}
|
||||||
|
|
||||||
vecSessionCollaterals.push_back(txCollateral);
|
vecSessionCollaterals.push_back(MakeTransactionRef(txCollateral));
|
||||||
LogPrintf("CPrivateSendServer::CreateNewSession -- new session created, nSessionID: %d nSessionDenom: %d (%s) vecSessionCollaterals.size(): %d\n",
|
LogPrintf("CPrivateSendServer::CreateNewSession -- new session created, nSessionID: %d nSessionDenom: %d (%s) vecSessionCollaterals.size(): %d\n",
|
||||||
nSessionID, nSessionDenom, CPrivateSend::GetDenominationsToString(nSessionDenom), vecSessionCollaterals.size());
|
nSessionID, nSessionDenom, CPrivateSend::GetDenominationsToString(nSessionDenom), vecSessionCollaterals.size());
|
||||||
|
|
||||||
@ -771,7 +771,7 @@ bool CPrivateSendServer::AddUserToExistingSession(int nDenom, CTransaction txCol
|
|||||||
|
|
||||||
nMessageIDRet = MSG_NOERR;
|
nMessageIDRet = MSG_NOERR;
|
||||||
nTimeLastSuccessfulStep = GetTimeMillis();
|
nTimeLastSuccessfulStep = GetTimeMillis();
|
||||||
vecSessionCollaterals.push_back(txCollateral);
|
vecSessionCollaterals.push_back(MakeTransactionRef(txCollateral));
|
||||||
|
|
||||||
LogPrintf("CPrivateSendServer::AddUserToExistingSession -- new user accepted, nSessionID: %d nSessionDenom: %d (%s) vecSessionCollaterals.size(): %d\n",
|
LogPrintf("CPrivateSendServer::AddUserToExistingSession -- new user accepted, nSessionID: %d nSessionDenom: %d (%s) vecSessionCollaterals.size(): %d\n",
|
||||||
nSessionID, nSessionDenom, CPrivateSend::GetDenominationsToString(nSessionDenom), vecSessionCollaterals.size());
|
nSessionID, nSessionDenom, CPrivateSend::GetDenominationsToString(nSessionDenom), vecSessionCollaterals.size());
|
||||||
|
@ -20,7 +20,7 @@ class CPrivateSendServer : public CPrivateSendBase
|
|||||||
private:
|
private:
|
||||||
// Mixing uses collateral transactions to trust parties entering the pool
|
// Mixing uses collateral transactions to trust parties entering the pool
|
||||||
// to behave honestly. If they don't it takes their money.
|
// to behave honestly. If they don't it takes their money.
|
||||||
std::vector<CTransaction> vecSessionCollaterals;
|
std::vector<CTransactionRef> vecSessionCollaterals;
|
||||||
|
|
||||||
bool fUnitTest;
|
bool fUnitTest;
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ bool CDarksendBroadcastTx::Sign()
|
|||||||
{
|
{
|
||||||
if(!fMasterNode) return false;
|
if(!fMasterNode) return false;
|
||||||
|
|
||||||
std::string strMessage = tx.GetHash().ToString() + boost::lexical_cast<std::string>(sigTime);
|
std::string strMessage = tx->GetHash().ToString() + boost::lexical_cast<std::string>(sigTime);
|
||||||
|
|
||||||
if(!CMessageSigner::SignMessage(strMessage, vchSig, activeMasternode.keyMasternode)) {
|
if(!CMessageSigner::SignMessage(strMessage, vchSig, activeMasternode.keyMasternode)) {
|
||||||
LogPrintf("CDarksendBroadcastTx::Sign -- SignMessage() failed\n");
|
LogPrintf("CDarksendBroadcastTx::Sign -- SignMessage() failed\n");
|
||||||
@ -92,7 +92,7 @@ bool CDarksendBroadcastTx::Sign()
|
|||||||
|
|
||||||
bool CDarksendBroadcastTx::CheckSignature(const CPubKey& pubKeyMasternode)
|
bool CDarksendBroadcastTx::CheckSignature(const CPubKey& pubKeyMasternode)
|
||||||
{
|
{
|
||||||
std::string strMessage = tx.GetHash().ToString() + boost::lexical_cast<std::string>(sigTime);
|
std::string strMessage = tx->GetHash().ToString() + boost::lexical_cast<std::string>(sigTime);
|
||||||
std::string strError = "";
|
std::string strError = "";
|
||||||
|
|
||||||
if(!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
|
if(!CMessageSigner::VerifyMessage(pubKeyMasternode, vchSig, strMessage, strError)) {
|
||||||
@ -382,7 +382,7 @@ std::string CPrivateSend::GetMessageByID(PoolMessage nMessageID)
|
|||||||
void CPrivateSend::AddDSTX(const CDarksendBroadcastTx& dstx)
|
void CPrivateSend::AddDSTX(const CDarksendBroadcastTx& dstx)
|
||||||
{
|
{
|
||||||
LOCK(cs_mapdstx);
|
LOCK(cs_mapdstx);
|
||||||
mapDSTX.insert(std::make_pair(dstx.tx.GetHash(), dstx));
|
mapDSTX.insert(std::make_pair(dstx.tx->GetHash(), dstx));
|
||||||
}
|
}
|
||||||
|
|
||||||
CDarksendBroadcastTx CPrivateSend::GetDSTX(const uint256& hash)
|
CDarksendBroadcastTx CPrivateSend::GetDSTX(const uint256& hash)
|
||||||
|
@ -104,21 +104,21 @@ class CDarkSendEntry
|
|||||||
public:
|
public:
|
||||||
std::vector<CTxDSIn> vecTxDSIn;
|
std::vector<CTxDSIn> vecTxDSIn;
|
||||||
std::vector<CTxOut> vecTxOut;
|
std::vector<CTxOut> vecTxOut;
|
||||||
CTransaction txCollateral;
|
CTransactionRef txCollateral;
|
||||||
// memory only
|
// memory only
|
||||||
CService addr;
|
CService addr;
|
||||||
|
|
||||||
CDarkSendEntry() :
|
CDarkSendEntry() :
|
||||||
vecTxDSIn(std::vector<CTxDSIn>()),
|
vecTxDSIn(std::vector<CTxDSIn>()),
|
||||||
vecTxOut(std::vector<CTxOut>()),
|
vecTxOut(std::vector<CTxOut>()),
|
||||||
txCollateral(CTransaction()),
|
txCollateral(MakeTransactionRef()),
|
||||||
addr(CService())
|
addr(CService())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CDarkSendEntry(const std::vector<CTxDSIn>& vecTxDSIn, const std::vector<CTxOut>& vecTxOut, const CTransaction& txCollateral) :
|
CDarkSendEntry(const std::vector<CTxDSIn>& vecTxDSIn, const std::vector<CTxOut>& vecTxOut, const CTransaction& txCollateral) :
|
||||||
vecTxDSIn(vecTxDSIn),
|
vecTxDSIn(vecTxDSIn),
|
||||||
vecTxOut(vecTxOut),
|
vecTxOut(vecTxOut),
|
||||||
txCollateral(txCollateral),
|
txCollateral(MakeTransactionRef(txCollateral)),
|
||||||
addr(CService())
|
addr(CService())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -216,25 +216,25 @@ private:
|
|||||||
int nConfirmedHeight;
|
int nConfirmedHeight;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CTransaction tx;
|
CTransactionRef tx;
|
||||||
CTxIn vin;
|
CTxIn vin;
|
||||||
std::vector<unsigned char> vchSig;
|
std::vector<unsigned char> vchSig;
|
||||||
int64_t sigTime;
|
int64_t sigTime;
|
||||||
|
|
||||||
CDarksendBroadcastTx() :
|
CDarksendBroadcastTx() :
|
||||||
nConfirmedHeight(-1),
|
nConfirmedHeight(-1),
|
||||||
tx(),
|
tx(MakeTransactionRef()),
|
||||||
vin(),
|
vin(),
|
||||||
vchSig(),
|
vchSig(),
|
||||||
sigTime(0)
|
sigTime(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CDarksendBroadcastTx(CTransaction tx, COutPoint outpoint, int64_t sigTime) :
|
CDarksendBroadcastTx(const CTransaction& _tx, COutPoint _outpoint, int64_t _sigTime) :
|
||||||
nConfirmedHeight(-1),
|
nConfirmedHeight(-1),
|
||||||
tx(tx),
|
tx(MakeTransactionRef(_tx)),
|
||||||
vin(CTxIn(outpoint)),
|
vin(CTxIn(_outpoint)),
|
||||||
vchSig(),
|
vchSig(),
|
||||||
sigTime(sigTime)
|
sigTime(_sigTime)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
ADD_SERIALIZE_METHODS;
|
ADD_SERIALIZE_METHODS;
|
||||||
@ -249,7 +249,7 @@ public:
|
|||||||
|
|
||||||
friend bool operator==(const CDarksendBroadcastTx& a, const CDarksendBroadcastTx& b)
|
friend bool operator==(const CDarksendBroadcastTx& a, const CDarksendBroadcastTx& b)
|
||||||
{
|
{
|
||||||
return a.tx == b.tx;
|
return *a.tx == *b.tx;
|
||||||
}
|
}
|
||||||
friend bool operator!=(const CDarksendBroadcastTx& a, const CDarksendBroadcastTx& b)
|
friend bool operator!=(const CDarksendBroadcastTx& a, const CDarksendBroadcastTx& b)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user