Recursively determine the rounds of a given input (How deep is the darksend chain for a given input)
| 410 | |
| 411 | // Recursively determine the rounds of a given input (How deep is the darksend chain for a given input) |
| 412 | int GetInputDarksendRounds(CTxIn in, int rounds) { |
| 413 | if (rounds >= 17) return rounds; |
| 414 | if (rounds > nDarksendRounds || nDarksendRounds <= 0 || !fEnableDarksend) return rounds; // once we hit the max rounds setting, there's no point going further back (this func is only used for selecting qualifying txs) |
| 415 | |
| 416 | std::string padding = ""; |
| 417 | padding.insert(0, ((rounds + 1) * 5) + 3, ' '); |
| 418 | |
| 419 | const CWalletTx* wtx = pwalletMain->GetWalletTx(in.prevout.hash); |
| 420 | if (wtx != NULL) { |
| 421 | // bounds check |
| 422 | if (in.prevout.n >= wtx->vout.size()) return -4; |
| 423 | |
| 424 | if (wtx->vout[in.prevout.n].nValue == DARKSEND_FEE) return -3; |
| 425 | |
| 426 | //make sure the final output is non-denominate |
| 427 | if (rounds == 0 && !pwalletMain->IsDenominatedAmount(wtx->vout[in.prevout.n].nValue)) return -2; //NOT DENOM |
| 428 | |
| 429 | bool found = false; |
| 430 | for (CTxOut out : wtx->vout) { |
| 431 | found = pwalletMain->IsDenominatedAmount(out.nValue); |
| 432 | if (found) break; // no need to loop more |
| 433 | } |
| 434 | if (!found) return rounds - 1; //NOT FOUND, "-1" because of the pre-mixing creation of denominated amounts |
| 435 | |
| 436 | // find my vin and look that up |
| 437 | for (CTxIn in2 : wtx->vin) { |
| 438 | if (pwalletMain->IsMine(in2)) { |
| 439 | //LogPrintf("rounds :: %s %s %d NEXT\n", padding.c_str(), in.ToString().c_str(), rounds); |
| 440 | int n = GetInputDarksendRounds(in2, rounds + 1); |
| 441 | if (n != -3) return n; |
| 442 | } |
| 443 | } |
| 444 | } |
| 445 | |
| 446 | return rounds - 1; |
| 447 | } |
| 448 | |
| 449 | void CDarkSendPool::Reset() { |
| 450 | cachedLastSuccess = 0; |
no test coverage detected