diff options
Diffstat (limited to 'src/main.h')
| -rw-r--r-- | src/main.h | 45 |
1 files changed, 44 insertions, 1 deletions
| @@ -342,9 +342,52 @@ struct WalletRecoveryAudit | |||
| 342 | } | 342 | } |
| 343 | }; | 343 | }; |
| 344 | WalletRecoveryAudit GetWalletRecoveryAudit(); | 344 | WalletRecoveryAudit GetWalletRecoveryAudit(); |
| 345 | bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& txNew, int64& nFeeRequiredRet); | 345 | |
| 346 | // Why a send did not go through. | ||
| 347 | // | ||
| 348 | // The pool's payout thread has to decide, on every failed SendMoney, whether | ||
| 349 | // the failure was the wallet's condition (wait for it to change) or a fault | ||
| 350 | // (something is wrong with this payment). It used to guess by re-reading | ||
| 351 | // GetBalance() afterwards and allowing a fixed CENT of headroom for the fee. | ||
| 352 | // That cannot work: the fee here is a step function of the SERIALISED SIZE of | ||
| 353 | // a transaction that no longer exists, and the step is from 0 to 11 * CENT at | ||
| 354 | // 10,000 bytes -- so a one-CENT allowance is either unnecessary or an order of | ||
| 355 | // magnitude short, never right. A pool wallet close to broke selects many | ||
| 356 | // small inputs BECAUSE it is close to broke, which is what pushes the | ||
| 357 | // transaction over 10 KB, so the guess is wrong exactly when the money is | ||
| 358 | // tight. | ||
| 359 | // | ||
| 360 | // The wallet already knows the answer; it just did not say. SelectCoins() | ||
| 361 | // failing is "there is not enough spendable coin to cover the amount plus | ||
| 362 | // whatever fee this size of transaction requires", and it is the only reason | ||
| 363 | // CreateTransaction() can fail that is about funding rather than about the | ||
| 364 | // wallet being broken. | ||
| 365 | enum WalletSendResult | ||
| 366 | { | ||
| 367 | WALLET_SEND_OK = 0, | ||
| 368 | WALLET_SEND_INSUFFICIENT_FUNDS, // coin selection could not cover amount+fee | ||
| 369 | WALLET_SEND_FAILED // anything else: could not build, sign or accept | ||
| 370 | }; | ||
| 371 | |||
| 372 | // What the wallet did with a send request. nFeeRequired is the fee the | ||
| 373 | // transaction turned out to need, which for a failed send is what coin | ||
| 374 | // selection was asked for on top of the amount and could not find -- 0 if it | ||
| 375 | // never got that far. | ||
| 376 | struct SendMoneyOutcome | ||
| 377 | { | ||
| 378 | WalletSendResult result = WALLET_SEND_OK; | ||
| 379 | int64 nFeeRequired = 0; | ||
| 380 | }; | ||
| 381 | |||
| 382 | bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& txNew, int64& nFeeRequiredRet, | ||
| 383 | WalletSendResult* presultRet=NULL); | ||
| 346 | bool CommitTransactionSpent(const CWalletTx& wtxNew); | 384 | bool CommitTransactionSpent(const CWalletTx& wtxNew); |
| 385 | // The three-argument form is kept, and kept as a distinct declaration rather | ||
| 386 | // than a defaulted argument, because gui.cpp declares SendMoney itself instead | ||
| 387 | // of including this header. | ||
| 347 | bool SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew); | 388 | bool SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew); |
| 389 | bool SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, | ||
| 390 | SendMoneyOutcome& outcomeRet); | ||
| 348 | 391 | ||
| 349 | 392 | ||
| 350 | 393 | ||