You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

coincontrol.h 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright (c) 2011-2015 The Bitcoin Core developers
  2. // Distributed under the MIT software license, see the accompanying
  3. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
  4. #ifndef BITCOIN_COINCONTROL_H
  5. #define BITCOIN_COINCONTROL_H
  6. #include "primitives/transaction.h"
  7. /** Coin Control Features. */
  8. class CCoinControl
  9. {
  10. public:
  11. CTxDestination destChange;
  12. //! If false, allows unselected inputs, but requires all selected inputs be used
  13. bool fAllowOtherInputs;
  14. //! Includes watch only addresses which match the ISMINE_WATCH_SOLVABLE criteria
  15. bool fAllowWatchOnly;
  16. //! Minimum absolute fee (not per kilobyte)
  17. CAmount nMinimumTotalFee;
  18. CCoinControl()
  19. {
  20. SetNull();
  21. }
  22. void SetNull()
  23. {
  24. destChange = CNoDestination();
  25. fAllowOtherInputs = false;
  26. fAllowWatchOnly = false;
  27. setSelected.clear();
  28. nMinimumTotalFee = 0;
  29. }
  30. bool HasSelected() const
  31. {
  32. return (setSelected.size() > 0);
  33. }
  34. bool IsSelected(const uint256& hash, unsigned int n) const
  35. {
  36. COutPoint outpt(hash, n);
  37. return (setSelected.count(outpt) > 0);
  38. }
  39. void Select(const COutPoint& output)
  40. {
  41. setSelected.insert(output);
  42. }
  43. void UnSelect(const COutPoint& output)
  44. {
  45. setSelected.erase(output);
  46. }
  47. void UnSelectAll()
  48. {
  49. setSelected.clear();
  50. }
  51. void ListSelected(std::vector<COutPoint>& vOutpoints) const
  52. {
  53. vOutpoints.assign(setSelected.begin(), setSelected.end());
  54. }
  55. private:
  56. std::set<COutPoint> setSelected;
  57. };
  58. #endif // BITCOIN_COINCONTROL_H