forked from zeroreserve/ZeroReserve
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ZRBitcoin.h
110 lines (81 loc) · 2.43 KB
/
ZRBitcoin.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/*
This file is part of the Zero Reserve Plugin for Retroshare.
Zero Reserve is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zero Reserve is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Zero Reserve. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ZRBITCOIN_H
#define ZRBITCOIN_H
#include "zrtypes.h"
#include "zrdb.h"
namespace ZR
{
class Wallet
{
public:
Wallet() {}
virtual ZR::BitcoinAddress getAddress() = 0;
virtual ZR::ZR_Number getBalance() = 0;
virtual ZR::RetVal persist() = 0;
const std::string & getNick(){ return m_nick; }
void setNick( const std::string & nick ){ m_nick = nick; }
protected:
std::string m_nick;
};
class MyWallet : public Wallet
{
public:
enum WalletType {
BRAINWALLET,
ELECTRUMSEED,
WIFIMPORT,
CASASCIUS,
INVALID
};
MyWallet( WalletType wType ) : m_walletType( wType )
{}
virtual ZR::WalletSeed seed() = 0;
virtual void setSeed( const ZR::WalletSeed & seed ) = 0;
virtual ZR::RetVal getSecret( ZR::WalletSecret & secret_out ) = 0;
protected:
WalletType m_walletType;
};
class PeerWallet : public Wallet
{
PeerWallet();
public:
PeerWallet( const ZR::BitcoinAddress & address ) :
m_Address( address )
{}
virtual ZR::BitcoinAddress getAddress(){ return m_Address; }
virtual ZR::RetVal persist(){
return ZrDB::Instance()->addPeerWallet( m_Address, m_nick );
}
virtual ZR::ZR_Number getBalance(){
return 0;
}
private:
ZR::BitcoinAddress m_Address;
};
class Bitcoin
{
public:
virtual ZR::RetVal commit() = 0;
virtual ZR::RetVal start() = 0;
virtual ZR::RetVal stop() = 0;
virtual ZR::ZR_Number getBalance() = 0;
virtual MyWallet * mkWallet( MyWallet::WalletType wType ) = 0;
virtual void loadWallets( std::vector< ZR::MyWallet *> & wallets ) = 0;
static Bitcoin * Instance();
protected:
static Bitcoin * instance;
};
}
#endif // ZRBITCOIN_H