diff options
Diffstat (limited to 'src/main.h')
| -rw-r--r-- | src/main.h | 59 |
1 files changed, 58 insertions, 1 deletions
| @@ -41,6 +41,12 @@ static const int64 MAX_MONEY = 21000000 * COIN; | |||
| 41 | inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); } | 41 | inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); } |
| 42 | static const int64 CENT = 1000000; | 42 | static const int64 CENT = 1000000; |
| 43 | static const int COINBASE_MATURITY = 100; | 43 | static const int COINBASE_MATURITY = 100; |
| 44 | // Depth at which a coinbase we mined is actually usable. CMerkleTx::GetCredit | ||
| 45 | // values a coinbase at zero until GetBlocksToMaturity() reaches 0, which is | ||
| 46 | // this depth -- not COINBASE_MATURITY. Anything that plans to *spend* mined | ||
| 47 | // coin must gate on this, or it will try to pay out of a balance the wallet | ||
| 48 | // still reports as zero. Both rules live here so they cannot drift apart. | ||
| 49 | static const int COINBASE_SPENDABLE_DEPTH = COINBASE_MATURITY + 20; | ||
| 44 | 50 | ||
| 45 | // Bitflash difficulty floor. The PoW is RandomX (memory-hard), ~1000x slower | 51 | // Bitflash difficulty floor. The PoW is RandomX (memory-hard), ~1000x slower |
| 46 | // per hash than SHA-256d, so the target is much easier than Bitcoin's to let a | 52 | // per hash than SHA-256d, so the target is much easier than Bitcoin's to let a |
| @@ -84,6 +90,11 @@ extern int nMineMode; | |||
| 84 | // something a previous session wrote. | 90 | // something a previous session wrote. |
| 85 | extern bool fMineModeFromCommandLine; | 91 | extern bool fMineModeFromCommandLine; |
| 86 | extern string strParticipantPool; // participant: pool .btf address | 92 | extern string strParticipantPool; // participant: pool .btf address |
| 93 | extern string strPayoutAddress; // participant: /payoutaddr override (mine without a wallet) | ||
| 94 | extern string strPayoutFile; // participant: /payoutfile address list, rotated per reconnect | ||
| 95 | extern bool fPoolNoAnnounce; // /noannounce: suppress pool announcements | ||
| 96 | extern bool fPoolMineBlind; // /poolmineblind: mine on even when deaf to every peer | ||
| 97 | extern int nHashThreads; // participant: /hashthreads override (0 = cores-1) | ||
| 87 | extern string strPoolName; // operator: announced pool name | 98 | extern string strPoolName; // operator: announced pool name |
| 88 | extern string strPoolDashboardUrl; // operator: optional dashboard URL | 99 | extern string strPoolDashboardUrl; // operator: optional dashboard URL |
| 89 | extern string strPoolStatusFile; // operator: optional JSON status output path | 100 | extern string strPoolStatusFile; // operator: optional JSON status output path |
| @@ -96,6 +107,9 @@ extern bool fSoloMineTest; // /solomine: mine without requiring a peer (local te | |||
| 96 | extern int nMinerThreads; | 107 | extern int nMinerThreads; |
| 97 | // Resolves the automatic case into a real count. | 108 | // Resolves the automatic case into a real count. |
| 98 | int MinerThreadCount(); | 109 | int MinerThreadCount(); |
| 110 | // Hash threads one participant session runs; resolves /hashthreads. Not the | ||
| 111 | // same number as MinerThreadCount(), and only ONE session ever runs. | ||
| 112 | int ParticipantHashThreadCount(); | ||
| 99 | extern bool gPoolServerRunning; // GUI/startup state | 113 | extern bool gPoolServerRunning; // GUI/startup state |
| 100 | extern volatile bool gPoolRunning; // runtime pool server loop flag (rpc.cpp) | 114 | extern volatile bool gPoolRunning; // runtime pool server loop flag (rpc.cpp) |
| 101 | 115 | ||
| @@ -330,9 +344,52 @@ struct WalletRecoveryAudit | |||
| 330 | } | 344 | } |
| 331 | }; | 345 | }; |
| 332 | WalletRecoveryAudit GetWalletRecoveryAudit(); | 346 | WalletRecoveryAudit GetWalletRecoveryAudit(); |
| 333 | bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& txNew, int64& nFeeRequiredRet); | 347 | |
| 348 | // Why a send did not go through. | ||
| 349 | // | ||
| 350 | // The pool's payout thread has to decide, on every failed SendMoney, whether | ||
| 351 | // the failure was the wallet's condition (wait for it to change) or a fault | ||
| 352 | // (something is wrong with this payment). It used to guess by re-reading | ||
| 353 | // GetBalance() afterwards and allowing a fixed CENT of headroom for the fee. | ||
| 354 | // That cannot work: the fee here is a step function of the SERIALISED SIZE of | ||
| 355 | // a transaction that no longer exists, and the step is from 0 to 11 * CENT at | ||
| 356 | // 10,000 bytes -- so a one-CENT allowance is either unnecessary or an order of | ||
| 357 | // magnitude short, never right. A pool wallet close to broke selects many | ||
| 358 | // small inputs BECAUSE it is close to broke, which is what pushes the | ||
| 359 | // transaction over 10 KB, so the guess is wrong exactly when the money is | ||
| 360 | // tight. | ||
| 361 | // | ||
| 362 | // The wallet already knows the answer; it just did not say. SelectCoins() | ||
| 363 | // failing is "there is not enough spendable coin to cover the amount plus | ||
| 364 | // whatever fee this size of transaction requires", and it is the only reason | ||
| 365 | // CreateTransaction() can fail that is about funding rather than about the | ||
| 366 | // wallet being broken. | ||
| 367 | enum WalletSendResult | ||
| 368 | { | ||
| 369 | WALLET_SEND_OK = 0, | ||
| 370 | WALLET_SEND_INSUFFICIENT_FUNDS, // coin selection could not cover amount+fee | ||
| 371 | WALLET_SEND_FAILED // anything else: could not build, sign or accept | ||
| 372 | }; | ||
| 373 | |||
| 374 | // What the wallet did with a send request. nFeeRequired is the fee the | ||
| 375 | // transaction turned out to need, which for a failed send is what coin | ||
| 376 | // selection was asked for on top of the amount and could not find -- 0 if it | ||
| 377 | // never got that far. | ||
| 378 | struct SendMoneyOutcome | ||
| 379 | { | ||
| 380 | WalletSendResult result = WALLET_SEND_OK; | ||
| 381 | int64 nFeeRequired = 0; | ||
| 382 | }; | ||
| 383 | |||
| 384 | bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& txNew, int64& nFeeRequiredRet, | ||
| 385 | WalletSendResult* presultRet=NULL); | ||
| 334 | bool CommitTransactionSpent(const CWalletTx& wtxNew); | 386 | bool CommitTransactionSpent(const CWalletTx& wtxNew); |
| 387 | // The three-argument form is kept, and kept as a distinct declaration rather | ||
| 388 | // than a defaulted argument, because gui.cpp declares SendMoney itself instead | ||
| 389 | // of including this header. | ||
| 335 | bool SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew); | 390 | bool SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew); |
| 391 | bool SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, | ||
| 392 | SendMoneyOutcome& outcomeRet); | ||
| 336 | 393 | ||
| 337 | 394 | ||
| 338 | 395 | ||