Line data Source code
1 : // Copyright (c) 2011-2013 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 :
5 : #ifndef BITCOIN_COINCONTROL_H
6 : #define BITCOIN_COINCONTROL_H
7 :
8 : #include "primitives/transaction.h"
9 :
10 : /** Coin Control Features. */
11 66 : class CCoinControl
12 : {
13 : public:
14 : CTxDestination destChange;
15 : //! If false, allows unselected inputs, but requires all selected inputs be used
16 : bool fAllowOtherInputs;
17 : //! Includes watch only addresses which match the ISMINE_WATCH_SOLVABLE criteria
18 : bool fAllowWatchOnly;
19 :
20 0 : CCoinControl()
21 44 : {
22 22 : SetNull();
23 0 : }
24 :
25 22 : void SetNull()
26 : {
27 44 : destChange = CNoDestination();
28 22 : fAllowOtherInputs = false;
29 22 : fAllowWatchOnly = false;
30 22 : setSelected.clear();
31 22 : }
32 :
33 : bool HasSelected() const
34 : {
35 544 : return (setSelected.size() > 0);
36 : }
37 :
38 0 : bool IsSelected(const uint256& hash, unsigned int n) const
39 : {
40 : COutPoint outpt(hash, n);
41 0 : return (setSelected.count(outpt) > 0);
42 : }
43 :
44 : void Select(const COutPoint& output)
45 : {
46 8 : setSelected.insert(output);
47 : }
48 :
49 : void UnSelect(const COutPoint& output)
50 : {
51 0 : setSelected.erase(output);
52 : }
53 :
54 : void UnSelectAll()
55 : {
56 0 : setSelected.clear();
57 : }
58 :
59 : void ListSelected(std::vector<COutPoint>& vOutpoints) const
60 : {
61 96 : vOutpoints.assign(setSelected.begin(), setSelected.end());
62 : }
63 :
64 : private:
65 : std::set<COutPoint> setSelected;
66 : };
67 :
68 : #endif // BITCOIN_COINCONTROL_H
|