]>
Commit | Line | Data |
---|---|---|
effc2770 EL |
1 | // Copyright (c) 2009-2010 Satoshi Nakamoto |
2 | // Copyright (c) 2009-2013 The Bitcoin developers | |
3 | // Distributed under the MIT/X11 software license, see the accompanying | |
4 | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | |
5 | #ifndef BITCOIN_CORE_H | |
6 | #define BITCOIN_CORE_H | |
7 | ||
8 | #include "uint256.h" | |
9 | #include "serialize.h" | |
10 | #include "util.h" | |
11 | ||
12 | #include <stdio.h> | |
13 | ||
14 | /** An outpoint - a combination of a transaction hash and an index n into its vout */ | |
15 | class COutPoint | |
16 | { | |
17 | public: | |
18 | uint256 hash; | |
19 | unsigned int n; | |
20 | ||
21 | COutPoint() { SetNull(); } | |
22 | COutPoint(uint256 hashIn, unsigned int nIn) { hash = hashIn; n = nIn; } | |
23 | IMPLEMENT_SERIALIZE( READWRITE(FLATDATA(*this)); ) | |
24 | void SetNull() { hash = 0; n = (unsigned int) -1; } | |
25 | bool IsNull() const { return (hash == 0 && n == (unsigned int) -1); } | |
26 | ||
27 | friend bool operator<(const COutPoint& a, const COutPoint& b) | |
28 | { | |
29 | return (a.hash < b.hash || (a.hash == b.hash && a.n < b.n)); | |
30 | } | |
31 | ||
32 | friend bool operator==(const COutPoint& a, const COutPoint& b) | |
33 | { | |
34 | return (a.hash == b.hash && a.n == b.n); | |
35 | } | |
36 | ||
37 | friend bool operator!=(const COutPoint& a, const COutPoint& b) | |
38 | { | |
39 | return !(a == b); | |
40 | } | |
41 | ||
42 | std::string ToString() const | |
43 | { | |
44 | return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10).c_str(), n); | |
45 | } | |
46 | ||
47 | void print() const | |
48 | { | |
49 | printf("%s\n", ToString().c_str()); | |
50 | } | |
51 | }; | |
52 | ||
53 | #endif |