Skip to content

Commit dd831d9

Browse files
author
benjyc
committed
structure
1 parent b0a8431 commit dd831d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+38744
-0
lines changed

bitcoin-0.1.0.tgz

2.8 MB
Binary file not shown.

bitcoin0.1/bitcoin.exe

6.14 MB
Binary file not shown.

bitcoin0.1/libeay32.dll

1.25 MB
Binary file not shown.

bitcoin0.1/license.txt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2009 Satoshi Nakamoto
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in
11+
all copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
THE SOFTWARE.

bitcoin0.1/mingwm10.dll

11.4 KB
Binary file not shown.

bitcoin0.1/readme.txt

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
BitCoin v0.01 ALPHA
2+
3+
Copyright (c) 2009 Satoshi Nakamoto
4+
Distributed under the MIT/X11 software license, see the accompanying
5+
file license.txt or http://www.opensource.org/licenses/mit-license.php.
6+
This product includes software developed by the OpenSSL Project for use in
7+
the OpenSSL Toolkit (http://www.openssl.org/). This product includes
8+
cryptographic software written by Eric Young ([email protected]).
9+
10+
11+
Intro
12+
-----
13+
Bitcoin is an electronic cash system that uses a peer-to-peer network to
14+
prevent double-spending. It's completely decentralized with no server or
15+
central authority.
16+
17+
18+
Operating Systems
19+
-----------------
20+
Windows NT/2000/XP (and probably Vista)
21+
22+
Vista hasn't been tested yet. All the libraries used are cross-platform, so
23+
there's nothing preventing future Linux and Mac builds.
24+
25+
26+
Setup
27+
-----
28+
Unpack the files into a directory and run bitcoin.exe.
29+
30+
The software automatically finds other nodes to connect to. You should set
31+
your firewall to forward port 8333 to your computer so you can receive incoming
32+
connections, otherwise the nodes you can connect with will be limited.
33+
34+
To support the network by running a node, select:
35+
36+
Options->Generate Coins
37+
38+
and keep the program open or minimized. It runs at idle priority when no other
39+
programs are using the CPU. Your computer will be solving a very difficult
40+
computational problem that is used to lock in blocks of transactions. The time
41+
to generate a block varies each time, but may take days or months, depending
42+
on the speed of your computer and the competition on the network. It's not a
43+
computation that has to start over from the beginning if you stop and restart
44+
it. A solution might be found at any given moment it's running. As a reward
45+
for supporting the network, you receive coins when you successfully generate a
46+
block.

bitcoin0.1/src/base58.h

+201
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
// Copyright (c) 2009 Satoshi Nakamoto
2+
// Distributed under the MIT/X11 software license, see the accompanying
3+
// file license.txt or http://www.opensource.org/licenses/mit-license.php.
4+
5+
6+
//
7+
// Why base-58 instead of standard base-64 encoding?
8+
// - Don't want 0OIl characters that look the same in some fonts and
9+
// could be used to create visually identical looking account numbers.
10+
// - A string with non-alphanumeric characters is not as easily accepted as an account number.
11+
// - E-mail usually won't line-break if there's no punctuation to break at.
12+
// - Doubleclicking selects the whole number as one word if it's all alphanumeric.
13+
//
14+
15+
16+
static const char* pszBase58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
17+
18+
19+
inline string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend)
20+
{
21+
CAutoBN_CTX pctx;
22+
CBigNum bn58 = 58;
23+
CBigNum bn0 = 0;
24+
25+
// Convert big endian data to little endian
26+
// Extra zero at the end make sure bignum will interpret as a positive number
27+
vector<unsigned char> vchTmp(pend-pbegin+1, 0);
28+
reverse_copy(pbegin, pend, vchTmp.begin());
29+
30+
// Convert little endian data to bignum
31+
CBigNum bn;
32+
bn.setvch(vchTmp);
33+
34+
// Convert bignum to string
35+
string str;
36+
str.reserve((pend - pbegin) * 138 / 100 + 1);
37+
CBigNum dv;
38+
CBigNum rem;
39+
while (bn > bn0)
40+
{
41+
if (!BN_div(&dv, &rem, &bn, &bn58, pctx))
42+
throw bignum_error("EncodeBase58 : BN_div failed");
43+
bn = dv;
44+
unsigned int c = rem.getulong();
45+
str += pszBase58[c];
46+
}
47+
48+
// Leading zeroes encoded as base58 zeros
49+
for (const unsigned char* p = pbegin; p < pend && *p == 0; p++)
50+
str += pszBase58[0];
51+
52+
// Convert little endian string to big endian
53+
reverse(str.begin(), str.end());
54+
return str;
55+
}
56+
57+
inline string EncodeBase58(const vector<unsigned char>& vch)
58+
{
59+
return EncodeBase58(&vch[0], &vch[0] + vch.size());
60+
}
61+
62+
inline bool DecodeBase58(const char* psz, vector<unsigned char>& vchRet)
63+
{
64+
CAutoBN_CTX pctx;
65+
vchRet.clear();
66+
CBigNum bn58 = 58;
67+
CBigNum bn = 0;
68+
CBigNum bnChar;
69+
while (isspace(*psz))
70+
psz++;
71+
72+
// Convert big endian string to bignum
73+
for (const char* p = psz; *p; p++)
74+
{
75+
const char* p1 = strchr(pszBase58, *p);
76+
if (p1 == NULL)
77+
{
78+
while (isspace(*p))
79+
p++;
80+
if (*p != '\0')
81+
return false;
82+
break;
83+
}
84+
bnChar.setulong(p1 - pszBase58);
85+
if (!BN_mul(&bn, &bn, &bn58, pctx))
86+
throw bignum_error("DecodeBase58 : BN_mul failed");
87+
bn += bnChar;
88+
}
89+
90+
// Get bignum as little endian data
91+
vector<unsigned char> vchTmp = bn.getvch();
92+
93+
// Trim off sign byte if present
94+
if (vchTmp.size() >= 2 && vchTmp.end()[-1] == 0 && vchTmp.end()[-2] >= 0x80)
95+
vchTmp.erase(vchTmp.end()-1);
96+
97+
// Restore leading zeros
98+
int nLeadingZeros = 0;
99+
for (const char* p = psz; *p == pszBase58[0]; p++)
100+
nLeadingZeros++;
101+
vchRet.assign(nLeadingZeros + vchTmp.size(), 0);
102+
103+
// Convert little endian data to big endian
104+
reverse_copy(vchTmp.begin(), vchTmp.end(), vchRet.end() - vchTmp.size());
105+
return true;
106+
}
107+
108+
inline bool DecodeBase58(const string& str, vector<unsigned char>& vchRet)
109+
{
110+
return DecodeBase58(str.c_str(), vchRet);
111+
}
112+
113+
114+
115+
116+
117+
inline string EncodeBase58Check(const vector<unsigned char>& vchIn)
118+
{
119+
// add 4-byte hash check to the end
120+
vector<unsigned char> vch(vchIn);
121+
uint256 hash = Hash(vch.begin(), vch.end());
122+
vch.insert(vch.end(), (unsigned char*)&hash, (unsigned char*)&hash + 4);
123+
return EncodeBase58(vch);
124+
}
125+
126+
inline bool DecodeBase58Check(const char* psz, vector<unsigned char>& vchRet)
127+
{
128+
if (!DecodeBase58(psz, vchRet))
129+
return false;
130+
if (vchRet.size() < 4)
131+
{
132+
vchRet.clear();
133+
return false;
134+
}
135+
uint256 hash = Hash(vchRet.begin(), vchRet.end()-4);
136+
if (memcmp(&hash, &vchRet.end()[-4], 4) != 0)
137+
{
138+
vchRet.clear();
139+
return false;
140+
}
141+
vchRet.resize(vchRet.size()-4);
142+
return true;
143+
}
144+
145+
inline bool DecodeBase58Check(const string& str, vector<unsigned char>& vchRet)
146+
{
147+
return DecodeBase58Check(str.c_str(), vchRet);
148+
}
149+
150+
151+
152+
153+
154+
155+
static const unsigned char ADDRESSVERSION = 0;
156+
157+
inline string Hash160ToAddress(uint160 hash160)
158+
{
159+
// add 1-byte version number to the front
160+
vector<unsigned char> vch(1, ADDRESSVERSION);
161+
vch.insert(vch.end(), UBEGIN(hash160), UEND(hash160));
162+
return EncodeBase58Check(vch);
163+
}
164+
165+
inline bool AddressToHash160(const char* psz, uint160& hash160Ret)
166+
{
167+
vector<unsigned char> vch;
168+
if (!DecodeBase58Check(psz, vch))
169+
return false;
170+
if (vch.empty())
171+
return false;
172+
unsigned char nVersion = vch[0];
173+
if (vch.size() != sizeof(hash160Ret) + 1)
174+
return false;
175+
memcpy(&hash160Ret, &vch[1], sizeof(hash160Ret));
176+
return (nVersion <= ADDRESSVERSION);
177+
}
178+
179+
inline bool AddressToHash160(const string& str, uint160& hash160Ret)
180+
{
181+
return AddressToHash160(str.c_str(), hash160Ret);
182+
}
183+
184+
inline bool IsValidBitcoinAddress(const char* psz)
185+
{
186+
uint160 hash160;
187+
return AddressToHash160(psz, hash160);
188+
}
189+
190+
inline bool IsValidBitcoinAddress(const string& str)
191+
{
192+
return IsValidBitcoinAddress(str.c_str());
193+
}
194+
195+
196+
197+
198+
inline string PubKeyToAddress(const vector<unsigned char>& vchPubKey)
199+
{
200+
return Hash160ToAddress(Hash160(vchPubKey));
201+
}

0 commit comments

Comments
 (0)