diff options
72 files changed, 4549 insertions, 2587 deletions
diff --git a/.gitignore b/.gitignore index aeeef170e6..c1d06a3dfb 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,9 @@ src/bitcoin src/bitcoind .*.swp *.*~* +*.bak +*.rej +*.orig +*.o +*.patch +.bitcoin @@ -1,16 +1,30 @@ + Bitcoin integration/staging tree Development process =================== -Developers work in their own trees, then submit pull requests when they think their feature or bug fix is ready. +Developers work in their own trees, then submit pull requests when +they think their feature or bug fix is ready. + +If it is a simple/trivial/non-controversial change, then one of the +bitcoin development team members simply pulls it. -If it is a simple/trivial/non-controversial change, then one of the bitcoin development team members simply pulls it. +If it is a more complicated or potentially controversial +change, then the patch submitter will be asked to start a +discussion (if they haven't already) on the mailing list: +http://sourceforge.net/mailarchive/forum.php?forum_name=bitcoin-development -If it is a more complicated or potentially controversial change, then the patch submitter will be asked to start a discussion (if they haven't already) on the development forums: http://www.bitcoin.org/smf/index.php?board=6.0 -The patch will be accepted if there is broad consensus that it is a good thing. Developers should expect to rework and resubmit patches if they don't match the project's coding conventions (see coding.txt) or are controversial. +The patch will be accepted if there is broad consensus that it is a +good thing. Developers should expect to rework and resubmit patches +if they don't match the project's coding conventions (see coding.txt) +or are controversial. -The master branch is regularly built and tested (by who? need people willing to be quality assurance testers), and periodically pushed to the subversion repo to become the official, stable, released bitcoin. +The master branch is regularly built and tested, but is not guaranteed +to be completely stable. Tags are regularly created to indicate new +official, stable release versions of Bitcoin. If you would like to +help test the Bitcoin core, please contact QA@Bitcoin.org. +Feature branches are created when there are major new features being +worked on by several people. -Feature branches are created when there are major new features being worked on by several people. diff --git a/contrib/Bitcoin.app/Contents/Info.plist b/contrib/Bitcoin.app/Contents/Info.plist index bfeb2f8de4..a5c7da1c8f 100644 --- a/contrib/Bitcoin.app/Contents/Info.plist +++ b/contrib/Bitcoin.app/Contents/Info.plist @@ -17,11 +17,11 @@ <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> - <string>0.3.25</string> + <string>0.4.00</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> - <string>325</string> + <string>400</string> <key>LSMinimumSystemVersion</key> <string>10.5</string> <key>CFBundleIconFile</key> diff --git a/contrib/boost-win32.yml b/contrib/boost-win32.yml new file mode 100644 index 0000000000..61ea50e4fe --- /dev/null +++ b/contrib/boost-win32.yml @@ -0,0 +1,38 @@ +--- +name: "boost" +suites: +- "lucid" +architectures: +- "i386" +packages: +- "mingw32" +- "faketime" +- "zip" +reference_datetime: "2011-01-30 00:00:00" +remotes: [] +files: +- "boost_1_47_0.tar.bz2" +script: | + TMPDIR="$HOME/tmpdir" + mkdir -p $TMPDIR/bin/$GBUILD_BITS $TMPDIR/include + tar xjf boost_1_47_0.tar.bz2 + cd boost_1_47_0 + echo "using gcc : 4.4 : i586-mingw32msvc-g++ + : + <rc>i586-mingw32msvc-windres + <archiver>i586-mingw32msvc-ar + <cxxflags>-frandom-seed=boost1 + ;" > user-config.jam + ./bootstrap.sh --without-icu + ./bjam toolset=gcc target-os=windows threadapi=win32 threading=multi variant=release link=static --user-config=user-config.jam --without-mpi --without-python -sNO_BZIP2=1 -sNO_ZLIB=1 --layout=tagged --build-type=complete $MAKEOPTS stage + for lib in chrono date_time exception filesystem graph iostreams math_c99f math_c99l math_c99 math_tr1f math_tr1l math_tr1 prg_exec_monitor program_options random regex serialization signals system test_exec_monitor thread_win32 unit_test_framework wave wserialization; do + mkdir $lib + (cd $lib ; ar xf ../stage/lib/libboost_${lib}-mt-s.a) + mv $lib $TMPDIR/bin/$GBUILD_BITS + done + cp -a boost $TMPDIR/include + cd $TMPDIR + export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1 + export FAKETIME=$REFERENCE_DATETIME + zip -r boost-win32-1.47.0-gitian.zip * + cp boost-win32-1.47.0-gitian.zip $OUTDIR diff --git a/contrib/gitian-win32.yml b/contrib/gitian-win32.yml index 07d31c717e..52b10bc33f 100644 --- a/contrib/gitian-win32.yml +++ b/contrib/gitian-win32.yml @@ -9,25 +9,45 @@ packages: - "git-core" - "unzip" - "nsis" +- "faketime" +- "wine" reference_datetime: "2011-01-30 00:00:00" remotes: - "url": "https://github.com/bitcoin/bitcoin.git" "dir": "bitcoin" files: -- "wxWidgets-2.9.1.tar.bz2" -- "boost_1_43_0.tar.bz2" +- "wxwidgets-win32-2.9.2-gitian.zip" +- "boost-win32-1.47.0-gitian.zip" - "openssl-1.0.0d.tar.gz" -- "db-4.7.25.NC.tar.gz" -- "upnpc-exe-win32-20110215.zip" -- "miniupnpc-1.5.20110215.tar.gz" -- "WSPiApi.h" +- "db-4.8.30.NC.tar.gz" +- "miniupnpc-1.6.tar.gz" script: | # - tar xjf wxWidgets-2.9.1.tar.bz2 - cd wxWidgets-2.9.1 - ./configure --host=i586-mingw32msvc --build=i686-linux --disable-shared --enable-monolithic --without-libpng --disable-svg - perl -i -p -e "s/__TIME__/\"$REFERENCE_TIME\"/;s/__DATE__/\"$REFERENCE_DATE\"/" include/wx/chartype.h - make $MAKEOPTS + mkdir wxWidgets-2.9.2 + cd wxWidgets-2.9.2 + mkdir lib + unzip ../wxwidgets-win32-2.9.2-gitian.zip + cd bin/$GBUILD_BITS + for lib in wx_mswu; do + i586-mingw32msvc-ar rc ../../lib/lib${lib}-2.9-i586-mingw32msvc.a $lib/*.o + i586-mingw32msvc-ranlib ../../lib/lib${lib}-2.9-i586-mingw32msvc.a + done + cp -a wx ../../lib + cd ../.. + mv include/wx-2.9/wx include + cd .. + # + mkdir boost_1_47_0 + cd boost_1_47_0 + mkdir -p stage/lib + unzip ../boost-win32-1.47.0-gitian.zip + cd bin/$GBUILD_BITS + for lib in *; do + i586-mingw32msvc-ar rc ../../stage/lib/libboost_${lib}-mt-s.a $lib/*.o + i586-mingw32msvc-ranlib ../../stage/lib/libboost_${lib}-mt-s.a + done + cd ../.. + mv include/boost . cd .. # tar xzf openssl-1.0.0d.tar.gz @@ -36,33 +56,19 @@ script: | make cd .. # - tar xzf db-4.7.25.NC.tar.gz - cd db-4.7.25.NC/build_unix + tar xzf db-4.8.30.NC.tar.gz + cd db-4.8.30.NC/build_unix ../dist/configure --enable-mingw --enable-cxx --host=i586-mingw32msvc CFLAGS="-I/usr/i586-mingw32msvc/include" make $MAKEOPTS cd ../.. # - tar xjf boost_1_43_0.tar.bz2 - cd boost_1_43_0 - echo "using gcc : 4.4 : i586-mingw32msvc-g++ - : - <rc>i586-mingw32msvc-windres - <archiver>i586-mingw32msvc-ar - ;" > user-config.jam - ./bootstrap.sh --without-icu - ./bjam toolset=gcc target-os=windows threadapi=win32 threading=multi --user-config=user-config.jam --without-mpi --without-python -sNO_BZIP2=1 -sNO_ZLIB=1 --layout=tagged --build-type=complete $MAKEOPTS stage + tar xzf miniupnpc-1.6.tar.gz + cd miniupnpc-1.6 + sed 's/dllwrap -k --driver-name gcc/$(DLLWRAP) -k --driver-name $(CC)/' -i Makefile.mingw + sed 's|wingenminiupnpcstrings $< $@|./wingenminiupnpcstrings $< $@|' -i Makefile.mingw + make -f Makefile.mingw DLLWRAP=i586-mingw32msvc-dllwrap CC=i586-mingw32msvc-gcc AR=i586-mingw32msvc-ar cd .. - # - mkdir upnpc-exe-win32-20110215 - cd upnpc-exe-win32-20110215 - unzip ../upnpc-exe-win32-20110215.zip - mkdir miniupnpc - cd miniupnpc - tar xzf ../../miniupnpc-1.5.20110215.tar.gz - mv ./miniupnpc-1.5.20110215/* ./ - cd ../.. - # - cp WSPiApi.h $HOME/build + mv miniupnpc-1.6 miniupnpc # cd bitcoin mkdir -p $OUTDIR/src @@ -72,8 +78,10 @@ script: | cp $OUTDIR/src/doc/README_windows.txt $OUTDIR/readme.txt cp $OUTDIR/src/COPYING $OUTDIR/license.txt cd src - sed 's/$(DEBUGFLAGS)//' < makefile.linux-mingw > makefile.linux-mingw.2 && mv makefile.linux-mingw.2 makefile.linux-mingw - sed 's|//#include <WSPiApi.h>|#include <WSPiApi.h>|' < net.cpp > net.cpp.2 && mv net.cpp.2 net.cpp + sed 's/$(DEBUGFLAGS)/-frandom-seed=bitcoin/' -i makefile.linux-mingw + export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1 + export FAKETIME=$REFERENCE_DATETIME + export TZ=UTC make -f makefile.linux-mingw $MAKEOPTS DEPSDIR=$HOME/build bitcoin.exe USE_UPNP=1 make -f makefile.linux-mingw $MAKEOPTS DEPSDIR=$HOME/build bitcoind.exe USE_UPNP=0 i586-mingw32msvc-strip bitcoin.exe diff --git a/contrib/gitian.yml b/contrib/gitian.yml index 90be8934fa..efa9cb8c10 100644 --- a/contrib/gitian.yml +++ b/contrib/gitian.yml @@ -6,40 +6,42 @@ architectures: - "i386" - "amd64" packages: -- "libdb4.7++-dev" +- "libdb4.8++-dev" - "libxxf86vm-dev" - "libgtk2.0-dev" - "libboost-all-dev" - "libssl-dev" - "git-core" +- "unzip" reference_datetime: "2011-01-30 00:00:00" remotes: - "url": "https://github.com/bitcoin/bitcoin.git" "dir": "bitcoin" files: -- "wxWidgets-2.9.1.tar.bz2" -- "miniupnpc-1.5.tar.gz" -- "toplevel.h.diff" -- "toplevel.cpp.diff" +- "wxWidgets-2.9.2-x64-gitian.zip" +- "wxWidgets-2.9.2-x32-gitian.zip" +- "miniupnpc-1.6.tar.gz" script: | INSTDIR="$HOME/install" export LIBRARY_PATH="$INSTDIR/lib" # - tar xzf miniupnpc-1.5.tar.gz - cd miniupnpc-1.5 + tar xzf miniupnpc-1.6.tar.gz + cd miniupnpc-1.6 INSTALLPREFIX=$INSTDIR make $MAKEOPTS install cd .. # - tar xjf wxWidgets-2.9.1.tar.bz2 - cd wxWidgets-2.9.1 - cd include/wx/gtk - patch < ../../../../toplevel.h.diff - cd ../../../src/gtk - patch < ../../../toplevel.cpp.diff - cd ../.. - ./configure --prefix=$INSTDIR --enable-monolithic --disable-shared - perl -i -p -e "s/__TIME__/\"$REFERENCE_TIME\"/;s/__DATE__/\"$REFERENCE_DATE\"/" include/wx/chartype.h - make $MAKEOPTS install + mkdir -p $INSTDIR/bin $INSTDIR/lib/wx $INSTDIR/include + mkdir wxWidgets-2.9.2 + cd wxWidgets-2.9.2 + unzip ../wxWidgets-2.9.2-x32-gitian.zip + unzip -o ../wxWidgets-2.9.2-x64-gitian.zip + cp -a bin/$GBUILD_BITS/wx/config/gtk2-unicode-static-2.9 $INSTDIR/bin/wx-config + for lib in wx_gtk2u wxregexu wxtiff; do + ar rc $INSTDIR/lib/lib${lib}-2.9.a bin/$GBUILD_BITS/$lib/*.o + ranlib $INSTDIR/lib/lib${lib}-2.9.a + done + cp -a include/wx-2.9/* $INSTDIR/include + cp -a bin/$GBUILD_BITS/wx/include $INSTDIR/lib/wx cd .. # cd bitcoin @@ -50,7 +52,7 @@ script: | cp $OUTDIR/src/doc/README $OUTDIR cp $OUTDIR/src/COPYING $OUTDIR cd src - sed 's/$(DEBUGFLAGS)//' < makefile.unix > makefile.unix.2 && mv makefile.unix.2 makefile.unix + sed 's/$(DEBUGFLAGS)//' -i makefile.unix PATH=$INSTDIR/bin:$PATH make -f makefile.unix CXX="g++ -I$INSTDIR/include -L$INSTDIR/lib" $MAKEOPTS bitcoin USE_UPNP=1 PATH=$INSTDIR/bin:$PATH make -f makefile.unix CXX="g++ -I$INSTDIR/include -L$INSTDIR/lib" $MAKEOPTS bitcoind USE_UPNP=0 mkdir -p $OUTDIR/bin/$GBUILD_BITS diff --git a/contrib/pyminer/README b/contrib/pyminer/README new file mode 100644 index 0000000000..d1596575dd --- /dev/null +++ b/contrib/pyminer/README @@ -0,0 +1,6 @@ + +This is a 'getwork' CPU mining client for bitcoin. + +It is pure-python, and therefore very, very slow. The purpose is to +provide a reference implementation of a miner, for study. + diff --git a/contrib/pyminer/example-config.cfg b/contrib/pyminer/example-config.cfg new file mode 100644 index 0000000000..103e7c1372 --- /dev/null +++ b/contrib/pyminer/example-config.cfg @@ -0,0 +1,32 @@ + +# +# RPC login details +# +host=127.0.0.1 +port=8332 + +rpcuser=myusername +rpcpass=mypass + + +# +# mining details +# + +threads=4 + +# periodic rate for requesting new work, if solution not found +scantime=60 + + +# +# misc. +# + +# not really used right now +logdir=/tmp/pyminer + +# set to 1, to enable hashmeter output +hashmeter=0 + + diff --git a/contrib/pyminer/pyminer.py b/contrib/pyminer/pyminer.py new file mode 100755 index 0000000000..2887aba591 --- /dev/null +++ b/contrib/pyminer/pyminer.py @@ -0,0 +1,252 @@ +#!/usr/bin/python +# +# Copyright (c) 2011 The Bitcoin developers +# Distributed under the MIT/X11 software license, see the accompanying +# file license.txt or http://www.opensource.org/licenses/mit-license.php. +# + +import time +import json +import pprint +import hashlib +import struct +import re +import base64 +import httplib +import sys +from multiprocessing import Process + +ERR_SLEEP = 15 +MAX_NONCE = 1000000L + +settings = {} +pp = pprint.PrettyPrinter(indent=4) + +class BitcoinRPC: + OBJID = 1 + + def __init__(self, host, port, username, password): + authpair = "%s:%s" % (username, password) + self.authhdr = "Basic %s" % (base64.b64encode(authpair)) + self.conn = httplib.HTTPConnection(host, port, False, 30) + def rpc(self, method, params=None): + self.OBJID += 1 + obj = { 'version' : '1.1', + 'method' : method, + 'id' : self.OBJID } + if params is None: + obj['params'] = [] + else: + obj['params'] = params + self.conn.request('POST', '/', json.dumps(obj), + { 'Authorization' : self.authhdr, + 'Content-type' : 'application/json' }) + + resp = self.conn.getresponse() + if resp is None: + print "JSON-RPC: no response" + return None + + body = resp.read() + resp_obj = json.loads(body) + if resp_obj is None: + print "JSON-RPC: cannot JSON-decode body" + return None + if 'error' in resp_obj and resp_obj['error'] != None: + return resp_obj['error'] + if 'result' not in resp_obj: + print "JSON-RPC: no result in object" + return None + + return resp_obj['result'] + def getblockcount(self): + return self.rpc('getblockcount') + def getwork(self, data=None): + return self.rpc('getwork', data) + +def uint32(x): + return x & 0xffffffffL + +def bytereverse(x): + return uint32(( ((x) << 24) | (((x) << 8) & 0x00ff0000) | + (((x) >> 8) & 0x0000ff00) | ((x) >> 24) )) + +def bufreverse(in_buf): + out_words = [] + for i in range(0, len(in_buf), 4): + word = struct.unpack('@I', in_buf[i:i+4])[0] + out_words.append(struct.pack('@I', bytereverse(word))) + return ''.join(out_words) + +def wordreverse(in_buf): + out_words = [] + for i in range(0, len(in_buf), 4): + out_words.append(in_buf[i:i+4]) + out_words.reverse() + return ''.join(out_words) + +class Miner: + def __init__(self, id): + self.id = id + self.max_nonce = MAX_NONCE + + def work(self, datastr, targetstr): + # decode work data hex string to binary + static_data = datastr.decode('hex') + static_data = bufreverse(static_data) + + # the first 76b of 80b do not change + blk_hdr = static_data[:76] + + # decode 256-bit target value + targetbin = targetstr.decode('hex') + targetbin = targetbin[::-1] # byte-swap and dword-swap + targetbin_str = targetbin.encode('hex') + target = long(targetbin_str, 16) + + # pre-hash first 76b of block header + static_hash = hashlib.sha256() + static_hash.update(blk_hdr) + + for nonce in xrange(self.max_nonce): + + # encode 32-bit nonce value + nonce_bin = struct.pack("<I", nonce) + + # hash final 4b, the nonce value + hash1_o = static_hash.copy() + hash1_o.update(nonce_bin) + hash1 = hash1_o.digest() + + # sha256 hash of sha256 hash + hash_o = hashlib.sha256() + hash_o.update(hash1) + hash = hash_o.digest() + + # quick test for winning solution: high 32 bits zero? + if hash[-4:] != '\0\0\0\0': + continue + + # convert binary hash to 256-bit Python long + hash = bufreverse(hash) + hash = wordreverse(hash) + + hash_str = hash.encode('hex') + l = long(hash_str, 16) + + # proof-of-work test: hash < target + if l < target: + print time.asctime(), "PROOF-OF-WORK found: %064x" % (l,) + return (nonce + 1, nonce_bin) + else: + print time.asctime(), "PROOF-OF-WORK false positive %064x" % (l,) +# return (nonce + 1, nonce_bin) + + return (nonce + 1, None) + + def submit_work(self, rpc, original_data, nonce_bin): + nonce_bin = bufreverse(nonce_bin) + nonce = nonce_bin.encode('hex') + solution = original_data[:152] + nonce + original_data[160:256] + param_arr = [ solution ] + result = rpc.getwork(param_arr) + print time.asctime(), "--> Upstream RPC result:", result + + def iterate(self, rpc): + work = rpc.getwork() + if work is None: + time.sleep(ERR_SLEEP) + return + if 'data' not in work or 'target' not in work: + time.sleep(ERR_SLEEP) + return + + time_start = time.time() + + (hashes_done, nonce_bin) = self.work(work['data'], + work['target']) + + time_end = time.time() + time_diff = time_end - time_start + + self.max_nonce = long( + (hashes_done * settings['scantime']) / time_diff) + if self.max_nonce > 0xfffffffaL: + self.max_nonce = 0xfffffffaL + + if settings['hashmeter']: + print "HashMeter(%d): %d hashes, %.2f Khash/sec" % ( + self.id, hashes_done, + (hashes_done / 1000.0) / time_diff) + + if nonce_bin is not None: + self.submit_work(rpc, work['data'], nonce_bin) + + def loop(self): + rpc = BitcoinRPC(settings['host'], settings['port'], + settings['rpcuser'], settings['rpcpass']) + if rpc is None: + return + + while True: + self.iterate(rpc) + +def miner_thread(id): + miner = Miner(id) + miner.loop() + +if __name__ == '__main__': + if len(sys.argv) != 2: + print "Usage: pyminer.py CONFIG-FILE" + sys.exit(1) + + f = open(sys.argv[1]) + for line in f: + # skip comment lines + m = re.search('^\s*#', line) + if m: + continue + + # parse key=value lines + m = re.search('^(\w+)\s*=\s*(\S.*)$', line) + if m is None: + continue + settings[m.group(1)] = m.group(2) + f.close() + + if 'host' not in settings: + settings['host'] = '127.0.0.1' + if 'port' not in settings: + settings['port'] = 8332 + if 'threads' not in settings: + settings['threads'] = 1 + if 'hashmeter' not in settings: + settings['hashmeter'] = 0 + if 'scantime' not in settings: + settings['scantime'] = 30L + if 'rpcuser' not in settings or 'rpcpass' not in settings: + print "Missing username and/or password in cfg file" + sys.exit(1) + + settings['port'] = int(settings['port']) + settings['threads'] = int(settings['threads']) + settings['hashmeter'] = int(settings['hashmeter']) + settings['scantime'] = long(settings['scantime']) + + thr_list = [] + for thr_id in range(settings['threads']): + p = Process(target=miner_thread, args=(thr_id,)) + p.start() + thr_list.append(p) + time.sleep(1) # stagger threads + + print settings['threads'], "mining threads started" + + print time.asctime(), "Miner Starts - %s:%s" % (settings['host'], settings['port']) + try: + for thr_proc in thr_list: + thr_proc.join() + except KeyboardInterrupt: + pass + print time.asctime(), "Miner Stops - %s:%s" % (settings['host'], settings['port']) + diff --git a/contrib/wx-patches/README b/contrib/wx-patches/README deleted file mode 100644 index 2afb4a9e91..0000000000 --- a/contrib/wx-patches/README +++ /dev/null @@ -1,4 +0,0 @@ -This folder contains two patches which are applied to wxWidgets -2.9.1 before building the wxWidgets which is used for release -versions of bitcoin. They make the GUI show up on newer OSs -with new libgtks, such as Ubuntu 11.04. diff --git a/contrib/wx-patches/toplevel.cpp.diff b/contrib/wx-patches/toplevel.cpp.diff deleted file mode 100644 index 359abf28d4..0000000000 --- a/contrib/wx-patches/toplevel.cpp.diff +++ /dev/null @@ -1,86 +0,0 @@ ---- /wxWidgets/trunk/src/gtk/toplevel.cpp (revision 67326)
-+++ /wxWidgets/trunk/src/gtk/toplevel.cpp (revision 67496)
-@@ -72,4 +72,8 @@
- // send any activate events at all
- static int g_sendActivateEvent = -1;
-+
-+// Whether _NET_REQUEST_FRAME_EXTENTS support is working
-+// 0 == not tested yet, 1 == working, 2 == broken
-+static int gs_requestFrameExtentsStatus;
-
- //-----------------------------------------------------------------------------
-@@ -432,4 +436,12 @@
- if (event->state == GDK_PROPERTY_NEW_VALUE && event->atom == property)
- {
-+ if (win->m_netFrameExtentsTimerId)
-+ {
-+ // WM support for _NET_REQUEST_FRAME_EXTENTS is working
-+ gs_requestFrameExtentsStatus = 1;
-+ g_source_remove(win->m_netFrameExtentsTimerId);
-+ win->m_netFrameExtentsTimerId = 0;
-+ }
-+
- wxSize decorSize = win->m_decorSize;
- int left, right, top, bottom;
-@@ -439,4 +451,22 @@
- win->GTKUpdateDecorSize(decorSize);
- }
-+ return false;
-+}
-+}
-+
-+extern "C" {
-+static gboolean request_frame_extents_timeout(void* data)
-+{
-+ // WM support for _NET_REQUEST_FRAME_EXTENTS is broken
-+ gs_requestFrameExtentsStatus = 2;
-+ gdk_threads_enter();
-+ wxTopLevelWindowGTK* win = static_cast<wxTopLevelWindowGTK*>(data);
-+ win->m_netFrameExtentsTimerId = 0;
-+ wxSize decorSize = win->m_decorSize;
-+ int left, right, top, bottom;
-+ if (wxGetFrameExtents(gtk_widget_get_window(win->m_widget), &left, &right, &top, &bottom))
-+ decorSize.Set(left + right, top + bottom);
-+ win->GTKUpdateDecorSize(decorSize);
-+ gdk_threads_leave();
- return false;
- }
-@@ -459,4 +489,5 @@
- m_deferShowAllowed = true;
- m_updateDecorSize = true;
-+ m_netFrameExtentsTimerId = 0;
-
- m_urgency_hint = -2;
-@@ -811,5 +842,6 @@
- if (deferShow)
- {
-- deferShow = m_deferShowAllowed && !GTK_WIDGET_REALIZED(m_widget);
-+ deferShow = gs_requestFrameExtentsStatus != 2 &&
-+ m_deferShowAllowed && !gtk_widget_get_realized(m_widget);
- if (deferShow)
- {
-@@ -829,11 +861,4 @@
- // GetSize()/SetSize() because it makes window bigger between each
- // restore and save.
-- m_updateDecorSize = deferShow;
-- }
-- if (deferShow)
-- {
-- // Fluxbox support for _NET_REQUEST_FRAME_EXTENTS is broken
-- const char* name = gdk_x11_screen_get_window_manager_name(screen);
-- deferShow = strcmp(name, "Fluxbox") != 0;
- m_updateDecorSize = deferShow;
- }
-@@ -875,4 +900,12 @@
- (XEvent*)&xevent);
-
-+ if (gs_requestFrameExtentsStatus == 0)
-+ {
-+ // if WM does not respond to request within 1 second,
-+ // we assume support for _NET_REQUEST_FRAME_EXTENTS is not working
-+ m_netFrameExtentsTimerId =
-+ g_timeout_add(1000, request_frame_extents_timeout, this);
-+ }
-+
- // defer calling gtk_widget_show()
- m_isShown = true;
diff --git a/contrib/wx-patches/toplevel.h.diff b/contrib/wx-patches/toplevel.h.diff deleted file mode 100644 index c2718d4637..0000000000 --- a/contrib/wx-patches/toplevel.h.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- /wxWidgets/trunk/include/wx/gtk/toplevel.h (revision 65373)
-+++ /wxWidgets/trunk/include/wx/gtk/toplevel.h (revision 67496)
-@@ -114,4 +114,6 @@
- // wxUSER_ATTENTION_ERROR difference, -2 for no hint, -1 for ERROR hint, rest for GtkTimeout handle.
- int m_urgency_hint;
-+ // timer for detecting WM with broken _NET_REQUEST_FRAME_EXTENTS handling
-+ unsigned m_netFrameExtentsTimerId;
-
- // return the size of the window without WM decorations
diff --git a/contrib/wxwidgets-win32.yml b/contrib/wxwidgets-win32.yml new file mode 100644 index 0000000000..3d49d7b35e --- /dev/null +++ b/contrib/wxwidgets-win32.yml @@ -0,0 +1,40 @@ +--- +name: "wxwidgets" +suites: +- "lucid" +architectures: +- "i386" +packages: +- "mingw32" +- "faketime" +- "zip" +reference_datetime: "2011-01-30 00:00:00" +remotes: [] +files: +- "wxWidgets-2.9.2.tar.bz2" +script: | + INSTDIR="$HOME/install" + TMPDIR="$HOME/tmpdir" + export LIBRARY_PATH="$INSTDIR/lib" + # + tar xjf wxWidgets-2.9.2.tar.bz2 + cd wxWidgets-2.9.2 + CXXFLAGS=-frandom-seed=wx1 ./configure --host=i586-mingw32msvc --build=i686-linux --prefix=$INSTDIR --disable-shared --enable-monolithic --without-libpng --disable-svg + perl -i -p -e "s/__TIME__/\"$REFERENCE_TIME\"/;s/__DATE__/\"$REFERENCE_DATE\"/" include/wx/chartype.h + make $MAKEOPTS install + mkdir $TMPDIR + cd $TMPDIR + cp -af $INSTDIR/include . + mkdir -p $TMPDIR/bin/$GBUILD_BITS + cd $TMPDIR/bin/$GBUILD_BITS + cp -af $INSTDIR/lib/wx . + for lib in wx_mswu; do + mkdir $lib + (cd $lib ; ar xf $INSTDIR/lib/lib${lib}-2.9-i586-mingw32msvc.a) + done + chmod -R +w $TMPDIR + cd $TMPDIR + export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1 + export FAKETIME=$REFERENCE_DATETIME + zip -r wxwidgets-win32-2.9.2-gitian.zip * + cp wxwidgets-win32-2.9.2-gitian.zip $OUTDIR diff --git a/contrib/wxwidgets.yml b/contrib/wxwidgets.yml new file mode 100644 index 0000000000..0509615101 --- /dev/null +++ b/contrib/wxwidgets.yml @@ -0,0 +1,42 @@ +--- +name: "wxwidgets" +suites: +- "lucid" +architectures: +- "i386" +- "amd64" +packages: +- "libxxf86vm-dev" +- "libgtk2.0-dev" +- "faketime" +- "zip" +reference_datetime: "2011-01-30 00:00:00" +remotes: [] +files: +- "wxWidgets-2.9.2.tar.bz2" +script: | + INSTDIR="$HOME/install" + TMPDIR="$HOME/tmpdir" + export LIBRARY_PATH="$INSTDIR/lib" + # + tar xjf wxWidgets-2.9.2.tar.bz2 + cd wxWidgets-2.9.2 + ./configure --prefix=$INSTDIR --enable-monolithic --disable-shared + perl -i -p -e "s/__TIME__/\"$REFERENCE_TIME\"/;s/__DATE__/\"$REFERENCE_DATE\"/" include/wx/chartype.h + make $MAKEOPTS install + mkdir $TMPDIR + cd $TMPDIR + cp -af $INSTDIR/include . + mkdir -p $TMPDIR/bin/$GBUILD_BITS + cd $TMPDIR/bin/$GBUILD_BITS + cp -af $INSTDIR/lib/wx . + for lib in wxtiff wxregexu wx_gtk2u; do + mkdir $lib + (cd $lib ; ar xf $INSTDIR/lib/lib${lib}-2.9.a) + done + chmod -R +w $TMPDIR + cd $TMPDIR + export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1 + export FAKETIME=$REFERENCE_DATETIME + zip -r wxWidgets-2.9.2-x$GBUILD_BITS-gitian.zip * + cp wxWidgets-2.9.2-x$GBUILD_BITS-gitian.zip $OUTDIR diff --git a/doc/README b/doc/README index f72bca01f7..772fd7f31e 100644 --- a/doc/README +++ b/doc/README @@ -1,4 +1,4 @@ -Bitcoin 0.3.25 BETA +Bitcoin 0.4.0rc1 BETA Copyright (c) 2009-2011 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying @@ -36,7 +36,7 @@ every time you wish to send Bitcoins. If you lose this passphrase, you will lose access to spend all of the bitcoins in your wallet, no one, not even the Bitcoin developers can recover your Bitcoins. This means you are responsible for your own security, store your -password in a secure location and do not forget it. +passphrase in a secure location and do not forget it. Remember that the encryption built into bitcoin only encrypts the actual keys which are required to send your bitcoins, not the full @@ -57,7 +57,7 @@ If everything goes fine, delete the backup and enjoy your encrypted wallet. Note that once you encrypt your wallet, you will never be able to go back to a version of the Bitcoin client older than 0.4. -Keep in mind that you are always responsible for you own security. +Keep in mind that you are always responsible for your own security. All it takes is a slightly more advanced wallet-stealing trojan which installs a keylogger to steal your wallet passphrase as you enter it in addition to your wallet file and you have lost all your Bitcoins. @@ -67,6 +67,50 @@ entering your wallet passphrase in the Bitcoin client and using the same passphrase only as your wallet passphrase. +Technical details of wallet encryption +-------------------------------------- +Wallet encryption uses AES-256-CBC to encrypt only the private keys +that are held in a wallet. The keys are encrypted with a master key +which is entirely random. This master key is then encrypted with +AES-256-CBC with a key derived from the passphrase using SHA512 and +OpenSSL's EVP_BytesToKey and a dynamic number of rounds determined by +the speed of the machine which does the initial encryption (and is +updated based on the speed of a computer which does a subsequent +passphrase change). Although the underlying code supports multiple +encrypted copies of the same master key (and thus multiple passphrases) +the client does not yet have a method to add additional passphrases. + +At runtime, the client loads the wallet as it normally would, however +the keystore stores the keys in encrypted form. When the passphrase +is required (to top up keypool or send coins) it will either be queried +by a GUI prompt, or must first be entered with the walletpassphrase +RPC command. This will change the wallet to "unlocked" state where the +unencrypted master key is stored in memory (in the case of GUI, only for +long enough to complete the requested operation, in RPC, for as long as +is specified by the second parameter to walletpassphrase). The wallet is +then locked (or can be manually locked using the walletlock RPC command) +and the unencrypted master key is removed from memory. + +Implementation details of wallet encryption +------------------------------------------- +When the wallet is locked, calls to sendtoaddress, sendfrom, sendmany, +and keypoolrefill will return Error -13: "Error: Please enter the wallet +passphrase with walletpassphrase first." + +When the wallet is unlocked, calls to walletpassphrase will fail. + +When a wallet is encrypted, the passphrase is required to top up the +keypool, thus, if the passphrase is rarely entered, it is possible that +keypool might run out. In this case, the default key will be used as the +target for payouts for mining, and calls to getnewaddress and getaccount +address will return an error. In order to prevent such cases, the keypool +is automatically refilled when walletpassphrase is called with a correct +passphrase and when topupkeypool is called (while the wallet is unlocked). +Note that the keypool continues to be topped up on various occasions when +a new key from pool is used and the wallet is unlocked (or unencrypted). + + + See the documentation at the bitcoin wiki: https://en.bitcoin.it/wiki/Main_Page diff --git a/doc/README_windows.txt b/doc/README_windows.txt index e715b32068..8378ae50d8 100644 --- a/doc/README_windows.txt +++ b/doc/README_windows.txt @@ -1,4 +1,4 @@ -Bitcoin 0.3.25 BETA
+Bitcoin 0.4.00rc1 BETA
Copyright (c) 2009-2011 Bitcoin Developers
Distributed under the MIT/X11 software license, see the accompanying
diff --git a/doc/build-msw.txt b/doc/build-msw.txt index 1911008d1f..d08e3a23b7 100644 --- a/doc/build-msw.txt +++ b/doc/build-msw.txt @@ -27,11 +27,11 @@ Dependencies Libraries you need to download separately and build: default path download -wxWidgets \wxwidgets-2.9.1-mgw http://www.wxwidgets.org/downloads/ +wxWidgets \wxwidgets-2.9.2-mgw http://www.wxwidgets.org/downloads/ OpenSSL \openssl-1.0.0d-mgw http://www.openssl.org/source/ -Berkeley DB \db-4.7.25.NC-mgw http://www.oracle.com/technology/software/products/berkeley-db/index.html -Boost \boost-1.43.0-mgw http://www.boost.org/users/download/ -miniupnpc \upnpc-exe-win32-20110215 http://miniupnp.tuxfamily.org/files/ +Berkeley DB \db-4.8.30.NC-mgw http://www.oracle.com/technology/software/products/berkeley-db/index.html +Boost \boost-1.47.0-mgw http://www.boost.org/users/download/ +miniupnpc \miniupnpc-1.6-mgw http://miniupnp.tuxfamily.org/files/ Their licenses: wxWidgets LGPL 2.1 with very liberal exceptions @@ -41,11 +41,11 @@ Boost MIT-like license miniupnpc New (3-clause) BSD license Versions used in this release: -wxWidgets 2.9.1 +wxWidgets 2.9.2 OpenSSL 1.0.0d -Berkeley DB 4.7.25.NC -Boost 1.43.0 -miniupnpc 1.5-20110215 +Berkeley DB 4.8.30.NC +Boost 1.47.0 +miniupnpc 1.6 Notes @@ -57,7 +57,7 @@ classes that do the rote work of constructing all the UI elements. wxWidgets --------- DOS shell: -cd \wxWidgets-2.9.1-mgw\build\msw +cd \wxWidgets-2.9.2-mgw\build\msw mingw32-make -f makefile.gcc OpenSSL @@ -73,30 +73,26 @@ make Berkeley DB ----------- MSYS shell: -cd /c/db-4.7.25.NC-mgw/build_unix +cd /c/db-4.8.30.NC-mgw/build_unix sh ../dist/configure --enable-mingw --enable-cxx make - Boost ----- DOS prompt: downloaded boost jam 3.1.18 -cd \boost-1.43.0-mgw +cd \boost-1.47.0-mgw bjam toolset=gcc --build-type=complete stage -Note: -building with boost 1.45.0 failed because of boost ticket 4614, 4258 -builds fine with boost 1.43.0 - MiniUPnPc --------- -Building miniupnpc failed on Windows Server 2003, thus it is expected that a binary copy will be used. -See http://miniupnp.tuxfamily.org/forum/viewtopic.php?t=642 UPnP support is optional, make with USE_UPNP= to disable it. -Get upnpc-exe-win32-20110215.zip and unzip it to \upnpc-exe-win32-20110215 -Get miniupnpc-1.5.20110215.tar.gz and copy *.h to \upnpc-exe-win32-20110215\miniupnpc +MSYS shell: +cd /c/miniupnpc-1.6-mgw +make -f Makefile.mingw +mkdir miniupnpc +cp *.h miniupnpc/ Bitcoin ------- diff --git a/doc/build-osx.txt b/doc/build-osx.txt index ddf025003b..52d876d82b 100644 --- a/doc/build-osx.txt +++ b/doc/build-osx.txt @@ -135,18 +135,18 @@ The process for miniupnpc (optional) is similar to that of OpenSSL. Download from http://miniupnp.tuxfamily.org/files/. cd ~/bitcoin/deps -tar xvf ~/Downloads/miniupnpc-1.5.tar -mv miniupnpc-1.5 miniupnpc-1.5-x86_64 -tar xvf ~/Downloads/miniupnpc-1.5.tar -mv miniupnpc-1.5 miniupnpc-1.5-i386 +tar xvf ~/Downloads/miniupnpc-1.6.tar +mv miniupnpc-1.6 miniupnpc-1.6-x86_64 +tar xvf ~/Downloads/miniupnpc-1.6.tar +mv miniupnpc-1.6 miniupnpc-1.6-i386 # build x86_64 (64 bit intel) binary -cd miniupnpc-1.5-x86_64 +cd miniupnpc-1.6-x86_64 export CFLAGS="-arch x86_64" export LDFLAGS="-arch x86_64" export PREFIX="/Users/macuser/bitcoin/deps" make && make install # build i386 (32 bit intel) binary -cd miniupnpc-1.5-i386 +cd miniupnpc-1.6-i386 export CFLAGS="-arch i386" export LDFLAGS="-arch i386" export PREFIX="/Users/macuser/bitcoin/deps" @@ -154,7 +154,7 @@ make # combine the libs cd ~/bitcoin/deps -lipo -arch i386 miniupnpc-1.5-i386/libminiupnpc.a -arch x86_64 miniupnpc-1.5-x86_64/libminiupnpc.a -o lib/libminiupnpc.a -create +lipo -arch i386 miniupnpc-1.6-i386/libminiupnpc.a -arch x86_64 miniupnpc-1.6-x86_64/libminiupnpc.a -o lib/libminiupnpc.a -create Verify your binaries @@ -175,8 +175,8 @@ Berkeley DB Download from http://freshmeat.net/projects/berkeleydb/ cd ~/bitcoin/deps -tar xvf ~/Downloads/db-4.8.26.tar -cd db-4.8.26/build_unix +tar xvf ~/Downloads/db-4.8.30.tar +cd db-4.8.30/build_unix ../dist/configure --prefix=/Users/macosuser/bitcoin/deps --enable-cxx && make && make install diff --git a/doc/build-unix.txt b/doc/build-unix.txt index 0c4e88e523..4ecf15aa33 100644 --- a/doc/build-unix.txt +++ b/doc/build-unix.txt @@ -25,15 +25,14 @@ Dependencies sudo apt-get install build-essential sudo apt-get install libgtk2.0-dev sudo apt-get install libssl-dev -sudo apt-get install libdb4.7-dev -sudo apt-get install libdb4.7++-dev +sudo apt-get install libdb4.8-dev +sudo apt-get install libdb4.8++-dev Boost 1.40+: sudo apt-get install libboost-all-dev or Boost 1.37: sudo apt-get install libboost1.37-dev If using Boost 1.37, append -mt to the boost libraries in the makefile. -Requires wxWidgets 2.9.0 or greater, which uses UTF-8. Don't try 2.8, it -won't work. +Requires wxWidgets 2.9.1 or newer. You need to download wxWidgets from http://www.wxwidgets.org/downloads/ and build it yourself. See the build instructions and configure parameters @@ -55,10 +54,10 @@ miniupnpc New (3-clause) BSD license Versions used in this release: GCC 4.3.3 OpenSSL 0.9.8g -wxWidgets 2.9.0 -Berkeley DB 4.7.25.NC +wxWidgets 2.9.2 +Berkeley DB 4.8.30.NC Boost 1.37 -miniupnpc 1.5 +miniupnpc 1.6 Notes @@ -74,8 +73,8 @@ symbols, which reduces the executable size by about 90%. wxWidgets --------- cd /usr/local -tar -xzvf wxWidgets-2.9.0.tar.gz -cd wxWidgets-2.9.0 +tar -xzvf wxWidgets-2.9.2.tar.gz +cd wxWidgets-2.9.2 mkdir buildgtk cd buildgtk ../configure --with-gtk --enable-debug --disable-shared --enable-monolithic --without-libpng --disable-svg @@ -87,8 +86,8 @@ ldconfig miniupnpc --------- -tar -xzvf miniupnpc-1.5.tar.gz -cd miniupnpc-1.5 +tar -xzvf miniupnpc-1.6.tar.gz +cd miniupnpc-1.6 make sudo su make install @@ -96,8 +95,7 @@ make install Berkeley DB ----------- -You need Berkeley DB 4.7. Don't use 4.8, the database/log0000* files -are incompatible. If you have to build Berkeley DB yourself: +You need Berkeley DB 4.8. If you have to build Berkeley DB yourself: ../dist/configure --enable-cxx make diff --git a/doc/coding.txt b/doc/coding.txt index 4707476697..b3c812a486 100644 --- a/doc/coding.txt +++ b/doc/coding.txt @@ -39,3 +39,61 @@ v vector or similar list objects map map or multimap
set set or multiset
bn CBigNum
+
+-------------------------
+Locking/mutex usage notes
+
+The code is multi-threaded, and uses mutexes and the
+CRITICAL_BLOCK/TRY_CRITICAL_BLOCK macros to protect data structures.
+
+Deadlocks due to inconsistent lock ordering (thread 1 locks cs_main
+and then cs_wallet, while thread 2 locks them in the opposite order:
+result, deadlock as each waits for the other to release its lock) are
+a problem. Compile with -DDEBUG_LOCKORDER to get lock order
+inconsistencies reported in the debug.log file.
+
+Re-architecting the core code so there are better-defined interfaces
+between the various components is a goal, with any necessary locking
+done by the components (e.g. see the self-contained CKeyStore class
+and its cs_KeyStore lock for example).
+
+-------
+Threads
+
+StartNode : Starts other threads.
+
+ThreadGetMyExternalIP : Determines outside-the-firewall IP address,
+sends addr message to connected peers when it determines it.
+
+ThreadIRCSeed : Joins IRC bootstrapping channel, watching for new
+peers and advertising this node's IP address.
+
+ThreadSocketHandler : Sends/Receives data from peers on port 8333.
+
+ThreadMessageHandler : Higher-level message handling (sending and
+receiving).
+
+ThreadOpenConnections : Initiates new connections to peers.
+
+ThreadTopUpKeyPool : replenishes the keystore's keypool.
+
+ThreadCleanWalletPassphrase : re-locks an encrypted wallet after user
+has unlocked it for a period of time.
+
+SendingDialogStartTransfer : used by pay-via-ip-address code (obsolete)
+
+ThreadDelayedRepaint : repaint the gui
+
+ThreadFlushWalletDB : Close the wallet.dat file if it hasn't been used
+in 500ms.
+
+ThreadRPCServer : Remote procedure call handler, listens on port 8332
+for connections and services them.
+
+ThreadBitcoinMiner : Generates bitcoins
+
+ThreadMapPort : Universal plug-and-play startup/shutdown
+
+Shutdown : Does an orderly shutdown of everything
+
+ExitTimeout : Windows-only, sleeps 5 seconds then exits application
diff --git a/doc/release-process.txt b/doc/release-process.txt index 4940afefa5..bcda64dbed 100644 --- a/doc/release-process.txt +++ b/doc/release-process.txt @@ -1,6 +1,9 @@ * update (commit) version in sources + src/serialize.h + share/setup.nsi * update (commit) version in OSX app bundle + contrib/Bitcoin.app/Contents/Info.plist * CFBundleShortVersionString should have value like 0.3.23 * CFBundleVersion should have value like 323 diff --git a/locale/cs/LC_MESSAGES/bitcoin.mo b/locale/cs/LC_MESSAGES/bitcoin.mo Binary files differindex 80354cf764..8b6e444b66 100644 --- a/locale/cs/LC_MESSAGES/bitcoin.mo +++ b/locale/cs/LC_MESSAGES/bitcoin.mo diff --git a/locale/cs/LC_MESSAGES/bitcoin.po b/locale/cs/LC_MESSAGES/bitcoin.po index 51fe18297c..2275d901bf 100644 --- a/locale/cs/LC_MESSAGES/bitcoin.po +++ b/locale/cs/LC_MESSAGES/bitcoin.po @@ -5,8 +5,8 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-05-26 21:44+0200\n" -"PO-Revision-Date: 2011-05-26 22:31+0100\n" +"POT-Creation-Date: 2011-08-16 15:51+0100\n" +"PO-Revision-Date: 2011-08-16 16:03+0100\n" "Last-Translator: xHire <xhire@mujmalysvet.cz>\n" "Language-Team: \n" "Language: cs\n" @@ -17,114 +17,541 @@ msgstr "" "X-Poedit-Basepath: .\n" "X-Poedit-SearchPath-0: ../../..\n" -#: ../../../src/net.cpp:1503 +#: ../../../src/uibase.cpp:25 +#: ../../../src/ui.cpp:2985 +msgid "E&xit" +msgstr "&Konec" + +#: ../../../src/uibase.cpp:28 +msgid "&File" +msgstr "&Soubor" + +#: ../../../src/uibase.cpp:32 +msgid "&Your Receiving Addresses..." +msgstr "Tvá Bitcoinová &adresa..." + +#: ../../../src/uibase.cpp:35 +msgid "&Encrypt Wallet..." +msgstr "&Zašifruj peněženku..." + +#: ../../../src/uibase.cpp:38 +msgid "&Change Wallet Encryption Passphrase..." +msgstr "Změň &heslo pro šifrování peněženky..." + +#: ../../../src/uibase.cpp:42 +msgid "&Options..." +msgstr "M&ožnosti" + +#: ../../../src/uibase.cpp:45 +msgid "&Settings" +msgstr "Nas&tavení" + +#: ../../../src/uibase.cpp:49 +msgid "&About..." +msgstr "&O programu" + +#: ../../../src/uibase.cpp:52 +msgid "&Help" +msgstr "&Nápověda" + +#: ../../../src/uibase.cpp:61 +#: ../../../src/ui.cpp:2143 +#: ../../../src/ui.cpp:2148 +#: ../../../src/ui.cpp:2153 +#: ../../../src/ui.cpp:2202 +msgid "Send Coins" +msgstr "Pošli mince" + +#: ../../../src/uibase.cpp:62 +msgid "Address Book" +msgstr "Adresář" + +#: ../../../src/uibase.cpp:75 +msgid "Your Bitcoin Address:" +msgstr "Tvá Bitcoinová adresa:" + +#: ../../../src/uibase.cpp:82 +msgid " &New... " +msgstr " &Nová..." + +#: ../../../src/uibase.cpp:85 +#: ../../../src/uibase.cpp:790 +#: ../../../src/uibase.cpp:893 +msgid " &Copy to Clipboard " +msgstr " &Kopírovat do schránky" + +#: ../../../src/uibase.cpp:99 +msgid "Balance:" +msgstr "Stav účtu:" + +#: ../../../src/uibase.cpp:115 +msgid " All" +msgstr " Vše" + +#: ../../../src/uibase.cpp:115 +msgid " Sent" +msgstr " Odeslané" + +#: ../../../src/uibase.cpp:115 +msgid " Received" +msgstr " Přijaté" + +#: ../../../src/uibase.cpp:115 +msgid " In Progress" +msgstr " Pracuje se na tom" + +#: ../../../src/uibase.cpp:136 +msgid "All Transactions" +msgstr "Všechny transakce" + +#: ../../../src/uibase.cpp:147 +msgid "Sent/Received" +msgstr "Odeslané/Přijaté" + +#: ../../../src/uibase.cpp:158 +msgid "Sent" +msgstr "Odeslané" + +#: ../../../src/uibase.cpp:169 +msgid "Received" +msgstr "Přijaté" + +#: ../../../src/uibase.cpp:312 +#: ../../../src/uibase.cpp:453 +#: ../../../src/uibase.cpp:552 +#: ../../../src/uibase.cpp:732 +#: ../../../src/uibase.cpp:793 +#: ../../../src/uibase.cpp:902 +#: ../../../src/uibase.cpp:991 +msgid "OK" +msgstr "&Budiž" + +#: ../../../src/uibase.cpp:355 +msgid "&Start Bitcoin on system startup" +msgstr "&Spustit Bitcoin při startu systému" + +#: ../../../src/uibase.cpp:358 +msgid "&Minimize to the tray instead of the taskbar" +msgstr "&Minimalizovávat do ikony v panelu" + +#: ../../../src/uibase.cpp:361 +msgid "Map port using &UPnP" +msgstr "Namapovat port přes &UPnP" + +#: ../../../src/uibase.cpp:364 +msgid "M&inimize to the tray on close" +msgstr "Zavřením &minimalizovat do ikony" + +#: ../../../src/uibase.cpp:370 +msgid "&Connect through socks4 proxy (requires restart to apply): " +msgstr "&Připojit přes socks4 proxy (vyžaduje restart aplikace):" + +#: ../../../src/uibase.cpp:381 +msgid "Proxy &IP:" +msgstr "&IP adresa proxy:" + +#: ../../../src/uibase.cpp:389 +msgid " &Port:" +msgstr " &Port:" + +#: ../../../src/uibase.cpp:402 +msgid "Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended." +msgstr "Dobrovolný transakční poplatek za každý započatý KB napomáhá tomu, aby tvé transakce byly rychle zpracovány. Většina transakcí má do 1 KB. Doporučená výše poplatku je 0.01." + +#: ../../../src/uibase.cpp:409 +msgid "Pay transaction fee:" +msgstr "Výše transakčního poplatku:" + +#: ../../../src/uibase.cpp:430 +msgid "// [don't translate] Test panel 2 for future expansion" +msgstr "" + +#: ../../../src/uibase.cpp:434 +msgid "// [don't translate] Let's not start multiple pages until the first page is filled up" +msgstr "" + +#: ../../../src/uibase.cpp:456 +#: ../../../src/uibase.cpp:678 +#: ../../../src/uibase.cpp:737 +#: ../../../src/uibase.cpp:796 +#: ../../../src/uibase.cpp:905 +#: ../../../src/uibase.cpp:994 +msgid "Cancel" +msgstr "&Zrušit" + +#: ../../../src/uibase.cpp:459 +msgid "&Apply" +msgstr "&Použít" + +#: ../../../src/uibase.cpp:518 +msgid "Bitcoin " +msgstr "Bitcoin" + +#: ../../../src/uibase.cpp:524 +msgid "version" +msgstr "verze" + +#: ../../../src/uibase.cpp:535 +msgid "" +"Copyright (c) 2009-2011 Bitcoin Developers\n" +"\n" +"This is experimental software.\n" +"\n" +"Distributed under the MIT/X11 software license, see the accompanying file \n" +"license.txt or http://www.opensource.org/licenses/mit-license.php.\n" +"\n" +"This product includes software developed by the OpenSSL Project for use in the \n" +"OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \n" +"Eric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard." +msgstr "" +"Copyright (c) 2009-2011 Vývojáři Bitcoinu\n" +"\n" +"Tohle je experimentální program.\n" +"\n" +"Šířen pod licencí MIT/X11, viz přiložený soubor license.txt nebo \n" +"http://www.opensource.org/licenses/mit-license.php.\n" +"\n" +"Tento produkt zahrnuje programy vyvinuté OpenSSL Projektem pro použití \n" +"v OpenSSL Toolkitu (http://www.openssl.org/) a kryptografický program od \n" +"Erika Younga (eay@cryptsoft.com) a program UPnP od Thomase Bernarda." + +#: ../../../src/uibase.cpp:591 +msgid "Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)" +msgstr "Vlož Bitcoinovou adresu (např. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)" + +#: ../../../src/uibase.cpp:605 +msgid "Pay &To:" +msgstr "&Komu:" + +#: ../../../src/uibase.cpp:620 +msgid "&Paste" +msgstr "&Vložit" + +#: ../../../src/uibase.cpp:623 +msgid " Address &Book..." +msgstr " &Adresář..." + +#: ../../../src/uibase.cpp:630 +msgid "&Amount:" +msgstr "&Částka" + +#: ../../../src/uibase.cpp:640 +msgid "T&ransfer:" +msgstr "&Převod:" + +#: ../../../src/uibase.cpp:646 +msgid " Standard" +msgstr " Standard" + +#: ../../../src/uibase.cpp:673 +msgid "&Send" +msgstr "&Poslat" + +#: ../../../src/uibase.cpp:721 +msgid "" +"\n" +"\n" +"Connecting..." +msgstr "" +"\n" +"\n" +"Připojuji..." + +#: ../../../src/uibase.cpp:771 +msgid "These are your Bitcoin addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you. The highlighted address is displayed in the main window." +msgstr "Tohle jsou tvé Bitcoinové adresy na příjem plateb. Asi budeš chtít dát jinou adresu každému odesílateli, abys věděl, kdo ti kolik platil. Označená adresa bude zobrazena v hlavním okně." + +#: ../../../src/uibase.cpp:784 +#: ../../../src/uibase.cpp:896 +msgid "&Edit..." +msgstr "&Upravit..." + +#: ../../../src/uibase.cpp:787 +#: ../../../src/uibase.cpp:899 +msgid " &New Address... " +msgstr " &Nová adresa..." + +#: ../../../src/uibase.cpp:847 +#: ../../../src/ui.cpp:2620 +msgid "Bitcoin Address" +msgstr "Bitcoinová adresa" + +#: ../../../src/uibase.cpp:859 +msgid "Sending" +msgstr "Cizí adresy (pro odesílání)" + +#: ../../../src/uibase.cpp:867 +msgid "These are your Bitcoin addresses for receiving payments. You can give a different one to each sender to keep track of who is paying you. The highlighted address will be displayed in the main window." +msgstr "Tohle jsou tvé Bitcoinové adresy na příjem plateb. Můžeš dát jinou adresu každému odesílateli, abys věděl, kdo ti kolik platil. Označená adresa bude zobrazena v hlavním okně." + +#: ../../../src/uibase.cpp:880 +msgid "Receiving" +msgstr "Tvoje adresy (pro příjem)" + +#: ../../../src/uibase.cpp:890 +msgid "&Delete" +msgstr "&Smazat" + +#: ../../../src/rpc.cpp:2088 +#: ../../../src/rpc.cpp:2090 #, c-format -msgid "Unable to bind to port %d on this computer. Bitcoin is probably already running." -msgstr "Nedaří se mi připojit na port %d na tomhle počítači. Bitcoin už pravděpodobně jednou běží." +msgid "To use the %s option" +msgstr "Pro použití volby %s" + +#: ../../../src/rpc.cpp:2092 +#, c-format +msgid "" +"Warning: %s, you must set rpcpassword=<password>\n" +"in the configuration file: %s\n" +"If the file does not exist, create it with owner-readable-only file permissions.\n" +msgstr "" +"Varování: %s, musíš nastavit rpcpassword=<heslo>\n" +"v konfiguračním souboru: %s\n" +"Pokud tenhle soubor neexistuje, vytvoř ho s oprávněním pro čtení pouze pro vlastníka.\n" -#: ../../../src/ui.cpp:204 +#: ../../../src/rpc.cpp:2265 +#, c-format +msgid "" +"You must set rpcpassword=<password> in the configuration file:\n" +"%s\n" +"If the file does not exist, create it with owner-readable-only file permissions." +msgstr "" +"Musíš nastavit rpcpassword=<heslo> v konfiguračním souboru:\n" +"%s\n" +"Pokud tenhle soubor neexistuje, vytvoř ho s oprávněním pro čtení pouze pro vlastníka." + +#: ../../../src/util.cpp:870 +msgid "Warning: Please check that your computer's date and time are correct. If your clock is wrong Bitcoin will not work properly." +msgstr "Varování: Prosím zkontroluj, že datum a čas jsou na tvém počítači správně nastaveny. Pokud jsou nastaveny špatně, Bitcoin nebude fungovat správně." + +#: ../../../src/util.cpp:904 +msgid "beta" +msgstr "beta" + +#: ../../../src/wallet.cpp:1084 +msgid "Error: Wallet locked, unable to create transaction " +msgstr "Chyba: Peněženka je zamčená, takže není možné vytvořit transakci" + +#: ../../../src/wallet.cpp:1092 +#, c-format +msgid "Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds " +msgstr "Chyba: Tato transakce vyžaduje transakční poplatek nejméně %s kvůli svému objemu, komplexnosti nebo utrácení nedávno přijaté hotovosti" + +#: ../../../src/wallet.cpp:1094 +msgid "Error: Transaction creation failed " +msgstr "Chyba: Vytvoření transakce selhalo" + +#: ../../../src/wallet.cpp:1100 +#: ../../../src/ui.cpp:2176 +#: ../../../src/ui.cpp:2185 +#: ../../../src/ui.cpp:2336 +#: ../../../src/ui.cpp:2500 +msgid "Sending..." +msgstr "Posílám..." + +#: ../../../src/wallet.cpp:1104 +msgid "Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here." +msgstr "Chyba: Transakce byla odmítnuta. Tohle může nastat, pokud nějaké mince z tvé peněženky už jednou byly utraceny, například pokud používáš kopii souboru wallet.dat a mince byly utraceny v druhé kopii, ale nebyly označeny jako utracené v této." + +#: ../../../src/wallet.cpp:1117 +msgid "Invalid amount" +msgstr "Neplatná částka" + +#: ../../../src/wallet.cpp:1119 +#: ../../../src/ui.cpp:2403 +#: ../../../src/ui.cpp:2474 +msgid "Insufficient funds" +msgstr "Nedostatek peněz" + +#: ../../../src/ui.cpp:217 #, c-format msgid "This transaction is over the size limit. You can still send it for a fee of %s, which goes to the nodes that process your transaction and helps to support the network. Do you want to pay the fee?" msgstr "Tahle transakce přesahuje velikostní limit. Pořád ji ale můžeš poslat, pokud za ni zaplatíš poplatek %s, který půjde uzlům, které tvou transakci zpracují, a navíc tak podpoříš síť. Chceš zaplatit poplatek?" -#: ../../../src/ui.cpp:303 +#: ../../../src/ui.cpp:261 +#: ../../../src/ui.cpp:1247 +msgid "Enter the current passphrase to the wallet." +msgstr "Zadej platné heslo pro peněženku." + +#: ../../../src/ui.cpp:262 +#: ../../../src/ui.cpp:1183 +#: ../../../src/ui.cpp:1200 +#: ../../../src/ui.cpp:1248 +#: ../../../src/ui.cpp:1274 +#: ../../../src/ui.cpp:1294 +msgid "Passphrase" +msgstr "Heslo" + +#: ../../../src/ui.cpp:268 +msgid "Please supply the current wallet decryption passphrase." +msgstr "Zadej platné heslo pro dešifrování peněženky." + +#: ../../../src/ui.cpp:276 +#: ../../../src/ui.cpp:1259 +#: ../../../src/ui.cpp:1316 +msgid "The passphrase entered for the wallet decryption was incorrect." +msgstr "Nezadal jsi správné heslo pro dešifrování peněženky." + +#: ../../../src/ui.cpp:353 msgid "Status" msgstr "Stav" -#: ../../../src/ui.cpp:304 +#: ../../../src/ui.cpp:354 msgid "Date" msgstr "Datum" -#: ../../../src/ui.cpp:305 +#: ../../../src/ui.cpp:355 msgid "Description" msgstr "Popis" -#: ../../../src/ui.cpp:306 +#: ../../../src/ui.cpp:356 msgid "Debit" msgstr "Výdaje" -#: ../../../src/ui.cpp:307 +#: ../../../src/ui.cpp:357 msgid "Credit" msgstr "Příjmy" -#: ../../../src/ui.cpp:513 +#: ../../../src/ui.cpp:568 #, c-format msgid "Open for %d blocks" msgstr "Otevřeno pro %d bloků" -#: ../../../src/ui.cpp:515 +#: ../../../src/ui.cpp:570 #, c-format msgid "Open until %s" msgstr "Otřevřeno dokud %s" -#: ../../../src/ui.cpp:521 +#: ../../../src/ui.cpp:576 #, c-format msgid "%d/offline?" msgstr "%d/offline?" -#: ../../../src/ui.cpp:523 +#: ../../../src/ui.cpp:578 #, c-format msgid "%d/unconfirmed" msgstr "%d/nepotvrzeno" -#: ../../../src/ui.cpp:525 +#: ../../../src/ui.cpp:580 #, c-format msgid "%d confirmations" msgstr "%d potvrzení" -#: ../../../src/ui.cpp:610 +#: ../../../src/ui.cpp:665 msgid "Generated" msgstr "Vygenerováno" -#: ../../../src/ui.cpp:618 +#: ../../../src/ui.cpp:673 #, c-format msgid "Generated (%s matures in %d more blocks)" msgstr "Vygenerováno (%s dozraje po %d blocích)" -#: ../../../src/ui.cpp:622 +#: ../../../src/ui.cpp:677 msgid "Generated - Warning: This block was not received by any other nodes and will probably not be accepted!" msgstr "Vygenerovaný - Varování: Tehnle blok nebyl obdržen žádným jiným uzlem a pravděpodobně nebude akceptován!" -#: ../../../src/ui.cpp:626 +#: ../../../src/ui.cpp:681 msgid "Generated (not accepted)" msgstr "Vygenerováno (neakceptováno)" -#: ../../../src/ui.cpp:636 +#: ../../../src/ui.cpp:691 msgid "From: " msgstr "Od: " -#: ../../../src/ui.cpp:660 +#: ../../../src/ui.cpp:715 msgid "Received with: " msgstr "Přijato adresou: " -#: ../../../src/ui.cpp:706 +#: ../../../src/ui.cpp:760 msgid "Payment to yourself" msgstr "Platba pro sebe sama" -#: ../../../src/ui.cpp:740 +#: ../../../src/ui.cpp:794 msgid "To: " msgstr "Pro: " -#: ../../../src/ui.cpp:1055 +#: ../../../src/ui.cpp:1109 msgid " Generating" msgstr " Generuji" -#: ../../../src/ui.cpp:1057 +#: ../../../src/ui.cpp:1111 msgid "(not connected)" msgstr "(nepřipojen)" -#: ../../../src/ui.cpp:1060 +#: ../../../src/ui.cpp:1114 #, c-format msgid " %d connections %d blocks %d transactions" msgstr " %d spojení %d bloků %d transakcí" -#: ../../../src/ui.cpp:1165 -#: ../../../src/ui.cpp:2529 +#: ../../../src/ui.cpp:1171 +msgid "Wallet already encrypted." +msgstr "Peněženka je už zašifrovaná." + +#: ../../../src/ui.cpp:1182 +msgid "" +"Enter the new passphrase to the wallet.\n" +"Please use a passphrase of 10 or more random characters, or eight or more words." +msgstr "" +"Zadej nové heslo pro peněženku.\n" +"Použij alespoň 10 náhodných znaků nebo alespoň 8 slov." + +#: ../../../src/ui.cpp:1189 +#: ../../../src/ui.cpp:1282 +msgid "Error: The supplied passphrase was too short." +msgstr "Chyba: Zadané heslo je příliš krátké." + +#: ../../../src/ui.cpp:1193 +msgid "" +"WARNING: If you encrypt your wallet and lose your passphrase, you will LOSE ALL OF YOUR BITCOINS!\n" +"Are you sure you wish to encrypt your wallet?" +msgstr "" +"VAROVÁNÍ: Pokud zašifruješ peněženku a ztratíš či zapomeneš heslo, PŘIJDEŠ O VŠECHNY BITCOINY!\n" +"Jsi si jistý, že chceš peněženku zašifrovat?" + +#: ../../../src/ui.cpp:1199 +msgid "Please re-enter your new wallet passphrase." +msgstr "Zadej ještě jednou nové heslo pro peněženku." + +#: ../../../src/ui.cpp:1208 +#: ../../../src/ui.cpp:1304 +msgid "Error: the supplied passphrases didn't match." +msgstr "Chyba: zadaná hesla nejsou shodná." + +#: ../../../src/ui.cpp:1218 +msgid "Wallet encryption failed." +msgstr "Zašifrování peněženky selhalo." + +#: ../../../src/ui.cpp:1225 +msgid "" +"Wallet Encrypted.\n" +"Remember that encrypting your wallet cannot fully protect your bitcoins from being stolen by malware infecting your computer." +msgstr "" +"Peněženka je zašifrována.\n" +"Pamatuj, že pouhé šifrování peněženky nemůže plně ochránit tvé bitcoiny před krádeží malwarem, kterým se může počítač nakazit." + +#: ../../../src/ui.cpp:1236 +msgid "Wallet is unencrypted, please encrypt it first." +msgstr "Peněženka není zašifrovaná, musíš ji prvně zašifrovat." + +#: ../../../src/ui.cpp:1273 +msgid "Enter the new passphrase for the wallet." +msgstr "Zadej nové heslo pro peněženku." + +#: ../../../src/ui.cpp:1293 +msgid "Re-enter the new passphrase for the wallet." +msgstr "Zadej ještě jednou nové heslo pro peněženku." + +#: ../../../src/ui.cpp:1325 +msgid "Wallet Passphrase Changed." +msgstr "Heslo peněženky bylo změněno." + +#: ../../../src/ui.cpp:1382 +#: ../../../src/ui.cpp:2815 msgid "New Receiving Address" msgstr "Nová Bitcoinová adresa" -#: ../../../src/ui.cpp:1166 -#: ../../../src/ui.cpp:2530 +#: ../../../src/ui.cpp:1383 +#: ../../../src/ui.cpp:2816 msgid "" "You should use a new address for each payment you receive.\n" "\n" @@ -134,248 +561,226 @@ msgstr "" "\n" "Označení" -#: ../../../src/ui.cpp:1235 +#: ../../../src/ui.cpp:1467 msgid "<b>Status:</b> " msgstr "<b>Stav:</b> " -#: ../../../src/ui.cpp:1240 +#: ../../../src/ui.cpp:1472 msgid ", has not been successfully broadcast yet" msgstr ", ještě nebylo rozesláno" -#: ../../../src/ui.cpp:1242 +#: ../../../src/ui.cpp:1474 #, c-format msgid ", broadcast through %d node" msgstr ", rozesláno přes %d uzel" -#: ../../../src/ui.cpp:1244 +#: ../../../src/ui.cpp:1476 #, c-format msgid ", broadcast through %d nodes" msgstr ", rozesláno přes %d uzlů" -#: ../../../src/ui.cpp:1248 +#: ../../../src/ui.cpp:1480 msgid "<b>Date:</b> " msgstr "<b>Datum:</b> " -#: ../../../src/ui.cpp:1256 +#: ../../../src/ui.cpp:1488 msgid "<b>Source:</b> Generated<br>" msgstr "<b>Zdroj:</b> Vygenerováno<br>" -#: ../../../src/ui.cpp:1262 -#: ../../../src/ui.cpp:1280 +#: ../../../src/ui.cpp:1494 +#: ../../../src/ui.cpp:1511 msgid "<b>From:</b> " msgstr "<b>Od:</b> " -#: ../../../src/ui.cpp:1280 +#: ../../../src/ui.cpp:1511 msgid "unknown" msgstr "neznámo" -#: ../../../src/ui.cpp:1281 -#: ../../../src/ui.cpp:1305 -#: ../../../src/ui.cpp:1364 +#: ../../../src/ui.cpp:1512 +#: ../../../src/ui.cpp:1536 +#: ../../../src/ui.cpp:1595 msgid "<b>To:</b> " msgstr "<b>Pro:</b> " -#: ../../../src/ui.cpp:1284 +#: ../../../src/ui.cpp:1515 msgid " (yours, label: " msgstr " (tvoje, označení: " -#: ../../../src/ui.cpp:1286 +#: ../../../src/ui.cpp:1517 msgid " (yours)" msgstr " (tvoje)" -#: ../../../src/ui.cpp:1323 -#: ../../../src/ui.cpp:1335 -#: ../../../src/ui.cpp:1381 -#: ../../../src/ui.cpp:1398 +#: ../../../src/ui.cpp:1554 +#: ../../../src/ui.cpp:1566 +#: ../../../src/ui.cpp:1612 +#: ../../../src/ui.cpp:1629 msgid "<b>Credit:</b> " msgstr "<b>Příjem:</b> " -#: ../../../src/ui.cpp:1325 +#: ../../../src/ui.cpp:1556 #, c-format msgid "(%s matures in %d more blocks)" msgstr "(%s dozraje po %d blocích)" -#: ../../../src/ui.cpp:1327 +#: ../../../src/ui.cpp:1558 msgid "(not accepted)" msgstr "(neakceptováno)" -#: ../../../src/ui.cpp:1372 -#: ../../../src/ui.cpp:1380 -#: ../../../src/ui.cpp:1395 +#: ../../../src/ui.cpp:1603 +#: ../../../src/ui.cpp:1611 +#: ../../../src/ui.cpp:1626 msgid "<b>Debit:</b> " msgstr "<b>Výdaj:</b> " -#: ../../../src/ui.cpp:1386 +#: ../../../src/ui.cpp:1617 msgid "<b>Transaction fee:</b> " msgstr "<b>Transakční poplatek:</b> " -#: ../../../src/ui.cpp:1402 +#: ../../../src/ui.cpp:1633 msgid "<b>Net amount:</b> " msgstr "<b>Čistá částka:</b> " -#: ../../../src/ui.cpp:1409 +#: ../../../src/ui.cpp:1640 msgid "Message:" msgstr "Zpráva:" -#: ../../../src/ui.cpp:1411 +#: ../../../src/ui.cpp:1642 msgid "Comment:" msgstr "Komentář:" -#: ../../../src/ui.cpp:1414 +#: ../../../src/ui.cpp:1645 msgid "Generated coins must wait 120 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, it will change to \"not accepted\" and not be spendable. This may occasionally happen if another node generates a block within a few seconds of yours." msgstr "Vygenerované mince musí čekat 120 bloků, než mohou být utraceny. Když jsi vygeneroval tenhle blok, tak byl rozposlán do sítě, aby byl přidán do řetězce bloků. Pokud se mu nepodaří dostat se do řetězce, změní se na \"neakceptovaný\" a nebude utratitelný. To se občas může přihodit, pokud jiný uzel vygeneruje blok zhruba ve stejném okamžiku jako ty." -#: ../../../src/ui.cpp:1594 +#: ../../../src/ui.cpp:1825 msgid "Cannot write autostart/bitcoin.desktop file" msgstr "Nemohu zapisovat do souboru autostart/bitcoin.desktop" -#: ../../../src/ui.cpp:1630 +#: ../../../src/ui.cpp:1861 msgid "Main" msgstr "Hlavní" -#: ../../../src/ui.cpp:1638 +#: ../../../src/ui.cpp:1871 msgid "&Start Bitcoin on window system startup" msgstr "&Spustit Bitcoin při startu okenního systému" -#: ../../../src/ui.cpp:1645 +#: ../../../src/ui.cpp:1878 msgid "&Minimize on close" msgstr "&Zavřením pouze skrýt" -#: ../../../src/ui.cpp:1787 +#: ../../../src/ui.cpp:2020 #, c-format msgid "version %s" msgstr "verze %s" -#: ../../../src/ui.cpp:1899 +#: ../../../src/ui.cpp:2143 msgid "Error in amount " msgstr "Chyba v částce" -#: ../../../src/ui.cpp:1899 -#: ../../../src/ui.cpp:1904 -#: ../../../src/ui.cpp:1909 -#: ../../../src/ui.cpp:1944 -#: ../../../src/uibase.cpp:55 -msgid "Send Coins" -msgstr "Pošli mince" - -#: ../../../src/ui.cpp:1904 +#: ../../../src/ui.cpp:2148 msgid "Amount exceeds your balance " msgstr "Částka překračuje stav účtu" -#: ../../../src/ui.cpp:1909 +#: ../../../src/ui.cpp:2153 msgid "Total exceeds your balance when the " msgstr "Celková částka přesahuje stav tvého účtu, když " -#: ../../../src/ui.cpp:1909 +#: ../../../src/ui.cpp:2153 msgid " transaction fee is included " msgstr " transakční poplatek je zahrnut" -#: ../../../src/ui.cpp:1927 +#: ../../../src/ui.cpp:2176 msgid "Payment sent " msgstr "Platba odeslána" -#: ../../../src/ui.cpp:1927 -#: ../../../src/ui.cpp:1932 -#: ../../../src/ui.cpp:2076 -#: ../../../src/ui.cpp:2229 -#: ../../../src/main.cpp:3997 -msgid "Sending..." -msgstr "Posílám..." - -#: ../../../src/ui.cpp:1944 +#: ../../../src/ui.cpp:2202 msgid "Invalid address " msgstr "Neplatná adresa" -#: ../../../src/ui.cpp:1997 +#: ../../../src/ui.cpp:2257 #, c-format msgid "Sending %s to %s" msgstr "Posílám %s %s" -#: ../../../src/ui.cpp:2070 -#: ../../../src/ui.cpp:2103 +#: ../../../src/ui.cpp:2330 +#: ../../../src/ui.cpp:2363 msgid "CANCELLED" msgstr "ZRUŠENO" -#: ../../../src/ui.cpp:2074 +#: ../../../src/ui.cpp:2334 msgid "Cancelled" msgstr "Zrušeno" -#: ../../../src/ui.cpp:2076 +#: ../../../src/ui.cpp:2336 msgid "Transfer cancelled " msgstr "Převod zrušen" -#: ../../../src/ui.cpp:2129 +#: ../../../src/ui.cpp:2389 msgid "Error: " msgstr "Chyba: " -#: ../../../src/ui.cpp:2143 -#: ../../../src/ui.cpp:2214 -#: ../../../src/main.cpp:4016 -msgid "Insufficient funds" -msgstr "Nedostatek peněz" - -#: ../../../src/ui.cpp:2148 +#: ../../../src/ui.cpp:2408 msgid "Connecting..." msgstr "Připojuji..." -#: ../../../src/ui.cpp:2153 +#: ../../../src/ui.cpp:2413 msgid "Unable to connect" msgstr "Nemohu se připojit" -#: ../../../src/ui.cpp:2158 +#: ../../../src/ui.cpp:2418 msgid "Requesting public key..." msgstr "Požaduji veřejný klíč..." -#: ../../../src/ui.cpp:2170 +#: ../../../src/ui.cpp:2430 msgid "Received public key..." msgstr "Přijat veřejný klíč..." -#: ../../../src/ui.cpp:2184 +#: ../../../src/ui.cpp:2444 msgid "Recipient is not accepting transactions sent by IP address" msgstr "Příjemce neakceptuje transakce poslané IP adresou" -#: ../../../src/ui.cpp:2186 +#: ../../../src/ui.cpp:2446 msgid "Transfer was not accepted" msgstr "Převod nebyl akceptován" -#: ../../../src/ui.cpp:2195 +#: ../../../src/ui.cpp:2455 msgid "Invalid response received" msgstr "Přišla neplatná odpověď" -#: ../../../src/ui.cpp:2210 +#: ../../../src/ui.cpp:2470 msgid "Creating transaction..." msgstr "Vytvářím transakci..." -#: ../../../src/ui.cpp:2222 +#: ../../../src/ui.cpp:2489 #, c-format msgid "This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds" msgstr "Tato transakce vyžaduje transakční poplatek nejméně %s kvůli svému objemu, komplexnosti nebo utrácení nedávno přijaté hotovosti" -#: ../../../src/ui.cpp:2224 +#: ../../../src/ui.cpp:2491 msgid "Transaction creation failed" msgstr "Vytvoření transakce selhalo" -#: ../../../src/ui.cpp:2231 +#: ../../../src/ui.cpp:2502 msgid "Transaction aborted" msgstr "Transakce zrušena" -#: ../../../src/ui.cpp:2239 +#: ../../../src/ui.cpp:2510 msgid "Lost connection, transaction cancelled" msgstr "Spojení se ztratilo, takže transakce byla zrušena" -#: ../../../src/ui.cpp:2255 +#: ../../../src/ui.cpp:2526 msgid "Sending payment..." msgstr "Posílám platbu..." -#: ../../../src/ui.cpp:2261 +#: ../../../src/ui.cpp:2532 msgid "The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here." msgstr "Transakce byla odmítnuta. Tohle může nastat, pokud nějaké mince z tvé peněženky už jednou byly utraceny, například pokud používáš kopii souboru wallet.dat a mince byly utraceny v druhé kopii, ale nebyly označeny jako utracené v této." -#: ../../../src/ui.cpp:2270 +#: ../../../src/ui.cpp:2541 msgid "Waiting for confirmation..." msgstr "Čekám na potvrzení..." -#: ../../../src/ui.cpp:2288 +#: ../../../src/ui.cpp:2559 msgid "" "The payment was sent, but the recipient was unable to verify it.\n" "The transaction is recorded and will credit to the recipient,\n" @@ -385,518 +790,202 @@ msgstr "" "Transakce je zaznamenána a bude připsána příjemci,\n" "ale poznámka u platby bude prázdná." -#: ../../../src/ui.cpp:2297 +#: ../../../src/ui.cpp:2568 msgid "Payment was sent, but an invalid response was received" msgstr "Platba byla odeslána, ale přišla neplatná odpověď" -#: ../../../src/ui.cpp:2303 +#: ../../../src/ui.cpp:2574 msgid "Payment completed" msgstr "Platba je kompletní" -#: ../../../src/ui.cpp:2334 -#: ../../../src/ui.cpp:2480 -#: ../../../src/ui.cpp:2517 +#: ../../../src/ui.cpp:2616 +#: ../../../src/ui.cpp:2763 +#: ../../../src/ui.cpp:2803 msgid "Name" msgstr "Jméno" -#: ../../../src/ui.cpp:2335 -#: ../../../src/ui.cpp:2480 -#: ../../../src/ui.cpp:2517 +#: ../../../src/ui.cpp:2617 +#: ../../../src/ui.cpp:2763 +#: ../../../src/ui.cpp:2803 msgid "Address" msgstr "Adresa" -#: ../../../src/ui.cpp:2337 -#: ../../../src/ui.cpp:2492 +#: ../../../src/ui.cpp:2619 +#: ../../../src/ui.cpp:2775 msgid "Label" msgstr "Označení" -#: ../../../src/ui.cpp:2338 -#: ../../../src/uibase.cpp:837 -msgid "Bitcoin Address" -msgstr "Bitcoinová adresa" - -#: ../../../src/ui.cpp:2462 +#: ../../../src/ui.cpp:2745 msgid "This is one of your own addresses for receiving payments and cannot be entered in the address book. " msgstr "Tohle je jedna z tvých vlastních adres pro příjem plateb a nemůže být zadána do adresáře." -#: ../../../src/ui.cpp:2480 -#: ../../../src/ui.cpp:2486 +#: ../../../src/ui.cpp:2763 +#: ../../../src/ui.cpp:2769 msgid "Edit Address" msgstr "Upravit adresu" -#: ../../../src/ui.cpp:2492 +#: ../../../src/ui.cpp:2775 msgid "Edit Address Label" msgstr "Upravit označení adresy" -#: ../../../src/ui.cpp:2517 -#: ../../../src/ui.cpp:2523 +#: ../../../src/ui.cpp:2803 +#: ../../../src/ui.cpp:2809 msgid "Add Address" msgstr "Přidat adresu" -#: ../../../src/ui.cpp:2600 +#: ../../../src/ui.cpp:2897 msgid "Bitcoin" msgstr "Bitcoin" -#: ../../../src/ui.cpp:2602 +#: ../../../src/ui.cpp:2899 msgid "Bitcoin - Generating" msgstr "Bitcoin - Generování" -#: ../../../src/ui.cpp:2604 +#: ../../../src/ui.cpp:2901 msgid "Bitcoin - (not connected)" msgstr "Bitcoin - (nepřipojen)" -#: ../../../src/ui.cpp:2683 +#: ../../../src/ui.cpp:2980 msgid "&Open Bitcoin" msgstr "&Otevřít Bitcoin" -#: ../../../src/ui.cpp:2684 +#: ../../../src/ui.cpp:2981 msgid "&Send Bitcoins" msgstr "&Poslat Bitcoiny" -#: ../../../src/ui.cpp:2685 +#: ../../../src/ui.cpp:2982 msgid "O&ptions..." msgstr "&Možnosti..." -#: ../../../src/ui.cpp:2688 -#: ../../../src/uibase.cpp:25 -msgid "E&xit" -msgstr "&Konec" - -#: ../../../src/ui.cpp:2904 +#: ../../../src/ui.cpp:3211 msgid "Program has crashed and will terminate. " msgstr "Program havaroval a bude ukončen." -#: ../../../src/main.cpp:1866 -msgid "Warning: Disk space is low " -msgstr "Upozornění: Na disku je málo místa" - -#: ../../../src/main.cpp:3990 -#, c-format -msgid "Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds " -msgstr "Chyba: Tato transakce vyžaduje transakční poplatek nejméně %s kvůli svému objemu, komplexnosti nebo utrácení nedávno přijaté hotovosti" - -#: ../../../src/main.cpp:3992 -msgid "Error: Transaction creation failed " -msgstr "Chyba: Vytvoření transakce selhalo" - -#: ../../../src/main.cpp:4001 -msgid "Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here." -msgstr "Chyba: Transakce byla odmítnuta. Tohle může nastat, pokud nějaké mince z tvé peněženky už jednou byly utraceny, například pokud používáš kopii souboru wallet.dat a mince byly utraceny v druhé kopii, ale nebyly označeny jako utracené v této." - -#: ../../../src/main.cpp:4014 -msgid "Invalid amount" -msgstr "Neplatná částka" - -#: ../../../src/main.cpp:4021 -msgid "Invalid bitcoin address" -msgstr "Neplatná Bitcoinová adresa" - -#: ../../../src/rpc.cpp:1802 -#: ../../../src/rpc.cpp:1804 -#, c-format -msgid "To use the %s option" -msgstr "Pro použití volby %s" - -#: ../../../src/rpc.cpp:1806 -#, c-format -msgid "" -"Warning: %s, you must set rpcpassword=<password>\n" -"in the configuration file: %s\n" -"If the file does not exist, create it with owner-readable-only file permissions.\n" -msgstr "" -"Varování: %s, musíš nastavit rpcpassword=<heslo>\n" -"v konfiguračním souboru: %s\n" -"Pokud tenhle soubor neexistuje, vytvoř ho s oprávněním pro čtení pouze pro vlastníka.\n" - -#: ../../../src/rpc.cpp:1974 -#, c-format -msgid "" -"You must set rpcpassword=<password> in the configuration file:\n" -"%s\n" -"If the file does not exist, create it with owner-readable-only file permissions." -msgstr "" -"Musíš nastavit rpcpassword=<heslo> v konfiguračním souboru:\n" -"%s\n" -"Pokud tenhle soubor neexistuje, vytvoř ho s oprávněním pro čtení pouze pro vlastníka." - -#: ../../../src/util.cpp:866 -msgid "Warning: Please check that your computer's date and time are correct. If your clock is wrong Bitcoin will not work properly." -msgstr "Varování: Prosím zkontroluj, že datum a čas jsou na tvém počítači správně nastaveny. Pokud jsou nastaveny špatně, Bitcoin nebude fungovat správně." - -#: ../../../src/util.cpp:899 -msgid "beta" -msgstr "beta" - -#: ../../../src/uibase.cpp:28 -msgid "&File" -msgstr "&Soubor" - -#: ../../../src/uibase.cpp:32 -msgid "&Your Receiving Addresses..." -msgstr "Tvá Bitcoinová &adresa..." - -#: ../../../src/uibase.cpp:36 -msgid "&Options..." -msgstr "M&ožnosti" - -#: ../../../src/uibase.cpp:39 -msgid "&Settings" -msgstr "Nas&tavení" - -#: ../../../src/uibase.cpp:43 -msgid "&About..." -msgstr "&O programu" - -#: ../../../src/uibase.cpp:46 -msgid "&Help" -msgstr "&Nápověda" - -#: ../../../src/uibase.cpp:56 -msgid "Address Book" -msgstr "Adresář" - -#: ../../../src/uibase.cpp:69 -msgid "Your Bitcoin Address:" -msgstr "Tvá Bitcoinová adresa:" - -#: ../../../src/uibase.cpp:76 -msgid " &New... " -msgstr " &Nová..." - -#: ../../../src/uibase.cpp:79 -#: ../../../src/uibase.cpp:780 -#: ../../../src/uibase.cpp:883 -msgid " &Copy to Clipboard " -msgstr " &Kopírovat do schránky" - -#: ../../../src/uibase.cpp:93 -msgid "Balance:" -msgstr "Stav účtu:" - -#: ../../../src/uibase.cpp:109 -msgid " All" -msgstr " Vše" - -#: ../../../src/uibase.cpp:109 -msgid " Sent" -msgstr " Odeslané" - -#: ../../../src/uibase.cpp:109 -msgid " Received" -msgstr " Přijaté" - -#: ../../../src/uibase.cpp:109 -msgid " In Progress" -msgstr " Pracuje se na tom" - -#: ../../../src/uibase.cpp:130 -msgid "All Transactions" -msgstr "Všechny transakce" - -#: ../../../src/uibase.cpp:141 -msgid "Sent/Received" -msgstr "Odeslané/Přijaté" - -#: ../../../src/uibase.cpp:152 -msgid "Sent" -msgstr "Odeslané" - -#: ../../../src/uibase.cpp:163 -msgid "Received" -msgstr "Přijaté" - -#: ../../../src/uibase.cpp:302 -#: ../../../src/uibase.cpp:443 -#: ../../../src/uibase.cpp:542 -#: ../../../src/uibase.cpp:722 -#: ../../../src/uibase.cpp:783 -#: ../../../src/uibase.cpp:892 -#: ../../../src/uibase.cpp:981 -msgid "OK" -msgstr "&Budiž" - -#: ../../../src/uibase.cpp:345 -msgid "&Start Bitcoin on system startup" -msgstr "&Spustit Bitcoin při startu systému" - -#: ../../../src/uibase.cpp:348 -msgid "&Minimize to the tray instead of the taskbar" -msgstr "&Minimalizovávat do ikony v panelu" - -#: ../../../src/uibase.cpp:351 -msgid "Map port using &UPnP" -msgstr "Namapovat port přes &UPnP" - -#: ../../../src/uibase.cpp:354 -msgid "M&inimize to the tray on close" -msgstr "Zavřením &minimalizovat do ikony" - -#: ../../../src/uibase.cpp:360 -msgid "&Connect through socks4 proxy: " -msgstr "&Připojit přes socks4 proxy:" - -#: ../../../src/uibase.cpp:371 -msgid "Proxy &IP:" -msgstr "&IP adresa proxy:" - -#: ../../../src/uibase.cpp:379 -msgid " &Port:" -msgstr " &Port:" - -#: ../../../src/uibase.cpp:392 -msgid "Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended." -msgstr "Dobrovolný transakční poplatek za každý započatý KB napomáhá tomu, aby tvé transakce byly rychle zpracovány. Většina transakcí má do 1 KB. Doporučená výše poplatku je 0.01." - -#: ../../../src/uibase.cpp:399 -msgid "Pay transaction fee:" -msgstr "Výše transakčního poplatku:" - -#: ../../../src/uibase.cpp:420 -msgid "// [don't translate] Test panel 2 for future expansion" -msgstr "" - -#: ../../../src/uibase.cpp:424 -msgid "// [don't translate] Let's not start multiple pages until the first page is filled up" -msgstr "" - -#: ../../../src/uibase.cpp:446 -#: ../../../src/uibase.cpp:668 -#: ../../../src/uibase.cpp:727 -#: ../../../src/uibase.cpp:786 -#: ../../../src/uibase.cpp:895 -#: ../../../src/uibase.cpp:984 -msgid "Cancel" -msgstr "&Zrušit" - -#: ../../../src/uibase.cpp:449 -msgid "&Apply" -msgstr "&Použít" - -#: ../../../src/uibase.cpp:508 -msgid "Bitcoin " -msgstr "Bitcoin" - -#: ../../../src/uibase.cpp:514 -msgid "version" -msgstr "verze" - -#: ../../../src/uibase.cpp:525 -msgid "" -"Copyright (c) 2009-2011 Bitcoin Developers\n" -"\n" -"This is experimental software.\n" -"\n" -"Distributed under the MIT/X11 software license, see the accompanying file \n" -"license.txt or http://www.opensource.org/licenses/mit-license.php.\n" -"\n" -"This product includes software developed by the OpenSSL Project for use in the \n" -"OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \n" -"Eric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard." -msgstr "" -"Copyright (c) 2009-2011 Vývojáři Bitcoinu\n" -"\n" -"Tohle je experimentální program.\n" -"\n" -"Šířen pod licencí MIT/X11, viz přiložený soubor license.txt nebo \n" -"http://www.opensource.org/licenses/mit-license.php.\n" -"\n" -"Tento produkt zahrnuje programy vyvinuté OpenSSL Projektem pro použití \n" -"v OpenSSL Toolkitu (http://www.openssl.org/) a kryptografický program od \n" -"Erika Younga (eay@cryptsoft.com) a program UPnP od Thomase Bernarda." - -#: ../../../src/uibase.cpp:581 -msgid "Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)" -msgstr "Vlož Bitcoinovou adresu (např. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)" - -#: ../../../src/uibase.cpp:595 -msgid "Pay &To:" -msgstr "&Komu:" - -#: ../../../src/uibase.cpp:610 -msgid "&Paste" -msgstr "&Vložit" - -#: ../../../src/uibase.cpp:613 -msgid " Address &Book..." -msgstr " &Adresář..." - -#: ../../../src/uibase.cpp:620 -msgid "&Amount:" -msgstr "&Částka" - -#: ../../../src/uibase.cpp:630 -msgid "T&ransfer:" -msgstr "&Převod:" - -#: ../../../src/uibase.cpp:636 -msgid " Standard" -msgstr " Standard" - -#: ../../../src/uibase.cpp:663 -msgid "&Send" -msgstr "&Poslat" - -#: ../../../src/uibase.cpp:711 -msgid "" -"\n" -"\n" -"Connecting..." -msgstr "" -"\n" -"\n" -"Připojuji..." - -#: ../../../src/uibase.cpp:761 -msgid "These are your Bitcoin addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you. The highlighted address is displayed in the main window." -msgstr "Tohle jsou tvé Bitcoinové adresy na příjem plateb. Asi budeš chtít dát jinou adresu každému odesílateli, abys věděl, kdo ti kolik platil. Označená adresa bude zobrazena v hlavním okně." - -#: ../../../src/uibase.cpp:774 -#: ../../../src/uibase.cpp:886 -msgid "&Edit..." -msgstr "&Upravit..." - -#: ../../../src/uibase.cpp:777 -#: ../../../src/uibase.cpp:889 -msgid " &New Address... " -msgstr " &Nová adresa..." - -#: ../../../src/uibase.cpp:849 -msgid "Sending" -msgstr "Cizí adresy (pro odesílání)" - -#: ../../../src/uibase.cpp:857 -msgid "These are your Bitcoin addresses for receiving payments. You can give a different one to each sender to keep track of who is paying you. The highlighted address will be displayed in the main window." -msgstr "Tohle jsou tvé Bitcoinové adresy na příjem plateb. Můžeš dát jinou adresu každému odesílateli, abys věděl, kdo ti kolik platil. Označená adresa bude zobrazena v hlavním okně." - -#: ../../../src/uibase.cpp:870 -msgid "Receiving" -msgstr "Tvoje adresy (pro příjem)" - -#: ../../../src/uibase.cpp:880 -msgid "&Delete" -msgstr "&Smazat" - -#: ../../../src/init.cpp:142 +#: ../../../src/init.cpp:163 msgid "Bitcoin version" msgstr "Bitcoin verze" -#: ../../../src/init.cpp:143 +#: ../../../src/init.cpp:164 msgid "Usage:" msgstr "Užití:" -#: ../../../src/init.cpp:145 +#: ../../../src/init.cpp:166 msgid "Send command to -server or bitcoind\n" msgstr "Poslat příkaz pro -server nebo bitcoind\n" -#: ../../../src/init.cpp:146 +#: ../../../src/init.cpp:167 msgid "List commands\n" msgstr "Výpis příkazů\n" -#: ../../../src/init.cpp:147 +#: ../../../src/init.cpp:168 msgid "Get help for a command\n" msgstr "Získat nápovědu pro příkaz\n" -#: ../../../src/init.cpp:148 +#: ../../../src/init.cpp:169 msgid "Options:\n" msgstr "Možnosti:\n" -#: ../../../src/init.cpp:149 +#: ../../../src/init.cpp:170 msgid "Specify configuration file (default: bitcoin.conf)\n" msgstr "Konfigurační soubor (výchozí: bitcoin.conf)\n" -#: ../../../src/init.cpp:150 +#: ../../../src/init.cpp:171 msgid "Specify pid file (default: bitcoind.pid)\n" msgstr "PID soubor (výchozí: bitcoind.pid)\n" -#: ../../../src/init.cpp:151 +#: ../../../src/init.cpp:172 msgid "Generate coins\n" msgstr "Generovat mince\n" -#: ../../../src/init.cpp:152 +#: ../../../src/init.cpp:173 msgid "Don't generate coins\n" msgstr "Negenerovat mince\n" -#: ../../../src/init.cpp:153 +#: ../../../src/init.cpp:174 msgid "Start minimized\n" msgstr "Startovat minimalizovaně\n" -#: ../../../src/init.cpp:154 +#: ../../../src/init.cpp:175 msgid "Specify data directory\n" msgstr "Adresář pro data\n" -#: ../../../src/init.cpp:155 +#: ../../../src/init.cpp:176 +msgid "Specify connection timeout (in milliseconds)\n" +msgstr "Zadej časový limit spojení (v milisekundách)\n" + +#: ../../../src/init.cpp:177 msgid "Connect through socks4 proxy\n" msgstr "Připojovat se skrz socks4 proxy\n" -#: ../../../src/init.cpp:156 +#: ../../../src/init.cpp:178 msgid "Allow DNS lookups for addnode and connect\n" msgstr "Povolit DNS dotazy pro addnode (přidání uzlu) a connect (připojení)\n" -#: ../../../src/init.cpp:157 +#: ../../../src/init.cpp:179 msgid "Add a node to connect to\n" msgstr "Přidat uzel, ke kterému se připojit\n" -#: ../../../src/init.cpp:158 +#: ../../../src/init.cpp:180 msgid "Connect only to the specified node\n" msgstr "Připojovat se pouze k udanému uzlu\n" -#: ../../../src/init.cpp:159 +#: ../../../src/init.cpp:181 msgid "Don't accept connections from outside\n" msgstr "Nepřijímat připojení zvenčí\n" -#: ../../../src/init.cpp:162 +#: ../../../src/init.cpp:184 msgid "Don't attempt to use UPnP to map the listening port\n" msgstr "Nesnažit se použít UPnP k namapování naslouchacího portu\n" -#: ../../../src/init.cpp:164 +#: ../../../src/init.cpp:186 msgid "Attempt to use UPnP to map the listening port\n" msgstr "Snažit se použít UPnP k namapování naslouchacího portu\n" -#: ../../../src/init.cpp:167 +#: ../../../src/init.cpp:189 msgid "Fee per KB to add to transactions you send\n" msgstr "Poplatek za KB, který se přidá ke každé odeslané transakci\n" -#: ../../../src/init.cpp:169 +#: ../../../src/init.cpp:191 msgid "Accept command line and JSON-RPC commands\n" msgstr "Akceptovat příkazy z příkazové řádky a přes JSON-RPC\n" -#: ../../../src/init.cpp:172 +#: ../../../src/init.cpp:194 msgid "Run in the background as a daemon and accept commands\n" msgstr "Běžet na pozadí jako démon a akceptovat příkazy\n" -#: ../../../src/init.cpp:174 +#: ../../../src/init.cpp:196 msgid "Use the test network\n" msgstr "Použít testovací síť\n" -#: ../../../src/init.cpp:175 +#: ../../../src/init.cpp:197 msgid "Username for JSON-RPC connections\n" msgstr "Uživatelské jméno pro JSON-RPC spojení\n" -#: ../../../src/init.cpp:176 +#: ../../../src/init.cpp:198 msgid "Password for JSON-RPC connections\n" msgstr "Heslo pro JSON-RPC spojení\n" -#: ../../../src/init.cpp:177 +#: ../../../src/init.cpp:199 msgid "Listen for JSON-RPC connections on <port> (default: 8332)\n" msgstr "Čekat na JSON-RPC spojení na <portu> (výchozí: 8332)\n" -#: ../../../src/init.cpp:178 +#: ../../../src/init.cpp:200 msgid "Allow JSON-RPC connections from specified IP address\n" msgstr "Povolit JSON-RPC spojení ze specifikované IP adresy\n" -#: ../../../src/init.cpp:179 +#: ../../../src/init.cpp:201 msgid "Send commands to node running on <ip> (default: 127.0.0.1)\n" msgstr "Posílat příkazy uzlu běžícím na <ip> (výchozí: 127.0.0.1)\n" -#: ../../../src/init.cpp:180 +#: ../../../src/init.cpp:202 msgid "Set key pool size to <n> (default: 100)\n" msgstr "Nastavit zásobník klíčů na velikost <n> (výchozí: 100)\n" -#: ../../../src/init.cpp:181 +#: ../../../src/init.cpp:203 msgid "Rescan the block chain for missing wallet transactions\n" msgstr "Přeskenovat řetězec bloků na chybějící transakce peněženky\n" -#: ../../../src/init.cpp:185 +#: ../../../src/init.cpp:207 msgid "" "\n" "SSL options: (see the Bitcoin Wiki for SSL setup instructions)\n" @@ -904,68 +993,87 @@ msgstr "" "\n" "Možnosti SSL: (viz instrukce nastavení SSL v Bitcoin Wiki)\n" -#: ../../../src/init.cpp:186 +#: ../../../src/init.cpp:208 msgid "Use OpenSSL (https) for JSON-RPC connections\n" msgstr "Použít OpenSSL (https) pro JSON-RPC spojení\n" -#: ../../../src/init.cpp:187 +#: ../../../src/init.cpp:209 msgid "Server certificate file (default: server.cert)\n" msgstr "Soubor se serverovým certifikátem (výchozí: server.cert)\n" -#: ../../../src/init.cpp:188 +#: ../../../src/init.cpp:210 msgid "Server private key (default: server.pem)\n" msgstr "Soubor se serverovým soukromým klíčem (výchozí: server.pem)\n" -#: ../../../src/init.cpp:189 +#: ../../../src/init.cpp:211 msgid "Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)\n" msgstr "Akceptovatelné šifry (výchozí: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)\n" -#: ../../../src/init.cpp:193 +#: ../../../src/init.cpp:215 msgid "This help message\n" msgstr "Tato nápověda\n" -#: ../../../src/init.cpp:330 +#: ../../../src/init.cpp:353 #, c-format msgid "Cannot obtain a lock on data directory %s. Bitcoin is probably already running." msgstr "Nedaří se mi získat zámek na datový adresář %s. Bitcoin pravděpodobně už jednou běží." -#: ../../../src/init.cpp:356 +#: ../../../src/init.cpp:379 msgid "Error loading addr.dat \n" msgstr "Chyba při načítání addr.dat \n" -#: ../../../src/init.cpp:362 +#: ../../../src/init.cpp:385 msgid "Error loading blkindex.dat \n" msgstr "Chyba při načítání blkindex.dat \n" -#: ../../../src/init.cpp:369 +#: ../../../src/init.cpp:396 +msgid "Error loading wallet.dat: Wallet corrupted \n" +msgstr "Chyba při načítání wallet.dat: peněženka je poškozená \n" + +#: ../../../src/init.cpp:398 +msgid "Error loading wallet.dat: Wallet requires newer version of Bitcoin \n" +msgstr "Chyba při načítání wallet.dat: peněženka vyžaduje novější verzi Bitcoinu \n" + +#: ../../../src/init.cpp:400 msgid "Error loading wallet.dat \n" msgstr "Chyba při načítání wallet.dat \n" -#: ../../../src/init.cpp:449 +#: ../../../src/init.cpp:489 msgid "Invalid -proxy address" msgstr "Neplatná -proxy adresa" -#: ../../../src/init.cpp:472 +#: ../../../src/init.cpp:514 msgid "Invalid amount for -paytxfee=<amount>" msgstr "Neplatná částka pro -paytxfee=<částka>" -#: ../../../src/init.cpp:476 +#: ../../../src/init.cpp:518 msgid "Warning: -paytxfee is set very high. This is the transaction fee you will pay if you send a transaction." msgstr "Varování: -paytxfee je nastaveno velmi vysoko. Toto je transakční poplatek, který zaplatíš za každou poslanou transakci." -#: ../../../src/uibase.h:147 +#: ../../../src/net.cpp:1622 +#, c-format +msgid "Unable to bind to port %d on this computer. Bitcoin is probably already running." +msgstr "Nedaří se mi připojit na port %d na tomhle počítači. Bitcoin už pravděpodobně jednou běží." + +#: ../../../src/main.cpp:1437 +msgid "Warning: Disk space is low " +msgstr "Upozornění: Na disku je málo místa" + +#: ../../../src/uibase.h:151 msgid "Transaction Details" msgstr "Detaily transakce" -#: ../../../src/uibase.h:199 +#: ../../../src/uibase.h:203 msgid "Options" msgstr "Možnosti" -#: ../../../src/uibase.h:228 +#: ../../../src/uibase.h:232 msgid "About Bitcoin" msgstr "O Bitcoinu" -#: ../../../src/uibase.h:337 +#: ../../../src/uibase.h:341 msgid "Your Bitcoin Addresses" msgstr "Tvá Bitcoinová adresa" +#~ msgid "Invalid bitcoin address" +#~ msgstr "Neplatná Bitcoinová adresa" diff --git a/locale/fr/LC_MESSAGES/bitcoin.mo b/locale/fr/LC_MESSAGES/bitcoin.mo Binary files differindex f4d669b4c0..f60e15bd62 100644 --- a/locale/fr/LC_MESSAGES/bitcoin.mo +++ b/locale/fr/LC_MESSAGES/bitcoin.mo diff --git a/locale/nl/LC_MESSAGES/bitcoin.mo b/locale/nl/LC_MESSAGES/bitcoin.mo Binary files differindex c5ae8489fb..836e91d41b 100644 --- a/locale/nl/LC_MESSAGES/bitcoin.mo +++ b/locale/nl/LC_MESSAGES/bitcoin.mo diff --git a/locale/pl/LC_MESSAGES/bitcoin.po b/locale/pl/LC_MESSAGES/bitcoin.po index 7c177b82de..17b5f10468 100644 --- a/locale/pl/LC_MESSAGES/bitcoin.po +++ b/locale/pl/LC_MESSAGES/bitcoin.po @@ -2,10 +2,10 @@ msgid "" msgstr "" "Project-Id-Version: Bitcoin\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2011-07-14 18:55+0100\n" +"POT-Creation-Date: 2011-06-28 20:11+0100\n" "PO-Revision-Date: \n" -"Last-Translator: Dawid Spiechowicz <spiechu@gmail.com>\n" -"Language-Team: Spiechu <spiechu@gmail.com>\n" +"Last-Translator: Krystian Maksymowicz <krystian.maksymowicz@gmail.com>\n" +"Language-Team: Spiechu <spiechu@gmail.com>, Krystian Maksymowicz <krystian.maksymowicz@gmail.com>\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -18,10 +18,10 @@ msgstr "" "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n" "X-Poedit-SearchPath-0: ../../..\n" -#: ../../../src/net.cpp:1615 +#: ../../../src/net.cpp:1590 #, c-format msgid "Unable to bind to port %d on this computer. Bitcoin is probably already running." -msgstr "Nie można powiązać z portem %d tego komputera. Prawdopodobnie program Bitcoin jest już uruchomiony." +msgstr "Powiązanie z portem %d nie powiodło się. Prawdopodobnie Bitcoin jest już uruchomiony." #: ../../../src/init.cpp:162 msgid "Bitcoin version" @@ -29,7 +29,7 @@ msgstr "Wersja Bitcoin" #: ../../../src/init.cpp:163 msgid "Usage:" -msgstr "Użycie:" +msgstr "Zastosowanie:" #: ../../../src/init.cpp:165 msgid "Send command to -server or bitcoind\n" @@ -37,7 +37,7 @@ msgstr "Wyślij polecenie do -server lub bitcoind\n" #: ../../../src/init.cpp:166 msgid "List commands\n" -msgstr "Wyświetl komendy\n" +msgstr "Lista komend\n" #: ../../../src/init.cpp:167 msgid "Get help for a command\n" @@ -53,7 +53,7 @@ msgstr "Określ plik konfiguracyjny (domyślnie: bitcoin.conf)\n" #: ../../../src/init.cpp:170 msgid "Specify pid file (default: bitcoind.pid)\n" -msgstr "Wybierz plik pid (domyślnie: bitcoind.pid)\n" +msgstr "Określ plik pid (domyślnie: bitcoind.pid)\n" #: ../../../src/init.cpp:171 msgid "Generate coins\n" @@ -69,20 +69,22 @@ msgstr "Uruchom zminimalizowany\n" #: ../../../src/init.cpp:174 msgid "Specify data directory\n" -msgstr "Wybierz katalog z danymi\n" +msgstr "Określ katalog danych\n" #: ../../../src/init.cpp:175 msgid "Specify connection timeout (in milliseconds)\n" -msgstr "Ustaw czas upływu połączenia (w milisekundach)\n" +msgstr "Ustaw limit czasu połączenia (w milisekundach)\n" #: ../../../src/init.cpp:176 msgid "Connect through socks4 proxy\n" -msgstr "Połącz przez socks4 proxy\n" +msgstr "Połącz przez proxy socks4\n" +# 2do #: ../../../src/init.cpp:177 msgid "Allow DNS lookups for addnode and connect\n" -msgstr "Umożliwiaj wyszukiwanie DNS dla dodania węzła i połączenia\n" +msgstr "Umożliwiaj wyszukiwanie DNS przy dodawaniu węzła i połączenia\n" +# 2do #: ../../../src/init.cpp:178 msgid "Add a node to connect to\n" msgstr "Dodaj węzeł do którego połączyć\n" @@ -188,37 +190,29 @@ msgstr "Błąd ładowania addr.dat \n" msgid "Error loading blkindex.dat \n" msgstr "Błąd ładowania blkindex.dat \n" -#: ../../../src/init.cpp:394 -msgid "Error loading wallet.dat: Wallet corrupted \n" -msgstr "Błąd ładowania wallet.dat: Portfel uszkodzony \n" - -#: ../../../src/init.cpp:396 -msgid "Error loading wallet.dat: Wallet requires newer version of Bitcoin \n" -msgstr "Błąd ładowania wallet.dat: Portfel wymaga nowszej wersji Bitcoin \n" - -#: ../../../src/init.cpp:398 +#: ../../../src/init.cpp:391 msgid "Error loading wallet.dat \n" msgstr "Błąd ładowania wallet.dat \n" -#: ../../../src/init.cpp:488 +#: ../../../src/init.cpp:481 msgid "Invalid -proxy address" msgstr "Niewłaściwy adres -proxy" -#: ../../../src/init.cpp:513 +#: ../../../src/init.cpp:504 msgid "Invalid amount for -paytxfee=<amount>" msgstr "Nieprawidłowa kwota w -paytxfee=<amount>" -#: ../../../src/init.cpp:517 +#: ../../../src/init.cpp:508 msgid "Warning: -paytxfee is set very high. This is the transaction fee you will pay if you send a transaction." msgstr "Ostrzeżenie: ustawienie -paytxfee jest bardzo wysokie. To jest prowizja transakcji, którą zapłacisz jeżeli wyślesz transakcję." -#: ../../../src/rpc.cpp:2100 -#: ../../../src/rpc.cpp:2102 +#: ../../../src/rpc.cpp:1822 +#: ../../../src/rpc.cpp:1824 #, c-format msgid "To use the %s option" msgstr "Użycie opcji %s" -#: ../../../src/rpc.cpp:2104 +#: ../../../src/rpc.cpp:1826 #, c-format msgid "" "Warning: %s, you must set rpcpassword=<password>\n" @@ -229,7 +223,7 @@ msgstr "" "w pliku konfiguracyjnym: %s\n" "Jeżeli plik nie istnieje, utwórz go z uprawnieniami tylko do odczytu dla właściciela.\n" -#: ../../../src/rpc.cpp:2277 +#: ../../../src/rpc.cpp:1994 #, c-format msgid "" "You must set rpcpassword=<password> in the configuration file:\n" @@ -240,454 +234,368 @@ msgstr "" "%s\n" "Jeżeli plik nie istnieje, utwórz go z uprawnieniami tylko do odczytu dla właściciela." -#: ../../../src/util.cpp:869 +#: ../../../src/util.cpp:874 msgid "Warning: Please check that your computer's date and time are correct. If your clock is wrong Bitcoin will not work properly." -msgstr "Ostrzeżenie: Sprawdź czy ustawienia daty i czasu komputera są prawidłowe. Jeżeli zegar jest źle ustawiony, Bitcoin nie będzie poprawnie działał." +msgstr "Ostrzeżenie: Sprawdź czy ustawienia daty i czasu komputera są prawidłowe. Jeżeli zegar jest źle ustawiony, Bitcoin nie będzie działał poprawnie." -#: ../../../src/util.cpp:903 +#: ../../../src/util.cpp:908 msgid "beta" msgstr "beta" #: ../../../src/ui.cpp:216 #, c-format msgid "This transaction is over the size limit. You can still send it for a fee of %s, which goes to the nodes that process your transaction and helps to support the network. Do you want to pay the fee?" -msgstr "Ta transakcja jest poza limitem wielkości. W dalszym ciągu możesz wysłać ją z prowizją %s, która dotrze do węzłów przetwarzających twoją transakcję i pomoże utrzymać sieć. Chcesz zapłacić prowizję?" - -#: ../../../src/ui.cpp:259 -#: ../../../src/ui.cpp:1246 -msgid "Enter the current passphrase to the wallet." -msgstr "Wpisz obecne hasło do portfela." - -#: ../../../src/ui.cpp:260 -#: ../../../src/ui.cpp:1182 -#: ../../../src/ui.cpp:1199 -#: ../../../src/ui.cpp:1247 -#: ../../../src/ui.cpp:1273 -#: ../../../src/ui.cpp:1293 -msgid "Passphrase" -msgstr "Hasło" - -#: ../../../src/ui.cpp:266 -msgid "Please supply the current wallet decryption passphrase." -msgstr "Proszę dostarczyć hasło do odszyfrowania portfela." - -#: ../../../src/ui.cpp:274 -#: ../../../src/ui.cpp:1258 -#: ../../../src/ui.cpp:1315 -msgid "The passphrase entered for the wallet decryption was incorrect." -msgstr "Wpisane hasło do odszyfrowania portfela jest nieprawidłowe." +msgstr "Ta transakcja przekracza limit wielkości. W dalszym ciągu możesz ją wysłać z prowizją %s, która dotrze do węzłów przetwarzających twoją transakcję i pomoże utrzymać całą sieć. Chcesz zapłacić prowizję?" -#: ../../../src/ui.cpp:351 +#: ../../../src/ui.cpp:316 msgid "Status" -msgstr "Status" +msgstr "Stan" -#: ../../../src/ui.cpp:352 +#: ../../../src/ui.cpp:317 msgid "Date" msgstr "Data" -#: ../../../src/ui.cpp:353 +#: ../../../src/ui.cpp:318 msgid "Description" msgstr "Opis" -#: ../../../src/ui.cpp:354 +#: ../../../src/ui.cpp:319 msgid "Debit" -msgstr "Obciążenie" +msgstr "Debet" -#: ../../../src/ui.cpp:355 +#: ../../../src/ui.cpp:320 msgid "Credit" -msgstr "Suma" +msgstr "Kredyt" -#: ../../../src/ui.cpp:566 +#: ../../../src/ui.cpp:526 #, c-format msgid "Open for %d blocks" msgstr "Otwórz na %d bloków" -#: ../../../src/ui.cpp:568 +#: ../../../src/ui.cpp:528 #, c-format msgid "Open until %s" msgstr "Otwarte dopóki %s" -#: ../../../src/ui.cpp:574 +#: ../../../src/ui.cpp:534 #, c-format msgid "%d/offline?" msgstr "%d/offline?" -#: ../../../src/ui.cpp:576 +#: ../../../src/ui.cpp:536 #, c-format msgid "%d/unconfirmed" -msgstr "%d/niepotwierdzono" +msgstr "%d/niepotwierdzona" -#: ../../../src/ui.cpp:578 +#: ../../../src/ui.cpp:538 #, c-format msgid "%d confirmations" msgstr "%d potwierdzeń" -#: ../../../src/ui.cpp:663 +#: ../../../src/ui.cpp:623 msgid "Generated" msgstr "Wygenerowano" -#: ../../../src/ui.cpp:671 +#: ../../../src/ui.cpp:631 #, c-format msgid "Generated (%s matures in %d more blocks)" msgstr "Wygenerowano (%s dojrzałych w %d więcej bloków)" -#: ../../../src/ui.cpp:675 +#: ../../../src/ui.cpp:635 msgid "Generated - Warning: This block was not received by any other nodes and will probably not be accepted!" msgstr "Wygenerowano - Ostrzeżenie: Ten blok nie został otrzymany przez żaden inny węzeł i prawdopodobnie nie zostanie zaakceptowany!" -#: ../../../src/ui.cpp:679 +#: ../../../src/ui.cpp:639 msgid "Generated (not accepted)" msgstr "Wygenerowano (nie zaakceptowano)" -#: ../../../src/ui.cpp:689 +#: ../../../src/ui.cpp:649 msgid "From: " msgstr "Od:" -#: ../../../src/ui.cpp:713 +#: ../../../src/ui.cpp:673 msgid "Received with: " msgstr "Otrzymano z:" -#: ../../../src/ui.cpp:759 +#: ../../../src/ui.cpp:719 msgid "Payment to yourself" msgstr "Płatność dla siebie samego" -#: ../../../src/ui.cpp:793 +#: ../../../src/ui.cpp:753 msgid "To: " msgstr "Do:" -#: ../../../src/ui.cpp:1108 +#: ../../../src/ui.cpp:1068 msgid " Generating" msgstr " Generowanie" -#: ../../../src/ui.cpp:1110 +#: ../../../src/ui.cpp:1070 msgid "(not connected)" msgstr "(nie połączony)" -#: ../../../src/ui.cpp:1113 +#: ../../../src/ui.cpp:1073 #, c-format msgid " %d connections %d blocks %d transactions" msgstr " %d połączeń %d bloków %d transakcji" -#: ../../../src/ui.cpp:1170 -msgid "Wallet already encrypted." -msgstr "Portfel już zaszyfrowany." - -#: ../../../src/ui.cpp:1181 -msgid "" -"Enter the new passphrase to the wallet.\n" -"Please use a passphrase of 10 or more random characters, or eight or more words." -msgstr "" -"Wpisz nowe hasło dla portfela.\n" -"Proszę użyć hasła składającego się z 10 lub więcej losowych znaków albo ośmiu lub więcej słów." - -#: ../../../src/ui.cpp:1188 -#: ../../../src/ui.cpp:1281 -msgid "Error: The supplied passphrase was too short." -msgstr "Błąd: Dostarczone hasło jest za krótkie." - -#: ../../../src/ui.cpp:1192 -msgid "" -"WARNING: If you encrypt your wallet and lose your passphrase, you will LOSE ALL OF YOUR BITCOINS!\n" -"Are you sure you wish to encrypt your wallet?" -msgstr "" -"OSTRZEŻENIE: Jeżeli zaszyfrujesz swój portfel i zgubisz hasło, STRACISZ WSZYSTKIE SWOJE BITCOINY!\n" -"Czy jesteś pewny, że chcesz zaszyfrować swój portfel?" - -#: ../../../src/ui.cpp:1198 -msgid "Please re-enter your new wallet passphrase." -msgstr "Proszę powtórzyć nowe hasło do portfela." - -#: ../../../src/ui.cpp:1207 -#: ../../../src/ui.cpp:1303 -msgid "Error: the supplied passphrases didn't match." -msgstr "Błąd: dostarczone hasła się nie zgadzają." - -#: ../../../src/ui.cpp:1217 -msgid "Wallet encryption failed." -msgstr "Szyfrowanie portfela nie powiodło się." - -#: ../../../src/ui.cpp:1224 -msgid "" -"Wallet Encrypted.\n" -"Remember that encrypting your wallet cannot fully protect your bitcoins from being stolen by malware infecting your computer." -msgstr "" -"Portfel zaszyfrowany.\n" -"Pamiętaj, że zaszyfrowanie portfela nie chroni w pełni twoich bitcoinów przed kradzieżą przeprowadzoną przez złośliwe oprogramowanie infekujące twój komputer." - -#: ../../../src/ui.cpp:1235 -msgid "Wallet is unencrypted, please encrypt it first." -msgstr "Portfel jest niezaszyfrowany, proszę najpierw zaszyfrować." - -#: ../../../src/ui.cpp:1272 -msgid "Enter the new passphrase for the wallet." -msgstr "Wprowadź nowe hasło dla portfela." - -#: ../../../src/ui.cpp:1292 -msgid "Re-enter the new passphrase for the wallet." -msgstr "Powtórnie wprowadź nowe hasło dla portfela." - -#: ../../../src/ui.cpp:1324 -msgid "Wallet Passphrase Changed." -msgstr "Hasło dla portfela zostało zmienione." - -#: ../../../src/ui.cpp:1381 -#: ../../../src/ui.cpp:2816 +#: ../../../src/ui.cpp:1178 +#: ../../../src/ui.cpp:2571 msgid "New Receiving Address" -msgstr "Nowy Adres Odbiorczy" +msgstr "Nowy adres odbiorczy" -#: ../../../src/ui.cpp:1382 -#: ../../../src/ui.cpp:2817 +#: ../../../src/ui.cpp:1179 +#: ../../../src/ui.cpp:2572 msgid "" "You should use a new address for each payment you receive.\n" "\n" "Label" msgstr "" -"Powinieneś użyć nowego adresu dla każdej płatności, którą otrzymasz.\n" +"Powinieneś używać nowych adresów dla każdej otrzymywanej płatności.\n" "\n" "Etykieta" -#: ../../../src/ui.cpp:1466 +#: ../../../src/ui.cpp:1251 msgid "<b>Status:</b> " msgstr "<b>Status:</b>" -#: ../../../src/ui.cpp:1471 +#: ../../../src/ui.cpp:1256 msgid ", has not been successfully broadcast yet" msgstr ", nie został jeszcze prawidłowo rozgłoszony" -#: ../../../src/ui.cpp:1473 +#: ../../../src/ui.cpp:1258 #, c-format msgid ", broadcast through %d node" msgstr ", rozgłasza przez %d węzeł" -#: ../../../src/ui.cpp:1475 +#: ../../../src/ui.cpp:1260 #, c-format msgid ", broadcast through %d nodes" msgstr ", rozgłasza przez %d węzłów" -#: ../../../src/ui.cpp:1479 +#: ../../../src/ui.cpp:1264 msgid "<b>Date:</b> " msgstr "<b>Data:</b>" -#: ../../../src/ui.cpp:1487 +#: ../../../src/ui.cpp:1272 msgid "<b>Source:</b> Generated<br>" msgstr "<b>Źródło:</b> Wygenerowano<br>" -#: ../../../src/ui.cpp:1493 -#: ../../../src/ui.cpp:1511 +#: ../../../src/ui.cpp:1278 +#: ../../../src/ui.cpp:1296 msgid "<b>From:</b> " msgstr "<b>Od:</b>" -#: ../../../src/ui.cpp:1511 +#: ../../../src/ui.cpp:1296 msgid "unknown" msgstr "nieznany" -#: ../../../src/ui.cpp:1512 -#: ../../../src/ui.cpp:1536 -#: ../../../src/ui.cpp:1595 +#: ../../../src/ui.cpp:1297 +#: ../../../src/ui.cpp:1321 +#: ../../../src/ui.cpp:1380 msgid "<b>To:</b> " msgstr "<b>Do:</b>" -#: ../../../src/ui.cpp:1515 +#: ../../../src/ui.cpp:1300 msgid " (yours, label: " msgstr " (twoja, etykieta: " -#: ../../../src/ui.cpp:1517 +#: ../../../src/ui.cpp:1302 msgid " (yours)" msgstr " (twoja)" -#: ../../../src/ui.cpp:1554 -#: ../../../src/ui.cpp:1566 -#: ../../../src/ui.cpp:1612 -#: ../../../src/ui.cpp:1629 +#: ../../../src/ui.cpp:1339 +#: ../../../src/ui.cpp:1351 +#: ../../../src/ui.cpp:1397 +#: ../../../src/ui.cpp:1414 msgid "<b>Credit:</b> " -msgstr "<b>Suma:</b>" +msgstr "<b>Kredyt:</b>" -#: ../../../src/ui.cpp:1556 +#: ../../../src/ui.cpp:1341 #, c-format msgid "(%s matures in %d more blocks)" msgstr "(%s dojrzałych w %d więcej bloków)" -#: ../../../src/ui.cpp:1558 +#: ../../../src/ui.cpp:1343 msgid "(not accepted)" msgstr "(nie zaakceptowano)" -#: ../../../src/ui.cpp:1603 -#: ../../../src/ui.cpp:1611 -#: ../../../src/ui.cpp:1626 +#: ../../../src/ui.cpp:1388 +#: ../../../src/ui.cpp:1396 +#: ../../../src/ui.cpp:1411 msgid "<b>Debit:</b> " -msgstr "<b>Obciążenie:</b>" +msgstr "<b>Debet:</b>" -#: ../../../src/ui.cpp:1617 +#: ../../../src/ui.cpp:1402 msgid "<b>Transaction fee:</b> " msgstr "<b>Prowizja transakcji:</b>" -#: ../../../src/ui.cpp:1633 +#: ../../../src/ui.cpp:1418 msgid "<b>Net amount:</b> " msgstr "<b>Kwota netto:</b>" -#: ../../../src/ui.cpp:1640 +#: ../../../src/ui.cpp:1425 msgid "Message:" msgstr "Wiadomość:" -#: ../../../src/ui.cpp:1642 +#: ../../../src/ui.cpp:1427 msgid "Comment:" msgstr "Komentarz:" -#: ../../../src/ui.cpp:1645 +#: ../../../src/ui.cpp:1430 msgid "Generated coins must wait 120 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, it will change to \"not accepted\" and not be spendable. This may occasionally happen if another node generates a block within a few seconds of yours." -msgstr "Wygenerowane monety muszą poczekać 120 bloków zanim mogą zostać wydane. Gdy wygenerowałeś ten blok, został rozgłoszony do sieci z przeznaczeniem do dodania do łańcucha bloków. Jeżeli nie uda się dodać bloku do łańcucha, zostanie oznaczony jako \"nie zaakceptowany\" i nie będzie mógł zostać wydany. Sporadycznie dzieje się tak jeżeli inny węzeł wygeneruje blok nie dalej niż kilka sekund od ciebie." +msgstr "Wygenerowane monety muszą poczekać 120 bloków zanim będą mogły być wydane. Wygenerowany blok został został rozgłoszony w sieci z przeznaczeniem dodawania nowych bloków do łańcucha. Jeżeli nie uda się go dodać do łańcucha, zostanie oznaczony jako \"nie zaakceptowany\" i nie będzie mógł być wydany. Sporadycznie dzieje się tak jeżeli inny węzeł wygeneruje blok nie dalej niż kilka sekund od ciebie." -#: ../../../src/ui.cpp:1825 +#: ../../../src/ui.cpp:1610 msgid "Cannot write autostart/bitcoin.desktop file" msgstr "Nie mogę zapisać pliku autostart/bitcoin.desktop" -#: ../../../src/ui.cpp:1861 +#: ../../../src/ui.cpp:1646 msgid "Main" msgstr "Główne" -#: ../../../src/ui.cpp:1871 +#: ../../../src/ui.cpp:1656 msgid "&Start Bitcoin on window system startup" msgstr "&Uruchom Bitcoin przy starcie systemu" -#: ../../../src/ui.cpp:1878 +#: ../../../src/ui.cpp:1663 msgid "&Minimize on close" msgstr "&Minimalizuj przy zamknięciu" -#: ../../../src/ui.cpp:2020 +#: ../../../src/ui.cpp:1805 #, c-format msgid "version %s" msgstr "wersja %s" -#: ../../../src/ui.cpp:2143 +#: ../../../src/ui.cpp:1928 msgid "Error in amount " msgstr "Nieprawidłowa kwota" -#: ../../../src/ui.cpp:2143 -#: ../../../src/ui.cpp:2148 -#: ../../../src/ui.cpp:2153 -#: ../../../src/ui.cpp:2202 -#: ../../../src/uibase.cpp:61 +#: ../../../src/ui.cpp:1928 +#: ../../../src/ui.cpp:1933 +#: ../../../src/ui.cpp:1938 +#: ../../../src/ui.cpp:1973 +#: ../../../src/uibase.cpp:55 msgid "Send Coins" msgstr "Wyślij Monety" -#: ../../../src/ui.cpp:2148 +#: ../../../src/ui.cpp:1933 msgid "Amount exceeds your balance " msgstr "Kwota przekracza twój stan konta" -#: ../../../src/ui.cpp:2153 +#: ../../../src/ui.cpp:1938 msgid "Total exceeds your balance when the " msgstr "Przekroczenie twojego stanu konta gdy" -#: ../../../src/ui.cpp:2153 +#: ../../../src/ui.cpp:1938 msgid " transaction fee is included " msgstr " prowizja jest wliczona" -#: ../../../src/ui.cpp:2176 +#: ../../../src/ui.cpp:1956 msgid "Payment sent " msgstr "Wysłano płatność" -#: ../../../src/ui.cpp:2176 -#: ../../../src/ui.cpp:2185 -#: ../../../src/ui.cpp:2336 -#: ../../../src/ui.cpp:2500 -#: ../../../src/wallet.cpp:1097 +#: ../../../src/ui.cpp:1956 +#: ../../../src/ui.cpp:1961 +#: ../../../src/ui.cpp:2107 +#: ../../../src/ui.cpp:2260 +#: ../../../src/wallet.cpp:924 msgid "Sending..." msgstr "Wysyłanie..." -#: ../../../src/ui.cpp:2202 +#: ../../../src/ui.cpp:1973 msgid "Invalid address " msgstr "Nieprawidłowy adres" -#: ../../../src/ui.cpp:2257 +#: ../../../src/ui.cpp:2028 #, c-format msgid "Sending %s to %s" msgstr "Wysyłanie %s do %s" -#: ../../../src/ui.cpp:2330 -#: ../../../src/ui.cpp:2363 +#: ../../../src/ui.cpp:2101 +#: ../../../src/ui.cpp:2134 msgid "CANCELLED" msgstr "ANULOWANO" -#: ../../../src/ui.cpp:2334 +#: ../../../src/ui.cpp:2105 msgid "Cancelled" msgstr "Anulowano" -#: ../../../src/ui.cpp:2336 +#: ../../../src/ui.cpp:2107 msgid "Transfer cancelled " -msgstr "Transfer anulowano" +msgstr "Transfer anulowany" -#: ../../../src/ui.cpp:2389 +#: ../../../src/ui.cpp:2160 msgid "Error: " msgstr "Błąd:" -#: ../../../src/ui.cpp:2403 -#: ../../../src/ui.cpp:2474 -#: ../../../src/wallet.cpp:1116 +#: ../../../src/ui.cpp:2174 +#: ../../../src/ui.cpp:2245 +#: ../../../src/wallet.cpp:943 msgid "Insufficient funds" msgstr "Niewystarczające fundusze" -#: ../../../src/ui.cpp:2408 +#: ../../../src/ui.cpp:2179 msgid "Connecting..." msgstr "Łączenie..." -#: ../../../src/ui.cpp:2413 +#: ../../../src/ui.cpp:2184 msgid "Unable to connect" msgstr "Nie można połączyć" -#: ../../../src/ui.cpp:2418 +#: ../../../src/ui.cpp:2189 msgid "Requesting public key..." msgstr "Żądanie klucza publicznego..." -#: ../../../src/ui.cpp:2430 +#: ../../../src/ui.cpp:2201 msgid "Received public key..." msgstr "Otrzymano klucz publiczny..." -#: ../../../src/ui.cpp:2444 +#: ../../../src/ui.cpp:2215 msgid "Recipient is not accepting transactions sent by IP address" msgstr "Adresat nie akceptuje transakcji wysyłanych przez adres IP" -#: ../../../src/ui.cpp:2446 +#: ../../../src/ui.cpp:2217 msgid "Transfer was not accepted" msgstr "Transfer nie został zaakceptowany" -#: ../../../src/ui.cpp:2455 +#: ../../../src/ui.cpp:2226 msgid "Invalid response received" msgstr "Otrzymano niepoprawną odpowiedź" -#: ../../../src/ui.cpp:2470 +#: ../../../src/ui.cpp:2241 msgid "Creating transaction..." msgstr "Tworzenie transakcji..." -#: ../../../src/ui.cpp:2489 +#: ../../../src/ui.cpp:2253 #, c-format msgid "This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds" -msgstr "Ta transakcja wymaga prowizji co najmniej %s z uwagi na kwotę, złożoność lub użycie niedawno otrzymanych funduszy" +msgstr "Ta transakcja wymaga prowizji co najmniej %s z uwagi na jej kwotę, złożoność lub wykorzystanie niedawno otrzymanych funduszy" -#: ../../../src/ui.cpp:2491 +#: ../../../src/ui.cpp:2255 msgid "Transaction creation failed" msgstr "Błąd tworzenia transakcji " -#: ../../../src/ui.cpp:2502 +#: ../../../src/ui.cpp:2262 msgid "Transaction aborted" -msgstr "Transakcję przerwano" +msgstr "Przerwano transakcję" -#: ../../../src/ui.cpp:2510 +#: ../../../src/ui.cpp:2270 msgid "Lost connection, transaction cancelled" msgstr "Utracono połączenie, transakcja anulowana" -#: ../../../src/ui.cpp:2526 +#: ../../../src/ui.cpp:2286 msgid "Sending payment..." msgstr "Wysyłanie płatności..." -#: ../../../src/ui.cpp:2532 +#: ../../../src/ui.cpp:2292 msgid "The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here." msgstr "Transakcja została odrzucona. Może się tak zdarzyć jeżeli część monet w twoim portfelu zostało wydanych, np. gdy użyto kopii pliku wallet.dat i monety zostały wydane w kopii, a tutaj nie zostały oznaczone jako wydane." -#: ../../../src/ui.cpp:2541 +#: ../../../src/ui.cpp:2301 msgid "Waiting for confirmation..." msgstr "Oczekiwanie na potwierdzenie..." -#: ../../../src/ui.cpp:2559 +#: ../../../src/ui.cpp:2319 msgid "" "The payment was sent, but the recipient was unable to verify it.\n" "The transaction is recorded and will credit to the recipient,\n" @@ -697,86 +605,86 @@ msgstr "" "Transakcja została zarejestrowana i zostanie przypisana do odbiorcy,\n" "ale informacja w komentarzu będzie pusta." -#: ../../../src/ui.cpp:2568 +#: ../../../src/ui.cpp:2328 msgid "Payment was sent, but an invalid response was received" msgstr "Płatność została wysłana, ale otrzymano nieprawidłową odpowiedź" -#: ../../../src/ui.cpp:2574 +#: ../../../src/ui.cpp:2334 msgid "Payment completed" msgstr "Płatność zakończona" -#: ../../../src/ui.cpp:2616 -#: ../../../src/ui.cpp:2764 -#: ../../../src/ui.cpp:2804 +#: ../../../src/ui.cpp:2376 +#: ../../../src/ui.cpp:2522 +#: ../../../src/ui.cpp:2559 msgid "Name" msgstr "Nazwa" -#: ../../../src/ui.cpp:2617 -#: ../../../src/ui.cpp:2764 -#: ../../../src/ui.cpp:2804 +#: ../../../src/ui.cpp:2377 +#: ../../../src/ui.cpp:2522 +#: ../../../src/ui.cpp:2559 msgid "Address" msgstr "Adres" -#: ../../../src/ui.cpp:2619 -#: ../../../src/ui.cpp:2776 +#: ../../../src/ui.cpp:2379 +#: ../../../src/ui.cpp:2534 msgid "Label" msgstr "Etykieta" -#: ../../../src/ui.cpp:2620 -#: ../../../src/uibase.cpp:847 +#: ../../../src/ui.cpp:2380 +#: ../../../src/uibase.cpp:837 msgid "Bitcoin Address" msgstr "Adres Bitcoin" -#: ../../../src/ui.cpp:2746 +#: ../../../src/ui.cpp:2504 msgid "This is one of your own addresses for receiving payments and cannot be entered in the address book. " -msgstr "To jest jeden z twoich adresów na otrzymywane płatności i nie może zostać wpisany do księgi adresowej." +msgstr "To jest jeden z twoich adresów na otrzymywane płatności i nie może zostać wpisany do książki adresowej." -#: ../../../src/ui.cpp:2764 -#: ../../../src/ui.cpp:2770 +#: ../../../src/ui.cpp:2522 +#: ../../../src/ui.cpp:2528 msgid "Edit Address" -msgstr "Edytuj Adres" +msgstr "Edytuj adres" -#: ../../../src/ui.cpp:2776 +#: ../../../src/ui.cpp:2534 msgid "Edit Address Label" -msgstr "Edytuj Etykietę Adresu" +msgstr "Edytuj etykietę adresu" -#: ../../../src/ui.cpp:2804 -#: ../../../src/ui.cpp:2810 +#: ../../../src/ui.cpp:2559 +#: ../../../src/ui.cpp:2565 msgid "Add Address" -msgstr "Dodaj Adres" +msgstr "Dodaj adres" -#: ../../../src/ui.cpp:2898 +#: ../../../src/ui.cpp:2642 msgid "Bitcoin" msgstr "Bitcoin" -#: ../../../src/ui.cpp:2900 +#: ../../../src/ui.cpp:2644 msgid "Bitcoin - Generating" msgstr "Bitcoin - Generowanie" -#: ../../../src/ui.cpp:2902 +#: ../../../src/ui.cpp:2646 msgid "Bitcoin - (not connected)" msgstr "Bitcoin - (nie połączony)" -#: ../../../src/ui.cpp:2981 +#: ../../../src/ui.cpp:2725 msgid "&Open Bitcoin" msgstr "&Otwórz Bitcoin" -#: ../../../src/ui.cpp:2982 +#: ../../../src/ui.cpp:2726 msgid "&Send Bitcoins" msgstr "&Wyślij Bitcoiny" -#: ../../../src/ui.cpp:2983 +#: ../../../src/ui.cpp:2727 msgid "O&ptions..." msgstr "O&pcje..." -#: ../../../src/ui.cpp:2986 +#: ../../../src/ui.cpp:2730 #: ../../../src/uibase.cpp:25 msgid "E&xit" msgstr "W&yjście" -#: ../../../src/ui.cpp:3212 +#: ../../../src/ui.cpp:2956 msgid "Program has crashed and will terminate. " -msgstr "Program uległ awarii i zostanie przerwany." +msgstr "Program uległ awarii i zostanie zamknięty." #: ../../../src/main.cpp:1430 msgid "Warning: Disk space is low " @@ -788,162 +696,154 @@ msgstr "&Plik" #: ../../../src/uibase.cpp:32 msgid "&Your Receiving Addresses..." -msgstr "&Twój Adres Odbiorczy..." +msgstr "&Twój adres odbiorczy..." -#: ../../../src/uibase.cpp:35 -msgid "&Encrypt Wallet..." -msgstr "&Zaszyfruj portfel..." - -#: ../../../src/uibase.cpp:38 -msgid "&Change Wallet Encryption Passphrase..." -msgstr "&Zmień hasło szyfrowania portfela..." - -#: ../../../src/uibase.cpp:42 +#: ../../../src/uibase.cpp:36 msgid "&Options..." msgstr "&Opcje..." -#: ../../../src/uibase.cpp:45 +#: ../../../src/uibase.cpp:39 msgid "&Settings" msgstr "&Ustawienia" -#: ../../../src/uibase.cpp:49 +#: ../../../src/uibase.cpp:43 msgid "&About..." msgstr "&O programie..." -#: ../../../src/uibase.cpp:52 +#: ../../../src/uibase.cpp:46 msgid "&Help" msgstr "&Pomoc" -#: ../../../src/uibase.cpp:62 +#: ../../../src/uibase.cpp:56 msgid "Address Book" -msgstr "Księga Adresowa" +msgstr "Książka adresowa" -#: ../../../src/uibase.cpp:75 +#: ../../../src/uibase.cpp:69 msgid "Your Bitcoin Address:" -msgstr "Twój Adres Bitcoin:" +msgstr "Twój adres Bitcoin:" -#: ../../../src/uibase.cpp:82 +#: ../../../src/uibase.cpp:76 msgid " &New... " msgstr " &Nowy..." -#: ../../../src/uibase.cpp:85 -#: ../../../src/uibase.cpp:790 -#: ../../../src/uibase.cpp:893 +#: ../../../src/uibase.cpp:79 +#: ../../../src/uibase.cpp:780 +#: ../../../src/uibase.cpp:883 msgid " &Copy to Clipboard " msgstr " &Kopiuj do schowka " -#: ../../../src/uibase.cpp:99 +#: ../../../src/uibase.cpp:93 msgid "Balance:" msgstr "Saldo:" -#: ../../../src/uibase.cpp:115 +#: ../../../src/uibase.cpp:109 msgid " All" msgstr " Wszystko" -#: ../../../src/uibase.cpp:115 +#: ../../../src/uibase.cpp:109 msgid " Sent" -msgstr "Wysłano" +msgstr " Wysłano" -#: ../../../src/uibase.cpp:115 +#: ../../../src/uibase.cpp:109 msgid " Received" -msgstr "Otrzymano" +msgstr " Otrzymano" -#: ../../../src/uibase.cpp:115 +#: ../../../src/uibase.cpp:109 msgid " In Progress" -msgstr "W Trakcie" +msgstr "W realizacji" -#: ../../../src/uibase.cpp:136 +#: ../../../src/uibase.cpp:130 msgid "All Transactions" -msgstr "Wszystkie Transakcje" +msgstr "Wszystkie transakcje" -#: ../../../src/uibase.cpp:147 +#: ../../../src/uibase.cpp:141 msgid "Sent/Received" -msgstr "Wysłano/Otrzymano" +msgstr "Wysłane/Otrzymane" -#: ../../../src/uibase.cpp:158 +#: ../../../src/uibase.cpp:152 msgid "Sent" -msgstr "Wysłano" +msgstr "Wysłane" -#: ../../../src/uibase.cpp:169 +#: ../../../src/uibase.cpp:163 msgid "Received" -msgstr "Otrzymano" - -#: ../../../src/uibase.cpp:312 -#: ../../../src/uibase.cpp:453 -#: ../../../src/uibase.cpp:552 -#: ../../../src/uibase.cpp:732 -#: ../../../src/uibase.cpp:793 -#: ../../../src/uibase.cpp:902 -#: ../../../src/uibase.cpp:991 +msgstr "Otrzymane" + +#: ../../../src/uibase.cpp:302 +#: ../../../src/uibase.cpp:443 +#: ../../../src/uibase.cpp:542 +#: ../../../src/uibase.cpp:722 +#: ../../../src/uibase.cpp:783 +#: ../../../src/uibase.cpp:892 +#: ../../../src/uibase.cpp:981 msgid "OK" msgstr "OK" -#: ../../../src/uibase.cpp:355 +#: ../../../src/uibase.cpp:345 msgid "&Start Bitcoin on system startup" msgstr "&Uruchom Bitcoin wraz ze startem systemu" -#: ../../../src/uibase.cpp:358 +#: ../../../src/uibase.cpp:348 msgid "&Minimize to the tray instead of the taskbar" -msgstr "&Zminimalizuj do traya zamiast do paska zadań" +msgstr "&Minimalizuj do obszaru powiadomień zamiast paska zadań" -#: ../../../src/uibase.cpp:361 +#: ../../../src/uibase.cpp:351 msgid "Map port using &UPnP" msgstr "Mapuj port używając &UPnP" -#: ../../../src/uibase.cpp:364 +#: ../../../src/uibase.cpp:354 msgid "M&inimize to the tray on close" -msgstr "Zm&inimalizuj do traya przy zamknięciu" +msgstr "M&inimalizuj do obszaru powiadomień przy zamknięciu" -#: ../../../src/uibase.cpp:370 +#: ../../../src/uibase.cpp:360 msgid "&Connect through socks4 proxy: " -msgstr "&Połącz przez socks4 proxy:" +msgstr "&Połącz przez proxy socks4:" -#: ../../../src/uibase.cpp:381 +#: ../../../src/uibase.cpp:371 msgid "Proxy &IP:" msgstr "Proxy &IP:" -#: ../../../src/uibase.cpp:389 +#: ../../../src/uibase.cpp:379 msgid " &Port:" msgstr " &Port:" -#: ../../../src/uibase.cpp:402 +#: ../../../src/uibase.cpp:392 msgid "Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended." -msgstr "Opcjonalna prowizja określona dla KB transakcji, która zapewni, że twoje transakcje będą szybko przetworzone. Większość transakcji to 1KB. Rekomendowana prowizja to 0.01." +msgstr "Opcjonalna prowizja określona na każdy KB transakcji, zapewniająca szybkie przetworzenie. Większość transakcji to 1KB. Rekomendowana prowizja to 0.01." -#: ../../../src/uibase.cpp:409 +#: ../../../src/uibase.cpp:399 msgid "Pay transaction fee:" -msgstr "Płać prowizję transakcji:" +msgstr "Płać prowizję od transakcji:" -#: ../../../src/uibase.cpp:430 +#: ../../../src/uibase.cpp:420 msgid "// [don't translate] Test panel 2 for future expansion" msgstr "" -#: ../../../src/uibase.cpp:434 +#: ../../../src/uibase.cpp:424 msgid "// [don't translate] Let's not start multiple pages until the first page is filled up" msgstr "" -#: ../../../src/uibase.cpp:456 -#: ../../../src/uibase.cpp:678 -#: ../../../src/uibase.cpp:737 -#: ../../../src/uibase.cpp:796 -#: ../../../src/uibase.cpp:905 -#: ../../../src/uibase.cpp:994 +#: ../../../src/uibase.cpp:446 +#: ../../../src/uibase.cpp:668 +#: ../../../src/uibase.cpp:727 +#: ../../../src/uibase.cpp:786 +#: ../../../src/uibase.cpp:895 +#: ../../../src/uibase.cpp:984 msgid "Cancel" msgstr "Anuluj" -#: ../../../src/uibase.cpp:459 +#: ../../../src/uibase.cpp:449 msgid "&Apply" msgstr "&Zastosuj" -#: ../../../src/uibase.cpp:518 +#: ../../../src/uibase.cpp:508 msgid "Bitcoin " -msgstr "Bitcoin" +msgstr "Bitcoin " -#: ../../../src/uibase.cpp:524 +#: ../../../src/uibase.cpp:514 msgid "version" msgstr "wersja" -#: ../../../src/uibase.cpp:535 +#: ../../../src/uibase.cpp:525 msgid "" "Copyright (c) 2009-2011 Bitcoin Developers\n" "\n" @@ -967,39 +867,39 @@ msgstr "" "OpenSSL Toolkit (http://www.openssl.org/) i oprogramowanie kryptograficzne napisane przez \n" "Erica Younga (eay@cryptsoft.com) oraz oprogramowanie UPnP napisane przez Thomasa Bernarda." -#: ../../../src/uibase.cpp:591 +#: ../../../src/uibase.cpp:581 msgid "Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)" msgstr "Wprowadź adres Bitcoin (np. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)" -#: ../../../src/uibase.cpp:605 +#: ../../../src/uibase.cpp:595 msgid "Pay &To:" -msgstr "Wpłać &Dla:" +msgstr "Wpłać &dla:" -#: ../../../src/uibase.cpp:620 +#: ../../../src/uibase.cpp:610 msgid "&Paste" msgstr "&Wklej" -#: ../../../src/uibase.cpp:623 +#: ../../../src/uibase.cpp:613 msgid " Address &Book..." -msgstr " Księga &Adresowa..." +msgstr " Książka &adresowa..." -#: ../../../src/uibase.cpp:630 +#: ../../../src/uibase.cpp:620 msgid "&Amount:" -msgstr "&Kwota:" +msgstr "&Saldo:" -#: ../../../src/uibase.cpp:640 +#: ../../../src/uibase.cpp:630 msgid "T&ransfer:" msgstr "T&ransfer:" -#: ../../../src/uibase.cpp:646 +#: ../../../src/uibase.cpp:636 msgid " Standard" msgstr " Standard" -#: ../../../src/uibase.cpp:673 +#: ../../../src/uibase.cpp:663 msgid "&Send" msgstr "&Wyślij" -#: ../../../src/uibase.cpp:721 +#: ../../../src/uibase.cpp:711 msgid "" "\n" "\n" @@ -1009,74 +909,70 @@ msgstr "" "\n" "Łączenie..." -#: ../../../src/uibase.cpp:771 +#: ../../../src/uibase.cpp:761 msgid "These are your Bitcoin addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you. The highlighted address is displayed in the main window." -msgstr "To są twoje adresy Bitcoin dla otrzymywania płatności. Możesz chcieć podać różne dla każdego płacącego aby kontrolować kto ci płaci. Wyróżniony adres będzie wyświetlany w oknie głównym." +msgstr "To są twoje adresy Bitcoin dla otrzymywania płatności. Możesz chcieć podawać inny dla każdego płacącego aby kontrolować kto ci płaci. Wyróżniony adres będzie wyświetlany w oknie głównym." -#: ../../../src/uibase.cpp:784 -#: ../../../src/uibase.cpp:896 +#: ../../../src/uibase.cpp:774 +#: ../../../src/uibase.cpp:886 msgid "&Edit..." msgstr "&Edytuj..." -#: ../../../src/uibase.cpp:787 -#: ../../../src/uibase.cpp:899 +#: ../../../src/uibase.cpp:777 +#: ../../../src/uibase.cpp:889 msgid " &New Address... " -msgstr " &Nowy Adres..." +msgstr " &Nowy adres..." -#: ../../../src/uibase.cpp:859 +#: ../../../src/uibase.cpp:849 msgid "Sending" msgstr "Wysyłanie" -#: ../../../src/uibase.cpp:867 +#: ../../../src/uibase.cpp:857 msgid "These are your Bitcoin addresses for receiving payments. You can give a different one to each sender to keep track of who is paying you. The highlighted address will be displayed in the main window." msgstr "To są twoje adresy Bitcoin dla otrzymywania płatności. Możesz podać różne dla każdego płacącego aby kontrolować kto ci płaci. Wyróżniony adres będzie wyświetlany w oknie głównym." -#: ../../../src/uibase.cpp:880 +#: ../../../src/uibase.cpp:870 msgid "Receiving" msgstr "Otrzymywanie" -#: ../../../src/uibase.cpp:890 +#: ../../../src/uibase.cpp:880 msgid "&Delete" msgstr "&Usuń" -#: ../../../src/wallet.cpp:1081 -msgid "Error: Wallet locked, unable to create transaction " -msgstr "Błąd: Portfel zablokowany, nie można utworzyć transakcji" - -#: ../../../src/wallet.cpp:1089 +#: ../../../src/wallet.cpp:917 #, c-format msgid "Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds " msgstr "Błąd: Ta transakcja wymaga prowizji co najmniej %s z uwagi na kwotę, złożoność lub użycie niedawno otrzymanych funduszy" -#: ../../../src/wallet.cpp:1091 +#: ../../../src/wallet.cpp:919 msgid "Error: Transaction creation failed " msgstr "Błąd: Nie udało się utworzyć transakcji" -#: ../../../src/wallet.cpp:1101 +#: ../../../src/wallet.cpp:928 msgid "Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here." msgstr "Błąd: Transakcja została odrzucona. Może się tak zdarzyć jeżeli część monet w twoim portfelu zostało wydanych, np. gdy użyto kopii pliku wallet.dat i monety zostały wydane w kopii, a tutaj nie zostały oznaczone jako wydane." -#: ../../../src/wallet.cpp:1114 +#: ../../../src/wallet.cpp:941 msgid "Invalid amount" msgstr "Niewłaściwa kwota" -#: ../../../src/wallet.cpp:1121 +#: ../../../src/wallet.cpp:948 msgid "Invalid bitcoin address" msgstr "Niewłaściwy adres bitcoin" -#: ../../../src/uibase.h:151 +#: ../../../src/uibase.h:147 msgid "Transaction Details" -msgstr "Szczegóły Transakcji" +msgstr "Szczegóły transakcji" -#: ../../../src/uibase.h:203 +#: ../../../src/uibase.h:199 msgid "Options" msgstr "Opcje" -#: ../../../src/uibase.h:232 +#: ../../../src/uibase.h:228 msgid "About Bitcoin" msgstr "O Bitcoin" -#: ../../../src/uibase.h:341 +#: ../../../src/uibase.h:337 msgid "Your Bitcoin Addresses" -msgstr "Twoje Adresy Bitcoin" +msgstr "Twoje adresy bitcoin" diff --git a/locale/pt/LC_MESSAGES/bitcoin.mo b/locale/pt/LC_MESSAGES/bitcoin.mo Binary files differindex 20e100f578..35a3fd7bc9 100644 --- a/locale/pt/LC_MESSAGES/bitcoin.mo +++ b/locale/pt/LC_MESSAGES/bitcoin.mo diff --git a/locale/readme.txt b/locale/readme.txt index 9fca3ce657..4019bf43c9 100644 --- a/locale/readme.txt +++ b/locale/readme.txt @@ -3,3 +3,5 @@ locale/<langcode>/LC_MESSAGES/bitcoin.mo and .po .po is the sourcefile
.mo is the compiled translation
+
+Note: pull requests should only include the .po file. Do not include .mo file
\ No newline at end of file diff --git a/locale/ro/LC_MESSAGES/bitcoin.mo b/locale/ro/LC_MESSAGES/bitcoin.mo Binary files differnew file mode 100644 index 0000000000..0eb994bcbe --- /dev/null +++ b/locale/ro/LC_MESSAGES/bitcoin.mo diff --git a/locale/ro/LC_MESSAGES/bitcoin.po b/locale/ro/LC_MESSAGES/bitcoin.po new file mode 100644 index 0000000000..e906e97566 --- /dev/null +++ b/locale/ro/LC_MESSAGES/bitcoin.po @@ -0,0 +1,1078 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2011-09-06 03:47+0100\n" +"PO-Revision-Date: 2011-09-06 06:36+0100\n" +"Last-Translator: Alex B <paraipanakos@gmail.com>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: \n" +"X-Poedit-KeywordsList: _;gettext;gettext_noop\n" +"X-Poedit-Basepath: .\n" +"X-Poedit-Language: Romanian\n" +"X-Poedit-SourceCharset: iso-8859-2\n" +"X-Poedit-SearchPath-0: ../../..\n" + +#: ../../../src/init.cpp:163 +msgid "Bitcoin version" +msgstr "versiune Bitcoin" + +#: ../../../src/init.cpp:164 +msgid "Usage:" +msgstr "Uz:" + +#: ../../../src/init.cpp:166 +msgid "Send command to -server or bitcoind\n" +msgstr "Trimite comanda la bitcoin lansat cu -server sau bitcoind\n" + +#: ../../../src/init.cpp:167 +msgid "List commands\n" +msgstr "Listeaza comenzi\n" + +#: ../../../src/init.cpp:168 +msgid "Get help for a command\n" +msgstr "Ajutor pentru o comanda\n" + +#: ../../../src/init.cpp:169 +msgid "Options:\n" +msgstr "Optiuni:\n" + +#: ../../../src/init.cpp:170 +msgid "Specify configuration file (default: bitcoin.conf)\n" +msgstr "Specifica fisier de configuratie (predeterminat: bitcoin.conf)\n" + +#: ../../../src/init.cpp:171 +msgid "Specify pid file (default: bitcoind.pid)\n" +msgstr "Specifica fisier pid (predeterminat: bitcoin.pid)\n" + +#: ../../../src/init.cpp:172 +msgid "Generate coins\n" +msgstr "Genereaza monede\n" + +#: ../../../src/init.cpp:173 +msgid "Don't generate coins\n" +msgstr "Nu genera monede\n" + +#: ../../../src/init.cpp:174 +msgid "Start minimized\n" +msgstr "Porneste minimizat\n" + +#: ../../../src/init.cpp:175 +msgid "Specify data directory\n" +msgstr "Specifica directorul de date\n" + +#: ../../../src/init.cpp:176 +msgid "Specify connection timeout (in milliseconds)\n" +msgstr "Specifica timpul maxim de conexiune (in milisecunde)\n" + +#: ../../../src/init.cpp:177 +msgid "Connect through socks4 proxy\n" +msgstr "Conecteaza prin proxy socks4\n" + +#: ../../../src/init.cpp:178 +msgid "Allow DNS lookups for addnode and connect\n" +msgstr "Permite cautare DNS pentru addnode si connect\n" + +#: ../../../src/init.cpp:179 +msgid "Add a node to connect to\n" +msgstr "Adauga un nod de conectare\n" + +#: ../../../src/init.cpp:180 +msgid "Connect only to the specified node\n" +msgstr "Conecteaza numai la nodul specificat\n" + +#: ../../../src/init.cpp:181 +msgid "Don't accept connections from outside\n" +msgstr "Nu accepta conexiuni din exterior\n" + +#: ../../../src/init.cpp:184 +msgid "Don't attempt to use UPnP to map the listening port\n" +msgstr "Nu utiliza UPnP pentru deschiderea portul de ascultare\n" + +#: ../../../src/init.cpp:186 +msgid "Attempt to use UPnP to map the listening port\n" +msgstr "Incearca sa utilizezi UPnP pentru deschiderea portului de ascultare.\n" + +#: ../../../src/init.cpp:189 +msgid "Fee per KB to add to transactions you send\n" +msgstr "Comision per KB ce se adauga la tranzactiile transmise\n" + +#: ../../../src/init.cpp:191 +msgid "Accept command line and JSON-RPC commands\n" +msgstr "Accepta comenzi de consola si JSON-RPC\n" + +#: ../../../src/init.cpp:194 +msgid "Run in the background as a daemon and accept commands\n" +msgstr "Executa ca daemon si accepta comenzi\n" + +#: ../../../src/init.cpp:196 +msgid "Use the test network\n" +msgstr "Utilizeaza reteaua de probe\n" + +#: ../../../src/init.cpp:197 +msgid "Username for JSON-RPC connections\n" +msgstr "Utilizator pentru conexiuni JSON-RPC\n" + +#: ../../../src/init.cpp:198 +msgid "Password for JSON-RPC connections\n" +msgstr "Parola pentru conexiuni JSON-RPC\n" + +#: ../../../src/init.cpp:199 +msgid "Listen for JSON-RPC connections on <port> (default: 8332)\n" +msgstr "Asculta conexiuni JSON-RPC pe portul <puerto> (predeterminat: 8332)\n" + +#: ../../../src/init.cpp:200 +msgid "Allow JSON-RPC connections from specified IP address\n" +msgstr "Permite conexiuni JSON-RPC de la adresa IP specifica\n" + +#: ../../../src/init.cpp:201 +msgid "Send commands to node running on <ip> (default: 127.0.0.1)\n" +msgstr "Trimite comanda la nod existent la <ip> (predeterminat: 127.0.0.1)\n" + +#: ../../../src/init.cpp:202 +msgid "Set key pool size to <n> (default: 100)\n" +msgstr "Ajusteaza numarul de chei in rezerva (predeterminat: 100)\n" + +#: ../../../src/init.cpp:203 +msgid "Rescan the block chain for missing wallet transactions\n" +msgstr "Rescaneza lantul de blocuri in cautare de tranzacti lipsa din portofel\n" + +#: ../../../src/init.cpp:207 +msgid "" +"\n" +"SSL options: (see the Bitcoin Wiki for SSL setup instructions)\n" +msgstr "" +"\n" +"Optiuni SSL: (vezi la Wiki Bitcoin pentru instructiuni detaliate)\n" + +#: ../../../src/init.cpp:208 +msgid "Use OpenSSL (https) for JSON-RPC connections\n" +msgstr "Utilizeaza OpenSSL (https) pentru conexiunile JSON-RPC\n" + +#: ../../../src/init.cpp:209 +msgid "Server certificate file (default: server.cert)\n" +msgstr "Arhiva certificat de server (predeterminat: server.cert)\n" + +#: ../../../src/init.cpp:210 +msgid "Server private key (default: server.pem)\n" +msgstr "Cheie privata de server (predeterminat: server.pem)\n" + +#: ../../../src/init.cpp:211 +msgid "Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)\n" +msgstr "Tipuri de cifrare acceptate (predeterminat: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)\n" + +#: ../../../src/init.cpp:215 +msgid "This help message\n" +msgstr "Acest mesaj de ajutor\n" + +#: ../../../src/init.cpp:353 +#, c-format +msgid "Cannot obtain a lock on data directory %s. Bitcoin is probably already running." +msgstr "Nu se poate obtine permis de lucru in directorul de date %s. E posibil ca Bitcoin sa fie deja in executie." + +#: ../../../src/init.cpp:379 +msgid "Error loading addr.dat \n" +msgstr "Eroare la incarcare addr.dat \n" + +#: ../../../src/init.cpp:385 +msgid "Error loading blkindex.dat \n" +msgstr "Eroare la incarcare blkindex.dat \n" + +#: ../../../src/init.cpp:396 +msgid "Error loading wallet.dat: Wallet corrupted \n" +msgstr "Eroare la incarcare wallet.dat \n" + +#: ../../../src/init.cpp:398 +msgid "Error loading wallet.dat: Wallet requires newer version of Bitcoin \n" +msgstr "Eroare la incarcare wallet.dat: E necesare o versiune mai noua de Bitcoin \n" + +#: ../../../src/init.cpp:400 +msgid "Error loading wallet.dat \n" +msgstr "Eroare la incarcare wallet.dat \n" + +#: ../../../src/init.cpp:489 +msgid "Invalid -proxy address" +msgstr "Adresa -proxy invalida" + +#: ../../../src/init.cpp:514 +msgid "Invalid amount for -paytxfee=<amount>" +msgstr "Cantitate invalida pentru -paytxfee=<amount>" + +#: ../../../src/init.cpp:518 +msgid "Warning: -paytxfee is set very high. This is the transaction fee you will pay if you send a transaction." +msgstr "Atentie: -paytxfee este prea mare. Acesta este comisionul platit la fiecare tranzactie." + +#: ../../../src/main.cpp:1398 +msgid "Warning: Disk space is low " +msgstr "Atentie: Spatiul pe hard disk este redus" + +#: ../../../src/net.cpp:1610 +#, c-format +msgid "Unable to bind to port %d on this computer. Bitcoin is probably already running." +msgstr "Nu e posibila ascultarea pe portul %d in acest calculator. Probabil clientul Bitcoin este deja in executie." + +#: ../../../src/rpc.cpp:2005 +#: ../../../src/rpc.cpp:2007 +#, c-format +msgid "To use the %s option" +msgstr "Pentru a utiliza optiunea %s" + +#: ../../../src/rpc.cpp:2009 +#, c-format +msgid "" +"Warning: %s, you must set rpcpassword=<password>\n" +"in the configuration file: %s\n" +"If the file does not exist, create it with owner-readable-only file permissions.\n" +msgstr "" +"Atentie: %s, trebuie sa specifici rpcpassword=<password>\n" +"in fisierul de configuratie: %s\n" +"Daca fisierul nu exista trebuie creat cu permisiuni de citire numai pentru autor.\n" + +#: ../../../src/rpc.cpp:2185 +#, c-format +msgid "" +"You must set rpcpassword=<password> in the configuration file:\n" +"%s\n" +"If the file does not exist, create it with owner-readable-only file permissions." +msgstr "" +"Trebuie sa specifici rpcpassword=<password> in fisierul de configuratie:\n" +"%s\n" +"Daca fisierul nu exista trebuie creat cu permisiuni de citire numai pentru autor." + +#: ../../../src/ui.cpp:217 +#, c-format +msgid "This transaction is over the size limit. You can still send it for a fee of %s, which goes to the nodes that process your transaction and helps to support the network. Do you want to pay the fee?" +msgstr "Aceasta tranzactie trece peste limita de dimensiune. O poti trimite in continuare pentru %s, care taxa se imparte intre nodurile ce receptioneaza tranzactia si ajuta la mentinerea retelei. Continui tranzactia?" + +#: ../../../src/ui.cpp:261 +#: ../../../src/ui.cpp:1247 +msgid "Enter the current passphrase to the wallet." +msgstr "Introduce parola actuala de portofel" + +#: ../../../src/ui.cpp:262 +#: ../../../src/ui.cpp:1183 +#: ../../../src/ui.cpp:1200 +#: ../../../src/ui.cpp:1248 +#: ../../../src/ui.cpp:1272 +#: ../../../src/ui.cpp:1292 +msgid "Passphrase" +msgstr "Parola" + +#: ../../../src/ui.cpp:268 +msgid "Please supply the current wallet decryption passphrase." +msgstr "Introduce parola actuala para decriptarea portofelului." + +#: ../../../src/ui.cpp:276 +#: ../../../src/ui.cpp:1257 +#: ../../../src/ui.cpp:1314 +msgid "The passphrase entered for the wallet decryption was incorrect." +msgstr "Parola introdusa pentru decriptarea portofelului nu este corecta." + +#: ../../../src/ui.cpp:353 +msgid "Status" +msgstr "Stare" + +#: ../../../src/ui.cpp:354 +msgid "Date" +msgstr "Data" + +#: ../../../src/ui.cpp:355 +msgid "Description" +msgstr "Descriere" + +#: ../../../src/ui.cpp:356 +msgid "Debit" +msgstr "Debit" + +#: ../../../src/ui.cpp:357 +msgid "Credit" +msgstr "Credit" + +#: ../../../src/ui.cpp:568 +#, c-format +msgid "Open for %d blocks" +msgstr "Deschis pentru %d blocuri" + +#: ../../../src/ui.cpp:570 +#, c-format +msgid "Open until %s" +msgstr "Deschis pana la %s" + +#: ../../../src/ui.cpp:576 +#, c-format +msgid "%d/offline?" +msgstr "%d/desconectat?" + +#: ../../../src/ui.cpp:578 +#, c-format +msgid "%d/unconfirmed" +msgstr "%d/neconfirmat" + +#: ../../../src/ui.cpp:580 +#, c-format +msgid "%d confirmations" +msgstr "%d confirmari" + +#: ../../../src/ui.cpp:665 +msgid "Generated" +msgstr "Generat" + +#: ../../../src/ui.cpp:673 +#, c-format +msgid "Generated (%s matures in %d more blocks)" +msgstr "Generat (%s matureaza in %d blocuri)" + +#: ../../../src/ui.cpp:677 +msgid "Generated - Warning: This block was not received by any other nodes and will probably not be accepted!" +msgstr "Generat - Atentie: Acest block nu se a receptionat de la alte noduri si probabil nu va fi acceptat!" + +#: ../../../src/ui.cpp:681 +msgid "Generated (not accepted)" +msgstr "Generat (neaceptat)" + +#: ../../../src/ui.cpp:691 +msgid "From: " +msgstr "De: " + +#: ../../../src/ui.cpp:715 +msgid "Received with: " +msgstr "Receptionat cu: " + +#: ../../../src/ui.cpp:760 +msgid "Payment to yourself" +msgstr "Plata proprie" + +#: ../../../src/ui.cpp:794 +msgid "To: " +msgstr "Pentru: " + +#: ../../../src/ui.cpp:1109 +msgid " Generating" +msgstr " Genereaza" + +#: ../../../src/ui.cpp:1111 +msgid "(not connected)" +msgstr "(neconectat)" + +#: ../../../src/ui.cpp:1114 +#, c-format +msgid " %d connections %d blocks %d transactions" +msgstr " %d conexiuni %d blocuri %d tranzactii" + +#: ../../../src/ui.cpp:1171 +msgid "Wallet already encrypted." +msgstr "Portofel deja encriptat." + +#: ../../../src/ui.cpp:1182 +msgid "" +"Enter the new passphrase to the wallet.\n" +"Please use a passphrase of 10 or more random characters, or eight or more words." +msgstr "" +"Introduce noua parola de portofel.\n" +"Te rugam sa utilizezi o parola de 10 sau mai multe caracter aleatoare sau minimum opt cuvinte." + +#: ../../../src/ui.cpp:1189 +#: ../../../src/ui.cpp:1280 +msgid "Error: The supplied passphrase was too short." +msgstr "Eroare: Parola introdusa este prea scurta." + +#: ../../../src/ui.cpp:1193 +msgid "" +"WARNING: If you encrypt your wallet and lose your passphrase, you will LOSE ALL OF YOUR BITCOINS!\n" +"Are you sure you wish to encrypt your wallet?" +msgstr "" +"ATENTIE: Daca encriptezi portofelul si uiti parola vei pierde TOATE MONEDELE!\n" +"Esti sigur ca vrei sa encriptezi portofelul?" + +#: ../../../src/ui.cpp:1199 +msgid "Please re-enter your new wallet passphrase." +msgstr "Reintroduce noua parola de portofel." + +#: ../../../src/ui.cpp:1208 +#: ../../../src/ui.cpp:1302 +msgid "Error: the supplied passphrases didn't match." +msgstr "Eroare: parolele introduse nu sunt identice." + +#: ../../../src/ui.cpp:1218 +msgid "Wallet encryption failed." +msgstr "Encriptare portofel esuata." + +#: ../../../src/ui.cpp:1225 +msgid "" +"Wallet Encrypted.\n" +"Remember that encrypting your wallet cannot fully protect your bitcoins from being stolen by malware infecting your computer." +msgstr "" +"Portofel encriptat.\n" +"Retine ca encriptarea portofelului nu iti poate proteja complet monedele daca pc-ul este infectat de malware." + +#: ../../../src/ui.cpp:1236 +msgid "Wallet is unencrypted, please encrypt it first." +msgstr "Portofelul nu este encriptat, incearca sa-l encriptezi inainte." + +#: ../../../src/ui.cpp:1271 +msgid "Enter the new passphrase for the wallet." +msgstr "Introduce noua parola de portofel." + +#: ../../../src/ui.cpp:1291 +msgid "Re-enter the new passphrase for the wallet." +msgstr "Reintroduce noua parola de portofel." + +#: ../../../src/ui.cpp:1323 +msgid "Wallet Passphrase Changed." +msgstr "Parola de portofel schimbata." + +#: ../../../src/ui.cpp:1379 +#: ../../../src/ui.cpp:2821 +msgid "New Receiving Address" +msgstr "Adresa Noua de Primire" + +#: ../../../src/ui.cpp:1380 +#: ../../../src/ui.cpp:2822 +msgid "" +"You should use a new address for each payment you receive.\n" +"\n" +"Label" +msgstr "" +"Cel mai indicat e sa utilizezi a adresa noua pentru fiecare plata primita.\n" +"\n" +"Eticheta" + +#: ../../../src/ui.cpp:1464 +msgid "<b>Status:</b> " +msgstr "<b>Stare:</b> " + +#: ../../../src/ui.cpp:1469 +msgid ", has not been successfully broadcast yet" +msgstr ", inca nu a fost trimisa cu succes" + +#: ../../../src/ui.cpp:1471 +#, c-format +msgid ", broadcast through %d node" +msgstr ", emis prin nod %d" + +#: ../../../src/ui.cpp:1473 +#, c-format +msgid ", broadcast through %d nodes" +msgstr ", emis prin noduri %d" + +#: ../../../src/ui.cpp:1477 +msgid "<b>Date:</b> " +msgstr "<b>Data:</b> " + +#: ../../../src/ui.cpp:1485 +msgid "<b>Source:</b> Generated<br>" +msgstr "<b>Sursa:</b> Generat<br>" + +#: ../../../src/ui.cpp:1491 +#: ../../../src/ui.cpp:1508 +msgid "<b>From:</b> " +msgstr "<b>De:</b> " + +#: ../../../src/ui.cpp:1508 +msgid "unknown" +msgstr "necunoscut" + +#: ../../../src/ui.cpp:1509 +#: ../../../src/ui.cpp:1533 +#: ../../../src/ui.cpp:1592 +msgid "<b>To:</b> " +msgstr "<b>Pentru:</b> " + +#: ../../../src/ui.cpp:1512 +msgid " (yours, label: " +msgstr "(tau, eticheta: " + +#: ../../../src/ui.cpp:1514 +msgid " (yours)" +msgstr "(tau)" + +#: ../../../src/ui.cpp:1551 +#: ../../../src/ui.cpp:1563 +#: ../../../src/ui.cpp:1609 +#: ../../../src/ui.cpp:1626 +msgid "<b>Credit:</b> " +msgstr "<b>Credit:</b> " + +#: ../../../src/ui.cpp:1553 +#, c-format +msgid "(%s matures in %d more blocks)" +msgstr "(%s matureaza in %d blocuri)" + +#: ../../../src/ui.cpp:1555 +msgid "(not accepted)" +msgstr "(neaceptat)" + +#: ../../../src/ui.cpp:1600 +#: ../../../src/ui.cpp:1608 +#: ../../../src/ui.cpp:1623 +msgid "<b>Debit:</b> " +msgstr "<b>Debit:</b> " + +#: ../../../src/ui.cpp:1614 +msgid "<b>Transaction fee:</b> " +msgstr "<b>Comision tranzactie:</b> " + +#: ../../../src/ui.cpp:1630 +msgid "<b>Net amount:</b> " +msgstr "<b>Cantitate neta:</b> " + +#: ../../../src/ui.cpp:1637 +msgid "Message:" +msgstr "Mesaj:" + +#: ../../../src/ui.cpp:1639 +msgid "Comment:" +msgstr "Comentariu:" + +#: ../../../src/ui.cpp:1642 +msgid "Generated coins must wait 120 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, it will change to \"not accepted\" and not be spendable. This may occasionally happen if another node generates a block within a few seconds of yours." +msgstr "Monedele generate trebuie sa astepte 120 de blocuri inainte sa poata fi cheltuite. Cand ai generat acest block, s-a transmis in retea pentru a fi incul in lantul de blocuri. Daca nu este acceptat in lant, se va schimba in \"neaceptat\" si nu se va putea cheltui. Acest lucru se poate intampla rareori cand alt nod genereaza un bloc in acelasi moment cu al tau ." + +#: ../../../src/ui.cpp:1822 +msgid "Cannot write autostart/bitcoin.desktop file" +msgstr "Nu se poate scrie in fisierul autostart/bitcoin.desktop" + +#: ../../../src/ui.cpp:1858 +msgid "Main" +msgstr "Principal" + +#: ../../../src/ui.cpp:1868 +msgid "&Start Bitcoin on window system startup" +msgstr "&Porneste Bitcoin odata cu sistemul" + +#: ../../../src/ui.cpp:1875 +msgid "&Minimize on close" +msgstr "&Minimizeaza la inchidere" + +#: ../../../src/ui.cpp:2017 +#, c-format +msgid "version %s" +msgstr "versiune %s" + +#: ../../../src/ui.cpp:2140 +msgid "Error in amount " +msgstr "Eroare in cantitate " + +#: ../../../src/ui.cpp:2140 +#: ../../../src/ui.cpp:2145 +#: ../../../src/ui.cpp:2150 +#: ../../../src/ui.cpp:2203 +#: ../../../src/uibase.cpp:61 +msgid "Send Coins" +msgstr "Trimite Monede" + +#: ../../../src/ui.cpp:2145 +msgid "Amount exceeds your balance " +msgstr "Cantitatea trece peste limita disponibila" + +#: ../../../src/ui.cpp:2150 +msgid "Total exceeds your balance when the " +msgstr "Totalul trece peste limita cand" + +#: ../../../src/ui.cpp:2150 +msgid " transaction fee is included " +msgstr "comisionul de tranzactie este inclus" + +#: ../../../src/ui.cpp:2177 +msgid "Payment sent " +msgstr "Plata trimisa" + +#: ../../../src/ui.cpp:2177 +#: ../../../src/ui.cpp:2187 +#: ../../../src/ui.cpp:2337 +#: ../../../src/ui.cpp:2502 +#: ../../../src/wallet.cpp:1088 +msgid "Sending..." +msgstr "Se trimite..." + +#: ../../../src/ui.cpp:2203 +msgid "Invalid address " +msgstr "Adresa incorecta" + +#: ../../../src/ui.cpp:2258 +#, c-format +msgid "Sending %s to %s" +msgstr "Se trimite %s la %s" + +#: ../../../src/ui.cpp:2331 +#: ../../../src/ui.cpp:2364 +msgid "CANCELLED" +msgstr "ANULAT" + +#: ../../../src/ui.cpp:2335 +msgid "Cancelled" +msgstr "Anulat" + +#: ../../../src/ui.cpp:2337 +msgid "Transfer cancelled " +msgstr "Transfer anulat" + +#: ../../../src/ui.cpp:2390 +msgid "Error: " +msgstr "Eroare: " + +#: ../../../src/ui.cpp:2404 +#: ../../../src/ui.cpp:2473 +#: ../../../src/wallet.cpp:1106 +msgid "Insufficient funds" +msgstr "Fonduri insuficiente" + +#: ../../../src/ui.cpp:2409 +msgid "Connecting..." +msgstr "Se conecteaza..." + +#: ../../../src/ui.cpp:2414 +msgid "Unable to connect" +msgstr "Conectare imposibila" + +#: ../../../src/ui.cpp:2419 +msgid "Requesting public key..." +msgstr "Se cere cheia publica..." + +#: ../../../src/ui.cpp:2431 +msgid "Received public key..." +msgstr "Cheia publica primita..." + +#: ../../../src/ui.cpp:2445 +msgid "Recipient is not accepting transactions sent by IP address" +msgstr "Destinatarul nu accepta tranzacti trimise la adresa IP" + +#: ../../../src/ui.cpp:2447 +msgid "Transfer was not accepted" +msgstr "Transferul nu a fost acceptat" + +#: ../../../src/ui.cpp:2456 +msgid "Invalid response received" +msgstr "Raspuns invalid receptionat" + +#: ../../../src/ui.cpp:2469 +msgid "Creating transaction..." +msgstr "Se creeaza tranzactia..." + +#: ../../../src/ui.cpp:2492 +#, c-format +msgid "This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds" +msgstr "Aceasta tranzactie necesita un comision de cel putin %s datorita cantitatii, complexitatii sau uzului de fonduri primite recent" + +#: ../../../src/ui.cpp:2494 +msgid "Transaction creation failed" +msgstr "Crearea tranzactiei a esuat." + +#: ../../../src/ui.cpp:2504 +msgid "Transaction aborted" +msgstr "Tranzactie anulata" + +#: ../../../src/ui.cpp:2512 +msgid "Lost connection, transaction cancelled" +msgstr "Conexiune pierduta, tranzactie anulata" + +#: ../../../src/ui.cpp:2528 +msgid "Sending payment..." +msgstr "Se trimite plata..." + +#: ../../../src/ui.cpp:2540 +msgid "The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here." +msgstr "Tranzactia a fost respinsa. Acest lucru se poate intampla daca vreuna din monede a fost cheltuita sau s-a folosit o copie de portofel (wallet.dat) si monedele a fost cheltuite in copie dar nu s-au marcat cheltuite aici." + +#: ../../../src/ui.cpp:2549 +msgid "Waiting for confirmation..." +msgstr "Se asteapta confirmare..." + +#: ../../../src/ui.cpp:2566 +msgid "" +"The payment was sent, but the recipient was unable to verify it.\n" +"The transaction is recorded and will credit to the recipient,\n" +"but the comment information will be blank." +msgstr "" +"Plata a fost trimisa dar destinatarul nu a putut sa o verifice.\n" +"Tranzactia a fost inregistrata si creditul trimis la desinatar,\n" +"dar informatia de comentarii va ramane in alb." + +#: ../../../src/ui.cpp:2575 +msgid "Payment was sent, but an invalid response was received" +msgstr "Plata a fost trimisa dar s-a receptionat un raspuns incorect" + +#: ../../../src/ui.cpp:2581 +msgid "Payment completed" +msgstr "Plata completa" + +#: ../../../src/ui.cpp:2623 +#: ../../../src/ui.cpp:2769 +#: ../../../src/ui.cpp:2809 +msgid "Name" +msgstr "Nume" + +#: ../../../src/ui.cpp:2624 +#: ../../../src/ui.cpp:2769 +#: ../../../src/ui.cpp:2809 +msgid "Address" +msgstr "Adresa" + +#: ../../../src/ui.cpp:2626 +#: ../../../src/ui.cpp:2781 +msgid "Label" +msgstr "Eticheta" + +#: ../../../src/ui.cpp:2627 +#: ../../../src/uibase.cpp:847 +msgid "Bitcoin Address" +msgstr "Adresa Bitcoin" + +#: ../../../src/ui.cpp:2751 +msgid "This is one of your own addresses for receiving payments and cannot be entered in the address book. " +msgstr "Aceasta este o adresa pentru primire de plati de aceea nu se poate introduce manual in agenda" + +#: ../../../src/ui.cpp:2769 +#: ../../../src/ui.cpp:2775 +msgid "Edit Address" +msgstr "Editeaza adresa" + +#: ../../../src/ui.cpp:2781 +msgid "Edit Address Label" +msgstr "Editeaza eticheta de adresa" + +#: ../../../src/ui.cpp:2809 +#: ../../../src/ui.cpp:2815 +msgid "Add Address" +msgstr "Adauga adresa" + +#: ../../../src/ui.cpp:2902 +msgid "Bitcoin" +msgstr "Bitcoin" + +#: ../../../src/ui.cpp:2904 +msgid "Bitcoin - Generating" +msgstr "Bitcoin - Se genereaza" + +#: ../../../src/ui.cpp:2906 +msgid "Bitcoin - (not connected)" +msgstr "Bitcoin - (neconectat)" + +#: ../../../src/ui.cpp:2985 +msgid "&Open Bitcoin" +msgstr "&Deschide Bitcoin" + +#: ../../../src/ui.cpp:2986 +msgid "&Send Bitcoins" +msgstr "&Trimite Bitcoin" + +#: ../../../src/ui.cpp:2987 +msgid "O&ptions..." +msgstr "O&ptiuni" + +#: ../../../src/ui.cpp:2990 +#: ../../../src/uibase.cpp:25 +msgid "E&xit" +msgstr "I&esire" + +#: ../../../src/ui.cpp:3216 +msgid "Program has crashed and will terminate. " +msgstr "Programul a detectat o eroare si se va inchide." + +#: ../../../src/uibase.cpp:28 +msgid "&File" +msgstr "&Arhiva" + +#: ../../../src/uibase.cpp:32 +msgid "&Your Receiving Addresses..." +msgstr "&Adresele de primire..." + +#: ../../../src/uibase.cpp:35 +msgid "&Encrypt Wallet..." +msgstr "&Encripteaza portofel..." + +#: ../../../src/uibase.cpp:38 +msgid "&Change Wallet Encryption Passphrase..." +msgstr "&Schimba parola de encriptare portofel..." + +#: ../../../src/uibase.cpp:42 +msgid "&Options..." +msgstr "&Optiuni..." + +#: ../../../src/uibase.cpp:45 +msgid "&Settings" +msgstr "&Cnfiguratie" + +#: ../../../src/uibase.cpp:49 +msgid "&About..." +msgstr "&Despre..." + +#: ../../../src/uibase.cpp:52 +msgid "&Help" +msgstr "&Ajutor" + +#: ../../../src/uibase.cpp:62 +msgid "Address Book" +msgstr "Agenda cu adrese" + +#: ../../../src/uibase.cpp:75 +msgid "Your Bitcoin Address:" +msgstr "Adresa Ta Bitcoin:" + +#: ../../../src/uibase.cpp:82 +msgid " &New... " +msgstr " &Nou... " + +#: ../../../src/uibase.cpp:85 +#: ../../../src/uibase.cpp:790 +#: ../../../src/uibase.cpp:893 +msgid " &Copy to Clipboard " +msgstr " &Copiaza in Clipboard" + +#: ../../../src/uibase.cpp:99 +msgid "Balance:" +msgstr "Balant:" + +#: ../../../src/uibase.cpp:115 +msgid " All" +msgstr "Tot" + +#: ../../../src/uibase.cpp:115 +msgid " Sent" +msgstr "Trimis" + +#: ../../../src/uibase.cpp:115 +msgid " Received" +msgstr "Primit" + +#: ../../../src/uibase.cpp:115 +msgid " In Progress" +msgstr "In Curs" + +#: ../../../src/uibase.cpp:136 +msgid "All Transactions" +msgstr "Toate Tranzactiile" + +#: ../../../src/uibase.cpp:147 +msgid "Sent/Received" +msgstr "Trimis/Primit" + +#: ../../../src/uibase.cpp:158 +msgid "Sent" +msgstr "Trimis" + +#: ../../../src/uibase.cpp:169 +msgid "Received" +msgstr "Primit" + +#: ../../../src/uibase.cpp:312 +#: ../../../src/uibase.cpp:453 +#: ../../../src/uibase.cpp:552 +#: ../../../src/uibase.cpp:732 +#: ../../../src/uibase.cpp:793 +#: ../../../src/uibase.cpp:902 +#: ../../../src/uibase.cpp:991 +msgid "OK" +msgstr "OK" + +#: ../../../src/uibase.cpp:355 +msgid "&Start Bitcoin on system startup" +msgstr "&Porneste Bitcoin odata cu sistemul" + +#: ../../../src/uibase.cpp:358 +msgid "&Minimize to the tray instead of the taskbar" +msgstr "&Minimizeaza in tray nu in bara de aplicatii" + +#: ../../../src/uibase.cpp:361 +msgid "Map port using &UPnP" +msgstr "Reserva portul utilizand &UPnP" + +#: ../../../src/uibase.cpp:364 +msgid "M&inimize to the tray on close" +msgstr "M&inimizeaza in tray la inchidere" + +#: ../../../src/uibase.cpp:370 +msgid "&Connect through socks4 proxy (requires restart to apply): " +msgstr "&Conecteaza prin proxy socks4 (repornire apl. necesara): " + +#: ../../../src/uibase.cpp:381 +msgid "Proxy &IP:" +msgstr "&IP de proxy:" + +#: ../../../src/uibase.cpp:389 +msgid " &Port:" +msgstr " &Port:" + +#: ../../../src/uibase.cpp:402 +msgid "Optional transaction fee per KB that helps make sure your transactions are processed quickly. Most transactions are 1KB. Fee 0.01 recommended." +msgstr "Comision optional per KB ce asigura ca tranzactiile tale sunt procesate rapid. Majoritatea tranzactiilor sunt de 1KB. Se recomanda un comision de 0.01." + +#: ../../../src/uibase.cpp:409 +msgid "Pay transaction fee:" +msgstr "Comision de tranzactie:" + +#: ../../../src/uibase.cpp:430 +msgid "// [don't translate] Test panel 2 for future expansion" +msgstr "" + +#: ../../../src/uibase.cpp:434 +msgid "// [don't translate] Let's not start multiple pages until the first page is filled up" +msgstr "" + +#: ../../../src/uibase.cpp:456 +#: ../../../src/uibase.cpp:678 +#: ../../../src/uibase.cpp:737 +#: ../../../src/uibase.cpp:796 +#: ../../../src/uibase.cpp:905 +#: ../../../src/uibase.cpp:994 +msgid "Cancel" +msgstr "Anuleaza" + +#: ../../../src/uibase.cpp:459 +msgid "&Apply" +msgstr "&Aplica" + +#: ../../../src/uibase.cpp:518 +msgid "Bitcoin " +msgstr "Bitcoin " + +#: ../../../src/uibase.cpp:524 +msgid "version" +msgstr "versiune" + +#: ../../../src/uibase.cpp:535 +msgid "" +"Copyright (c) 2009-2011 Bitcoin Developers\n" +"\n" +"This is experimental software.\n" +"\n" +"Distributed under the MIT/X11 software license, see the accompanying file \n" +"license.txt or http://www.opensource.org/licenses/mit-license.php.\n" +"\n" +"This product includes software developed by the OpenSSL Project for use in the \n" +"OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by \n" +"Eric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard." +msgstr "" +"Copyright (c) 2009-2011 Bitcoin Developers\n" +"\n" +"Acesta este un program experimental.\n" +"\n" +"Distribuit sub licenta MIT/X11, cauta fisierul adaugat de licenta \n" +"license.txt sau http://www.opensource.org/licenses/mit-license.php.\n" +"\n" +"Acest produs contine software creat deOpenSSL Project pentru uz in \n" +"OpenSSL Toolkit (http://www.openssl.org/), software cryptografic scris de \n" +"Eric Young (eay@cryptsoft.com) si software UPnP scris de Thomas Bernard." + +#: ../../../src/uibase.cpp:591 +msgid "Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)" +msgstr "Introduce o a adresa Bitcoin (exemplu: 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)" + +#: ../../../src/uibase.cpp:605 +msgid "Pay &To:" +msgstr "Plateste &la:" + +#: ../../../src/uibase.cpp:620 +msgid "&Paste" +msgstr "&Lipeste (paste)" + +#: ../../../src/uibase.cpp:623 +msgid " Address &Book..." +msgstr "Agenda de &adrese..." + +#: ../../../src/uibase.cpp:630 +msgid "&Amount:" +msgstr "&Cantitate:" + +#: ../../../src/uibase.cpp:640 +msgid "T&ransfer:" +msgstr "T&ransfera:" + +#: ../../../src/uibase.cpp:646 +msgid " Standard" +msgstr "Standard" + +#: ../../../src/uibase.cpp:673 +msgid "&Send" +msgstr "&Trimite" + +#: ../../../src/uibase.cpp:721 +msgid "" +"\n" +"\n" +"Connecting..." +msgstr "" +"\n" +"\n" +"Se conecteaza..." + +#: ../../../src/uibase.cpp:771 +msgid "These are your Bitcoin addresses for receiving payments. You may want to give a different one to each sender so you can keep track of who is paying you. The highlighted address is displayed in the main window." +msgstr "Acestea sunt adresele tale pentru primit plati. Poti sa folosesti o adresa diferita pentru fiecare persoana care iti trimite pentru a putea tine cont de unde vin platile. Adresa selectionata este afisata in fereastra principala." + +#: ../../../src/uibase.cpp:784 +#: ../../../src/uibase.cpp:896 +msgid "&Edit..." +msgstr "&Editeaza..." + +#: ../../../src/uibase.cpp:787 +#: ../../../src/uibase.cpp:899 +msgid " &New Address... " +msgstr " &Adresa noua... " + +#: ../../../src/uibase.cpp:859 +msgid "Sending" +msgstr "Se trimite" + +#: ../../../src/uibase.cpp:867 +msgid "These are your Bitcoin addresses for receiving payments. You can give a different one to each sender to keep track of who is paying you. The highlighted address will be displayed in the main window." +msgstr "Acestea sunt adresele tale pentru primit plati. Poti sa folosesti o adresa diferita pentru fiecare persoana care iti trimite pentru a putea tine cont de unde vin platile. Adresa selectionata este afisata in fereastra principala." + +#: ../../../src/uibase.cpp:880 +msgid "Receiving" +msgstr "Se receptioneaza" + +#: ../../../src/uibase.cpp:890 +msgid "&Delete" +msgstr "&Sterge" + +#: ../../../src/util.cpp:870 +msgid "Warning: Please check that your computer's date and time are correct. If your clock is wrong Bitcoin will not work properly." +msgstr "Atentie: Regleaza corect hora si data calculatorului pentru ca Bitcoin sa functioneze corect." + +#: ../../../src/util.cpp:904 +msgid "beta" +msgstr "beta" + +#: ../../../src/wallet.cpp:1073 +msgid "Error: Wallet locked, unable to create transaction " +msgstr "Eroare: Portofel blocat, nu se poate crea tranzactia" + +#: ../../../src/wallet.cpp:1081 +#, c-format +msgid "Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds " +msgstr "Eroare: Aceasta tranzactie necesita un comision de cel putin %s datorita cantitatii, complexitatii sau uzului de fonduri primite recent" + +#: ../../../src/wallet.cpp:1083 +msgid "Error: Transaction creation failed " +msgstr "Eroare: Crearea tranzactiei a esuat" + +#: ../../../src/wallet.cpp:1092 +msgid "Error: The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here." +msgstr "Error: Tranzactia a fost respinsa. Acest lucru se poate intampla daca vreuna din monede a fost cheltuita sau s-a folosit o copie de portofel (wallet.dat) si monedele a fost cheltuite in copie dar nu s-au marcat cheltuite aici." + +#: ../../../src/wallet.cpp:1104 +msgid "Invalid amount" +msgstr "Cantitate incorecta" + +#: ../../../src/uibase.h:151 +msgid "Transaction Details" +msgstr "Detalii de Tranzactie" + +#: ../../../src/uibase.h:203 +msgid "Options" +msgstr "Optiuni" + +#: ../../../src/uibase.h:232 +msgid "About Bitcoin" +msgstr "Despre Bitcoin" + +#: ../../../src/uibase.h:341 +msgid "Your Bitcoin Addresses" +msgstr "Adresele Tale Bitcoin" + +#~ msgid "Invalid bitcoin address" +#~ msgstr "Dirección Bitcoin inválida" diff --git a/share/setup.nsi b/share/setup.nsi index b4bf3cff47..6cf477747c 100644 --- a/share/setup.nsi +++ b/share/setup.nsi @@ -5,7 +5,7 @@ SetCompressor /SOLID lzma # General Symbol Definitions
!define REGKEY "SOFTWARE\$(^Name)"
-!define VERSION 0.3.25
+!define VERSION 0.4.00
!define COMPANY "Bitcoin project"
!define URL http://www.bitcoin.org/
@@ -45,13 +45,13 @@ Var StartMenuGroup !insertmacro MUI_LANGUAGE English
# Installer attributes
-OutFile bitcoin-0.3.25-win32-setup.exe
+OutFile bitcoin-0.4.00-win32-setup.exe
InstallDir $PROGRAMFILES\Bitcoin
CRCCheck on
XPStyle on
BrandingText " "
ShowInstDetails show
-VIProductVersion 0.3.25.0
+VIProductVersion 0.4.00.0
VIAddVersionKey ProductName Bitcoin
VIAddVersionKey ProductVersion "${VERSION}"
VIAddVersionKey CompanyName "${COMPANY}"
diff --git a/src/base58.h b/src/base58.h index 04922c74d8..592756ff74 100644 --- a/src/base58.h +++ b/src/base58.h @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin Developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/bignum.h b/src/bignum.h index 5eaa4028b7..1a2406b935 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_BIGNUM_H diff --git a/src/db.cpp b/src/db.cpp index 9c8c9c4f73..a22b17e34c 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. @@ -610,7 +611,7 @@ bool CWalletDB::WriteAccount(const string& strAccount, const CAccount& account) bool CWalletDB::WriteAccountingEntry(const CAccountingEntry& acentry) { - return Write(make_tuple(string("acentry"), acentry.strAccount, ++nAccountingEntryNumber), acentry); + return Write(boost::make_tuple(string("acentry"), acentry.strAccount, ++nAccountingEntryNumber), acentry); } int64 CWalletDB::GetAccountCreditDebit(const string& strAccount) @@ -638,7 +639,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list<CAccountin // Read next record CDataStream ssKey; if (fFlags == DB_SET_RANGE) - ssKey << make_tuple(string("acentry"), (fAllAccounts? string("") : strAccount), uint64(0)); + ssKey << boost::make_tuple(string("acentry"), (fAllAccounts? string("") : strAccount), uint64(0)); CDataStream ssValue; int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags); fFlags = DB_NEXT; @@ -682,8 +683,7 @@ int CWalletDB::LoadWallet(CWallet* pwallet) #endif //// todo: shouldn't we catch exceptions and try to recover and continue? - CRITICAL_BLOCK(pwallet->cs_mapWallet) - CRITICAL_BLOCK(pwallet->cs_KeyStore) + CRITICAL_BLOCK(pwallet->cs_wallet) { // Get cursor Dbc* pcursor = GetCursor(); @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_DB_H diff --git a/src/headers.h b/src/headers.h index d1844eb24e..d0c7434820 100644 --- a/src/headers.h +++ b/src/headers.h @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/init.cpp b/src/init.cpp index acfcc44d10..dbc2c41332 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #include "headers.h" diff --git a/src/init.h b/src/init.h index a02260c293..4017f25707 100644 --- a/src/init.h +++ b/src/init.h @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_INIT_H diff --git a/src/irc.cpp b/src/irc.cpp index cde934e80c..5278488dcd 100644 --- a/src/irc.cpp +++ b/src/irc.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_IRC_H @@ -1,13 +1,21 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_KEY_H #define BITCOIN_KEY_H +#include <stdexcept> +#include <vector> + #include <openssl/ec.h> #include <openssl/ecdsa.h> #include <openssl/obj_mac.h> +#include "serialize.h" +#include "uint256.h" +#include "base58.h" + // secp160k1 // const unsigned int PRIVATE_KEY_SIZE = 192; // const unsigned int PUBLIC_KEY_SIZE = 41; diff --git a/src/keystore.cpp b/src/keystore.cpp index 1828d6dddc..68f57e7e0e 100644 --- a/src/keystore.cpp +++ b/src/keystore.cpp @@ -1,4 +1,5 @@ -// Copyright (c) 2009-2011 Satoshi Nakamoto & Bitcoin developers +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. @@ -32,6 +33,19 @@ bool CBasicKeyStore::AddKey(const CKey& key) return true; } +bool CCryptoKeyStore::SetCrypted() +{ + CRITICAL_BLOCK(cs_KeyStore) + { + if (fUseCrypto) + return true; + if (!mapKeys.empty()) + return false; + fUseCrypto = true; + } + return true; +} + std::vector<unsigned char> CCryptoKeyStore::GenerateNewKey() { RandAddSeedPerfmon(); @@ -44,7 +58,7 @@ std::vector<unsigned char> CCryptoKeyStore::GenerateNewKey() bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn) { - CRITICAL_BLOCK(cs_vMasterKey) + CRITICAL_BLOCK(cs_KeyStore) { if (!SetCrypted()) return false; @@ -71,7 +85,6 @@ bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn) bool CCryptoKeyStore::AddKey(const CKey& key) { CRITICAL_BLOCK(cs_KeyStore) - CRITICAL_BLOCK(cs_vMasterKey) { if (!IsCrypted()) return CBasicKeyStore::AddKey(key); @@ -105,7 +118,7 @@ bool CCryptoKeyStore::AddCryptedKey(const std::vector<unsigned char> &vchPubKey, bool CCryptoKeyStore::GetKey(const CBitcoinAddress &address, CKey& keyOut) const { - CRITICAL_BLOCK(cs_vMasterKey) + CRITICAL_BLOCK(cs_KeyStore) { if (!IsCrypted()) return CBasicKeyStore::GetKey(address, keyOut); @@ -127,7 +140,7 @@ bool CCryptoKeyStore::GetKey(const CBitcoinAddress &address, CKey& keyOut) const bool CCryptoKeyStore::GetPubKey(const CBitcoinAddress &address, std::vector<unsigned char>& vchPubKeyOut) const { - CRITICAL_BLOCK(cs_vMasterKey) + CRITICAL_BLOCK(cs_KeyStore) { if (!IsCrypted()) return CKeyStore::GetPubKey(address, vchPubKeyOut); @@ -145,7 +158,6 @@ bool CCryptoKeyStore::GetPubKey(const CBitcoinAddress &address, std::vector<unsi bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn) { CRITICAL_BLOCK(cs_KeyStore) - CRITICAL_BLOCK(cs_vMasterKey) { if (!mapCryptedKeys.empty() || IsCrypted()) return false; diff --git a/src/keystore.h b/src/keystore.h index 436053a9e3..bbfac83d1f 100644 --- a/src/keystore.h +++ b/src/keystore.h @@ -1,4 +1,5 @@ -// Copyright (c) 2009-2011 Satoshi Nakamoto & Bitcoin developers +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_KEYSTORE_H @@ -8,9 +9,10 @@ class CKeyStore { -public: +protected: mutable CCriticalSection cs_KeyStore; +public: virtual bool AddKey(const CKey& key) =0; virtual bool HaveKey(const CBitcoinAddress &address) const =0; virtual bool GetKey(const CBitcoinAddress &address, CKey& keyOut) const =0; @@ -29,15 +31,21 @@ public: bool AddKey(const CKey& key); bool HaveKey(const CBitcoinAddress &address) const { - return (mapKeys.count(address) > 0); + bool result; + CRITICAL_BLOCK(cs_KeyStore) + result = (mapKeys.count(address) > 0); + return result; } bool GetKey(const CBitcoinAddress &address, CKey& keyOut) const { - KeyMap::const_iterator mi = mapKeys.find(address); - if (mi != mapKeys.end()) + CRITICAL_BLOCK(cs_KeyStore) { - keyOut.SetSecret((*mi).second); - return true; + KeyMap::const_iterator mi = mapKeys.find(address); + if (mi != mapKeys.end()) + { + keyOut.SetSecret((*mi).second); + return true; + } } return false; } @@ -57,15 +65,7 @@ private: bool fUseCrypto; protected: - bool SetCrypted() - { - if (fUseCrypto) - return true; - if (!mapKeys.empty()) - return false; - fUseCrypto = true; - return true; - } + bool SetCrypted(); // will encrypt previously unencrypted keys bool EncryptKeys(CKeyingMaterial& vMasterKeyIn); @@ -73,8 +73,6 @@ protected: bool Unlock(const CKeyingMaterial& vMasterKeyIn); public: - mutable CCriticalSection cs_vMasterKey; //No guarantees master key wont get locked before you can use it, so lock this first - CCryptoKeyStore() : fUseCrypto(false) { } @@ -88,18 +86,20 @@ public: { if (!IsCrypted()) return false; - return vMasterKey.empty(); + bool result; + CRITICAL_BLOCK(cs_KeyStore) + result = vMasterKey.empty(); + return result; } bool Lock() { - CRITICAL_BLOCK(cs_vMasterKey) - { - if (!SetCrypted()) - return false; + if (!SetCrypted()) + return false; + CRITICAL_BLOCK(cs_KeyStore) vMasterKey.clear(); - } + return true; } @@ -108,9 +108,12 @@ public: bool AddKey(const CKey& key); bool HaveKey(const CBitcoinAddress &address) const { - if (!IsCrypted()) - return CBasicKeyStore::HaveKey(address); - return mapCryptedKeys.count(address) > 0; + CRITICAL_BLOCK(cs_KeyStore) + { + if (!IsCrypted()) + return CBasicKeyStore::HaveKey(address); + return mapCryptedKeys.count(address) > 0; + } } bool GetKey(const CBitcoinAddress &address, CKey& keyOut) const; bool GetPubKey(const CBitcoinAddress &address, std::vector<unsigned char>& vchPubKeyOut) const; diff --git a/src/main.cpp b/src/main.cpp index b57974f577..5b159fe415 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #include "headers.h" @@ -21,15 +22,15 @@ set<CWallet*> setpwalletRegistered; CCriticalSection cs_main; -map<uint256, CTransaction> mapTransactions; +static map<uint256, CTransaction> mapTransactions; CCriticalSection cs_mapTransactions; unsigned int nTransactionsUpdated = 0; map<COutPoint, CInPoint> mapNextTx; map<uint256, CBlockIndex*> mapBlockIndex; uint256 hashGenesisBlock("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"); -CBigNum bnProofOfWorkLimit(~uint256(0) >> 32); -const int nTotalBlocksEstimate = 134444; // Conservative estimate of total nr of blocks on main chain +static CBigNum bnProofOfWorkLimit(~uint256(0) >> 32); +const int nTotalBlocksEstimate = 140700; // Conservative estimate of total nr of blocks on main chain const int nInitialBlockThreshold = 120; // Regard blocks up until N-threshold as "initial download" CBlockIndex* pindexGenesisBlock = NULL; int nBestHeight = -1; @@ -294,9 +295,10 @@ int CMerkleTx::SetMerkleBranch(const CBlock* pblock) bool CTransaction::CheckTransaction() const { // Basic checks that don't depend on any context - if (vin.empty() || vout.empty()) - return error("CTransaction::CheckTransaction() : vin or vout empty"); - + if (vin.empty()) + return error("CTransaction::CheckTransaction() : vin empty"); + if (vout.empty()) + return error("CTransaction::CheckTransaction() : vout empty"); // Size limits if (::GetSerializeSize(*this, SER_NETWORK) > MAX_BLOCK_SIZE) return error("CTransaction::CheckTransaction() : size limits failed"); @@ -314,6 +316,15 @@ bool CTransaction::CheckTransaction() const return error("CTransaction::CheckTransaction() : txout total out of range"); } + // Check for duplicate inputs + set<COutPoint> vInOutPoints; + BOOST_FOREACH(const CTxIn& txin, vin) + { + if (vInOutPoints.count(txin.prevout)) + return false; + vInOutPoints.insert(txin.prevout); + } + if (IsCoinBase()) { if (vin[0].scriptSig.size() < 2 || vin[0].scriptSig.size() > 100) @@ -802,7 +813,7 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, map<uint256, CTxIndex>& mapTestPoo // Read txindex CTxIndex txindex; bool fFound = true; - if (fMiner && mapTestPool.count(prevout.hash)) + if ((fBlock || fMiner) && mapTestPool.count(prevout.hash)) { // Get txindex from current proposed changes txindex = mapTestPool[prevout.hash]; @@ -862,12 +873,7 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, map<uint256, CTxIndex>& mapTestPoo txindex.vSpent[prevout.n] = posThisTx; // Write back - if (fBlock) - { - if (!txdb.UpdateTxIndex(prevout.hash, txindex)) - return error("ConnectInputs() : UpdateTxIndex failed"); - } - else if (fMiner) + if (fBlock || fMiner) { mapTestPool[prevout.hash] = txindex; } @@ -889,9 +895,8 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, map<uint256, CTxIndex>& mapTestPoo if (fBlock) { - // Add transaction to disk index - if (!txdb.AddTxIndex(*this, posThisTx, pindexBlock->nHeight)) - return error("ConnectInputs() : AddTxPos failed"); + // Add transaction to changes + mapTestPool[GetHash()] = CTxIndex(posThisTx, vout.size()); } else if (fMiner) { @@ -980,16 +985,22 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex) //// issue here: it doesn't know the version unsigned int nTxPos = pindex->nBlockPos + ::GetSerializeSize(CBlock(), SER_DISK) - 1 + GetSizeOfCompactSize(vtx.size()); - map<uint256, CTxIndex> mapUnused; + map<uint256, CTxIndex> mapQueuedChanges; int64 nFees = 0; BOOST_FOREACH(CTransaction& tx, vtx) { CDiskTxPos posThisTx(pindex->nFile, pindex->nBlockPos, nTxPos); nTxPos += ::GetSerializeSize(tx, SER_DISK); - if (!tx.ConnectInputs(txdb, mapUnused, posThisTx, pindex, nFees, true, false)) + if (!tx.ConnectInputs(txdb, mapQueuedChanges, posThisTx, pindex, nFees, true, false)) return false; } + // Write queued txindex changes + for (map<uint256, CTxIndex>::iterator mi = mapQueuedChanges.begin(); mi != mapQueuedChanges.end(); ++mi) + { + if (!txdb.UpdateTxIndex((*mi).first, (*mi).second)) + return error("ConnectBlock() : UpdateTxIndex failed"); + } if (vtx[0].GetValueOut() > GetBlockValue(pindex->nHeight, nFees)) return false; @@ -1291,7 +1302,8 @@ bool CBlock::AcceptBlock() (nHeight == 74000 && hash != uint256("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20")) || (nHeight == 105000 && hash != uint256("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97")) || (nHeight == 118000 && hash != uint256("0x000000000000774a7f8a7a12dc906ddb9e17e75d684f15e00f8767f9e8f36553")) || - (nHeight == 134444 && hash != uint256("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe"))) + (nHeight == 134444 && hash != uint256("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe")) || + (nHeight == 140700 && hash != uint256("0x000000000000033b512028abb90e1626d8b346fd0ed598ac0a3c371138dce2bd"))) return error("AcceptBlock() : rejected by checkpoint lockin at %d", nHeight); // Write block to history file @@ -1308,7 +1320,7 @@ bool CBlock::AcceptBlock() if (hashBestChain == hash) CRITICAL_BLOCK(cs_vNodes) BOOST_FOREACH(CNode* pnode, vNodes) - if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 134444)) + if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : 140700)) pnode->PushInventory(CInv(MSG_BLOCK, hash)); return true; @@ -1375,47 +1387,6 @@ bool static ProcessBlock(CNode* pfrom, CBlock* pblock) -template<typename Stream> -bool static ScanMessageStart(Stream& s) -{ - // Scan ahead to the next pchMessageStart, which should normally be immediately - // at the file pointer. Leaves file pointer at end of pchMessageStart. - s.clear(0); - short prevmask = s.exceptions(0); - const char* p = BEGIN(pchMessageStart); - try - { - loop - { - char c; - s.read(&c, 1); - if (s.fail()) - { - s.clear(0); - s.exceptions(prevmask); - return false; - } - if (*p != c) - p = BEGIN(pchMessageStart); - if (*p == c) - { - if (++p == END(pchMessageStart)) - { - s.clear(0); - s.exceptions(prevmask); - return true; - } - } - } - } - catch (...) - { - s.clear(0); - s.exceptions(prevmask); - return false; - } -} - bool CheckDiskSpace(uint64 nAdditionalBytes) { uint64 nFreeBytesAvailable = filesystem::space(GetDataDir()).available; @@ -1766,7 +1737,7 @@ bool static AlreadyHave(CTxDB& txdb, const CInv& inv) // The message start string is designed to be unlikely to occur in normal data. // The characters are rarely used upper ascii, not valid as UTF-8, and produce // a large 4-byte int at any alignment. -char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 }; +unsigned char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 }; bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) @@ -1852,7 +1823,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) // Ask the first connected node for block updates static int nAskedForBlocks; - if (!pfrom->fClient && (nAskedForBlocks < 1 || vNodes.size() <= 1)) + if (!pfrom->fClient && + (pfrom->nVersion < 32000 || pfrom->nVersion >= 32400) && + (nAskedForBlocks < 1 || vNodes.size() <= 1)) { nAskedForBlocks++; pfrom->PushGetBlocks(pindexBest, uint256(0)); @@ -2212,7 +2185,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) // Keep giving the same key to the same ip until they use it if (!mapReuseKey.count(pfrom->addr.ip)) - mapReuseKey[pfrom->addr.ip] = pwalletMain->GetOrReuseKeyFromPool(); + pwalletMain->GetKeyFromPool(mapReuseKey[pfrom->addr.ip], true); // Send back approval of order and pubkey to use CScript scriptPubKey; @@ -2654,7 +2627,7 @@ unsigned int static ScanHash_CryptoPP(char* pmidstate, char* pdata, char* phash1 } } - +// Some explaining would be appreciated class COrphan { public: @@ -2825,16 +2798,17 @@ CBlock* CreateNewBlock(CReserveKey& reservekey) } -void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce, int64& nPrevTime) +void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce) { // Update nExtraNonce - int64 nNow = max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); - if (++nExtraNonce >= 0x7f && nNow > nPrevTime+1) + static uint256 hashPrevBlock; + if (hashPrevBlock != pblock->hashPrevBlock) { - nExtraNonce = 1; - nPrevTime = nNow; + nExtraNonce = 0; + hashPrevBlock = pblock->hashPrevBlock; } - pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nBits << CBigNum(nExtraNonce); + ++nExtraNonce; + pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nTime << CBigNum(nExtraNonce); pblock->hashMerkleRoot = pblock->BuildMerkleTree(); } @@ -2910,7 +2884,7 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey) reservekey.KeepKey(); // Track how many getdata requests this block gets - CRITICAL_BLOCK(wallet.cs_mapRequestCount) + CRITICAL_BLOCK(wallet.cs_wallet) wallet.mapRequestCount[pblock->GetHash()] = 0; // Process this block the same as if we had received it from another node @@ -2932,7 +2906,6 @@ void static BitcoinMiner(CWallet *pwallet) // Each thread has its own key and counter CReserveKey reservekey(pwallet); unsigned int nExtraNonce = 0; - int64 nPrevTime = 0; while (fGenerateBitcoins) { @@ -2959,7 +2932,7 @@ void static BitcoinMiner(CWallet *pwallet) auto_ptr<CBlock> pblock(CreateNewBlock(reservekey)); if (!pblock.get()) return; - IncrementExtraNonce(pblock.get(), pindexPrev, nExtraNonce, nPrevTime); + IncrementExtraNonce(pblock.get(), pindexPrev, nExtraNonce); printf("Running BitcoinMiner with %d transactions in block\n", pblock->vtx.size()); diff --git a/src/main.h b/src/main.h index 9d6de52fa4..c400145d01 100644 --- a/src/main.h +++ b/src/main.h @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_MAIN_H @@ -20,7 +21,6 @@ class CKeyItem; class CReserveKey; class CWalletDB; -class CMessageHeader; class CAddress; class CInv; class CRequestTracker; @@ -53,7 +53,6 @@ static const int fHaveUPnP = false; extern CCriticalSection cs_main; extern std::map<uint256, CBlockIndex*> mapBlockIndex; extern uint256 hashGenesisBlock; -extern CBigNum bnProofOfWorkLimit; extern CBlockIndex* pindexGenesisBlock; extern int nBestHeight; extern CBigNum bnBestChainWork; @@ -95,7 +94,7 @@ bool ProcessMessages(CNode* pfrom); bool SendMessages(CNode* pto, bool fSendTrickle); void GenerateBitcoins(bool fGenerate, CWallet* pwallet); CBlock* CreateNewBlock(CReserveKey& reservekey); -void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce, int64& nPrevTime); +void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce); void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash1); bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey); bool CheckProofOfWork(uint256 hash, unsigned int nBits); @@ -1557,16 +1556,4 @@ public: bool ProcessAlert(); }; - - - - - - - - - - -extern std::map<uint256, CTransaction> mapTransactions; - #endif diff --git a/src/makefile.linux-mingw b/src/makefile.linux-mingw index 59ff03c48d..24cc127c2d 100644 --- a/src/makefile.linux-mingw +++ b/src/makefile.linux-mingw @@ -7,19 +7,19 @@ DEPSDIR:=/usr/i586-mingw32msvc USE_UPNP:=0 INCLUDEPATHS= \ - -I"$(DEPSDIR)/boost_1_43_0" \ - -I"$(DEPSDIR)/db-4.7.25.NC/build_unix" \ + -I"$(DEPSDIR)/boost_1_47_0" \ + -I"$(DEPSDIR)/db-4.8.30.NC/build_unix" \ -I"$(DEPSDIR)/openssl-1.0.0d/include" \ - -I"$(DEPSDIR)/wxWidgets-2.9.1/lib/gcc_lib/mswud" \ - -I"$(DEPSDIR)/wxWidgets-2.9.1/include" \ - -I"$(DEPSDIR)/wxWidgets-2.9.1/lib/wx/include/i586-mingw32msvc-msw-unicode-static-2.9/" \ + -I"$(DEPSDIR)/wxWidgets-2.9.2/lib/gcc_lib/mswud" \ + -I"$(DEPSDIR)/wxWidgets-2.9.2/include" \ + -I"$(DEPSDIR)/wxWidgets-2.9.2/lib/wx/include/i586-mingw32msvc-msw-unicode-static-2.9/" \ -I"$(DEPSDIR)" LIBPATHS= \ - -L"$(DEPSDIR)/boost_1_43_0/stage/lib" \ - -L"$(DEPSDIR)/db-4.7.25.NC/build_unix" \ + -L"$(DEPSDIR)/boost_1_47_0/stage/lib" \ + -L"$(DEPSDIR)/db-4.8.30.NC/build_unix" \ -L"$(DEPSDIR)/openssl-1.0.0d" \ - -L"$(DEPSDIR)/wxWidgets-2.9.1/lib" + -L"$(DEPSDIR)/wxWidgets-2.9.2/lib" WXLIBS= -l wx_mswu-2.9-i586-mingw32msvc @@ -32,16 +32,35 @@ LIBS= \ -l ssl \ -l crypto -DEFS=-D_MT -DWIN32 -D__WXMSW__ -D_WINDOWS -DNOPCH -DUSE_SSL +DEFS=-D_MT -DWIN32 -D__WXMSW__ -D_WINDOWS -DNOPCH -DUSE_SSL -DBOOST_THREAD_USE_LIB DEBUGFLAGS=-g -D__WXDEBUG__ CFLAGS=-O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) -HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \ - script.h db.h net.h irc.h keystore.h main.h wallet.h rpc.h uibase.h ui.h noui.h \ - crypter.h init.h +HEADERS = \ + base58.h \ + bignum.h \ + crypter.h \ + db.h \ + headers.h \ + init.h \ + irc.h \ + key.h \ + keystore.h \ + main.h \ + net.h \ + noui.h \ + protocol.h \ + rpc.h \ + script.h \ + serialize.h \ + strlcpy.h \ + ui.h \ + uibase.h \ + uint256.h \ + util.h \ + wallet.h ifdef USE_UPNP - INCLUDEPATHS += -I"$(DEPSDIR)/upnpc-exe-win32-20110215" - LIBPATHS += -L"$(DEPSDIR)/upnpc-exe-win32-20110215" + LIBPATHS += -L"$(DEPSDIR)/miniupnpc" LIBS += -l miniupnpc -l iphlpapi DEFS += -DSTATICLIB -DUSE_UPNP=$(USE_UPNP) endif @@ -49,17 +68,18 @@ endif LIBS += -l mingwthrd -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi OBJS= \ - obj/util.o \ - obj/script.o \ + obj/crypter.o \ obj/db.o \ - obj/net.o \ + obj/init.o \ obj/irc.o \ obj/keystore.o \ obj/main.o \ - obj/wallet.o \ + obj/net.o \ + obj/protocol.o \ obj/rpc.o \ - obj/init.o \ - obj/crypter.o \ + obj/script.o \ + obj/util.o \ + obj/wallet.o \ cryptopp/obj/sha.o \ cryptopp/obj/cpu.o @@ -90,7 +110,7 @@ bitcoind.exe: $(OBJS:obj/%=obj/nogui/%) obj/ui_res.o obj/test/%.o: obj/test/%.cpp $(HEADERS) i586-mingw32msvc-g++ -c $(CFLAGS) -o $@ $< -test_bitcoin.exe: obj/test/test_bitcoin.o +test_bitcoin.exe: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) i586-mingw32msvc-g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -lboost_unit_test_framework-mt-s diff --git a/src/makefile.mingw b/src/makefile.mingw index 16a0540094..1ca1a7bbe2 100644 --- a/src/makefile.mingw +++ b/src/makefile.mingw @@ -5,40 +5,60 @@ USE_UPNP:=0 INCLUDEPATHS= \ - -I"C:\boost-1.43.0-mgw" \ - -I"C:\db-4.7.25.NC-mgw\build_unix" \ + -I"C:\boost-1.47.0-mgw" \ + -I"C:\db-4.8.30.NC-mgw\build_unix" \ -I"C:\openssl-1.0.0d-mgw\include" \ - -I"C:\wxWidgets-2.9.1-mgw\lib\gcc_lib\mswud" \ - -I"C:\wxWidgets-2.9.1-mgw\include" + -I"C:\wxWidgets-2.9.2-mgw\lib\gcc_lib\mswud" \ + -I"C:\wxWidgets-2.9.2-mgw\include" LIBPATHS= \ - -L"C:\boost-1.43.0-mgw\stage\lib" \ - -L"C:\db-4.7.25.NC-mgw\build_unix" \ + -L"C:\boost-1.47.0-mgw\stage\lib" \ + -L"C:\db-4.8.30.NC-mgw\build_unix" \ -L"C:\openssl-1.0.0d-mgw" \ - -L"C:\wxWidgets-2.9.1-mgw\lib\gcc_lib" + -L"C:\wxWidgets-2.9.2-mgw\lib\gcc_lib" WXLIBS= \ -l wxmsw29ud_html -l wxmsw29ud_core -l wxmsw29ud_adv -l wxbase29ud -l wxtiffd -l wxjpegd -l wxpngd -l wxzlibd LIBS= \ - -l boost_system-mgw45-mt-s-1_43 \ - -l boost_filesystem-mgw45-mt-s-1_43 \ - -l boost_program_options-mgw45-mt-s-1_43 \ - -l boost_thread-mgw45-mt-s-1_43 \ + -l boost_system-mgw45-mt-s-1_47 \ + -l boost_filesystem-mgw45-mt-s-1_47 \ + -l boost_program_options-mgw45-mt-s-1_47 \ + -l boost_thread-mgw45-mt-s-1_47 \ -l db_cxx \ -l ssl \ -l crypto -DEFS=-DWIN32 -D__WXMSW__ -D_WINDOWS -DNOPCH -DUSE_SSL +DEFS=-DWIN32 -D__WXMSW__ -D_WINDOWS -DNOPCH -DUSE_SSL -DBOOST_THREAD_USE_LIB DEBUGFLAGS=-g -D__WXDEBUG__ CFLAGS=-mthreads -O2 -w -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) -HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \ - script.h db.h net.h irc.h keystore.h main.h wallet.h rpc.h uibase.h ui.h noui.h \ - init.h crypter.h +HEADERS = \ + base58.h \ + bignum.h \ + crypter.h \ + db.h \ + headers.h \ + init.h \ + irc.h \ + key.h \ + keystore.h \ + main.h \ + net.h \ + noui.h \ + protocol.h \ + rpc.h \ + script.h \ + serialize.h \ + strlcpy.h \ + ui.h \ + uibase.h \ + uint256.h \ + util.h \ + wallet.h ifdef USE_UPNP - INCLUDEPATHS += -I"C:\upnpc-exe-win32-20110215" - LIBPATHS += -L"C:\upnpc-exe-win32-20110215" + INCLUDEPATHS += -I"C:\miniupnpc-1.6-mgw" + LIBPATHS += -L"C:\miniupnpc-1.6-mgw" LIBS += -l miniupnpc -l iphlpapi DEFS += -DSTATICLIB -DUSE_UPNP=$(USE_UPNP) endif @@ -46,17 +66,18 @@ endif LIBS += -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l shlwapi OBJS= \ - obj/util.o \ - obj/script.o \ + obj/crypter.o \ obj/db.o \ - obj/net.o \ + obj/init.o \ obj/irc.o \ obj/keystore.o \ obj/main.o \ - obj/wallet.o \ + obj/net.o \ + obj/protocol.o \ obj/rpc.o \ - obj/init.o \ - obj/crypter.o \ + obj/script.o \ + obj/util.o \ + obj/wallet.o \ cryptopp/obj/sha.o \ cryptopp/obj/cpu.o @@ -83,10 +104,10 @@ obj/nogui/%.o: %.cpp $(HEADERS) bitcoind.exe: $(OBJS:obj/%=obj/nogui/%) obj/ui_res.o g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -obj/test/%.o: obj/test/%.cpp $(HEADERS) - g++ -c $(CFLAGS) -o $@ $< +obj/test/test_bitcoin.o: $(wildcard test/*.cpp) $(HEADERS) + g++ -c $(CFLAGS) -o $@ test/test_bitcoin.cpp -test_bitcoin: obj/test/test_bitcoin.o +test_bitcoin.exe: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) g++ $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) clean: diff --git a/src/makefile.osx b/src/makefile.osx index 89788562c3..97264c7eb4 100644 --- a/src/makefile.osx +++ b/src/makefile.osx @@ -32,22 +32,43 @@ DEFS=$(shell $(DEPSDIR)/bin/wx-config --cxxflags) -D__WXMAC_OSX__ -DNOPCH -DMSG_ DEBUGFLAGS=-g -DwxDEBUG_LEVEL=0 # ppc doesn't work because we don't support big-endian CFLAGS=-mmacosx-version-min=10.5 -arch i386 -arch x86_64 -O3 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) -HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \ - script.h db.h net.h irc.h keystore.h main.h wallet.h rpc.h uibase.h ui.h noui.h \ - init.h crypter.h +HEADERS = \ + base58.h \ + bignum.h \ + crypter.h \ + db.h \ + headers.h \ + init.h \ + irc.h \ + key.h \ + keystore.h \ + main.h \ + net.h \ + noui.h \ + protocol.h \ + rpc.h \ + script.h \ + serialize.h \ + strlcpy.h \ + ui.h \ + uibase.h \ + uint256.h \ + util.h \ + wallet.h OBJS= \ - obj/util.o \ - obj/script.o \ + obj/crypter.o \ obj/db.o \ - obj/net.o \ + obj/init.o \ obj/irc.o \ obj/keystore.o \ obj/main.o \ - obj/wallet.o \ + obj/net.o \ + obj/protocol.o \ obj/rpc.o \ - obj/init.o \ - obj/crypter.o \ + obj/script.o \ + obj/util.o \ + obj/wallet.o \ cryptopp/obj/sha.o \ cryptopp/obj/cpu.o @@ -76,10 +97,10 @@ obj/nogui/%.o: %.cpp $(HEADERS) bitcoind: $(OBJS:obj/%=obj/nogui/%) $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -obj/test/%.o: test/%.cpp $(HEADERS) - $(CXX) -c $(CFLAGS) -o $@ $< +obj/test/test_bitcoin.o: $(wildcard test/*.cpp) $(HEADERS) + $(CXX) -c $(CFLAGS) -o $@ test/test_bitcoin.cpp -test_bitcoin: obj/test/test_bitcoin.o +test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -lboost_unit_test_framework clean: diff --git a/src/makefile.unix b/src/makefile.unix index 0567f8b75e..298d856ecb 100644 --- a/src/makefile.unix +++ b/src/makefile.unix @@ -10,7 +10,7 @@ WXLIBS=$(shell wx-config --libs) USE_UPNP:=0 -DEFS=-DNOPCH -DFOURWAYSSE2 -DUSE_SSL +DEFS=-DNOPCH -DUSE_SSL # for boost 1.37, add -mt to the boost libraries LIBS= \ @@ -38,22 +38,43 @@ LIBS+= \ DEBUGFLAGS=-g -D__WXDEBUG__ CXXFLAGS=-O2 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(DEFS) -HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \ - script.h db.h net.h irc.h keystore.h main.h wallet.h rpc.h uibase.h ui.h noui.h \ - init.h crypter.h +HEADERS = \ + base58.h \ + bignum.h \ + crypter.h \ + db.h \ + headers.h \ + init.h \ + irc.h \ + key.h \ + keystore.h \ + main.h \ + net.h \ + noui.h \ + protocol.h \ + rpc.h \ + script.h \ + serialize.h \ + strlcpy.h \ + ui.h \ + uibase.h \ + uint256.h \ + util.h \ + wallet.h OBJS= \ - obj/util.o \ - obj/script.o \ + obj/crypter.o \ obj/db.o \ - obj/net.o \ + obj/init.o \ obj/irc.o \ obj/keystore.o \ obj/main.o \ - obj/wallet.o \ + obj/net.o \ + obj/protocol.o \ obj/rpc.o \ - obj/init.o \ - obj/crypter.o \ + obj/script.o \ + obj/util.o \ + obj/wallet.o \ cryptopp/obj/sha.o \ cryptopp/obj/cpu.o @@ -77,11 +98,11 @@ obj/nogui/%.o: %.cpp $(HEADERS) bitcoind: $(OBJS:obj/%=obj/nogui/%) $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS) -obj/test/%.o: test/%.cpp $(HEADERS) - $(CXX) -c $(CFLAGS) -o $@ $< +obj/test/test_bitcoin.o: $(wildcard test/*.cpp) $(HEADERS) + $(CXX) -c $(CFLAGS) -o $@ test/test_bitcoin.cpp -test_bitcoin: obj/test/test_bitcoin.o - $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) -lboost_unit_test_framework +test_bitcoin: obj/test/test_bitcoin.o $(filter-out obj/nogui/init.o,$(OBJS:obj/%=obj/nogui/%)) + $(CXX) $(CXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-Bstatic -lboost_unit_test_framework $(LIBS) clean: -rm -f bitcoin bitcoind test_bitcoin diff --git a/src/makefile.vc b/src/makefile.vc index c050deb6ed..a5437bcf5c 100644 --- a/src/makefile.vc +++ b/src/makefile.vc @@ -45,21 +45,45 @@ LIBS=$(LIBS) \ DEBUGFLAGS=/Os CFLAGS=/MD /c /nologo /EHsc /GR /Zm300 $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) -HEADERS=headers.h strlcpy.h serialize.h uint256.h util.h key.h bignum.h base58.h \ - script.h db.h net.h irc.h main.h rpc.h uibase.h ui.h noui.h init.h wallet.h keystore.h crypter.h +HEADERS = \ + base58.h \ + bignum.h \ + crypter.h \ + db.h \ + headers.h \ + init.h \ + irc.h \ + key.h \ + keystore.h \ + main.h \ + net.h \ + noui.h \ + protocol.h \ + rpc.h \ + script.h \ + serialize.h \ + strlcpy.h \ + ui.h \ + uibase.h \ + uint256.h \ + util.h \ + wallet.h OBJS= \ - obj\util.obj \ - obj\script.obj \ - obj\db.obj \ - obj\net.obj \ - obj\irc.obj \ - obj\keystore.obj \ - obj\main.obj \ - obj\wallet.obj \ - obj\rpc.obj \ - obj\init.obj \ - obj\crypter.obj + obj\crypter.o \ + obj\db.o \ + obj\init.o \ + obj\irc.o \ + obj\keystore.o \ + obj\main.o \ + obj\net.o \ + obj\rpc.o \ + obj\protocol.o \ + obj\script.o \ + obj\util.o \ + obj\wallet.o \ + cryptopp\obj\sha.o \ + cryptopp\obj\cpu.o CRYPTOPP_OBJS= \ cryptopp\obj\sha.obj \ diff --git a/src/net.cpp b/src/net.cpp index d697788213..509d8905f9 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. @@ -11,11 +12,6 @@ #ifdef __WXMSW__ #include <string.h> -// This file can be downloaded as a part of the Windows Platform SDK -// and is required for Bitcoin binaries to work properly on versions -// of Windows before XP. If you are doing builds of Bitcoin for -// public release, you should uncomment this line. -//#include <WSPiApi.h> #endif #ifdef USE_UPNP @@ -49,10 +45,10 @@ bool fClient = false; bool fAllowDNS = false; uint64 nLocalServices = (fClient ? 0 : NODE_NETWORK); CAddress addrLocalHost("0.0.0.0", 0, false, nLocalServices); -CNode* pnodeLocalHost = NULL; +static CNode* pnodeLocalHost = NULL; uint64 nLocalHostNonce = 0; array<int, 10> vnThreadsRunning; -SOCKET hListenSocket = INVALID_SOCKET; +static SOCKET hListenSocket = INVALID_SOCKET; vector<CNode*> vNodes; CCriticalSection cs_vNodes; @@ -98,7 +94,7 @@ bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet, int nTimeout SOCKET hSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (hSocket == INVALID_SOCKET) return false; -#ifdef BSD +#ifdef SO_NOSIGPIPE int set = 1; setsockopt(hSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&set, sizeof(int)); #endif @@ -447,6 +443,10 @@ bool AddAddress(CAddress addr, int64 nTimePenalty, CAddrDB *pAddrDB) if (addr.ip == addrLocalHost.ip) return false; addr.nTime = max((int64)0, (int64)addr.nTime - nTimePenalty); + bool fUpdated = false; + bool fNew = false; + CAddress addrFound = addr; + CRITICAL_BLOCK(cs_mapAddresses) { map<vector<unsigned char>, CAddress>::iterator it = mapAddresses.find(addr.GetKey()); @@ -455,16 +455,12 @@ bool AddAddress(CAddress addr, int64 nTimePenalty, CAddrDB *pAddrDB) // New address printf("AddAddress(%s)\n", addr.ToString().c_str()); mapAddresses.insert(make_pair(addr.GetKey(), addr)); - if (pAddrDB) - pAddrDB->WriteAddress(addr); - else - CAddrDB().WriteAddress(addr); - return true; + fUpdated = true; + fNew = true; } else { - bool fUpdated = false; - CAddress& addrFound = (*it).second; + addrFound = (*it).second; if ((addrFound.nServices | addr.nServices) != addrFound.nServices) { // Services have been added @@ -479,16 +475,22 @@ bool AddAddress(CAddress addr, int64 nTimePenalty, CAddrDB *pAddrDB) addrFound.nTime = addr.nTime; fUpdated = true; } - if (fUpdated) - { - if (pAddrDB) - pAddrDB->WriteAddress(addrFound); - else - CAddrDB().WriteAddress(addrFound); - } } } - return false; + // There is a nasty deadlock bug if this is done inside the cs_mapAddresses + // CRITICAL_BLOCK: + // Thread 1: begin db transaction (locks inside-db-mutex) + // then AddAddress (locks cs_mapAddresses) + // Thread 2: AddAddress (locks cs_mapAddresses) + // ... then db operation hangs waiting for inside-db-mutex + if (fUpdated) + { + if (pAddrDB) + pAddrDB->WriteAddress(addrFound); + else + CAddrDB().WriteAddress(addrFound); + } + return fNew; } void AddressCurrentlyConnected(const CAddress& addr) @@ -1078,10 +1080,11 @@ void ThreadMapPort2(void* parg) const char * rootdescurl = 0; const char * multicastif = 0; const char * minissdpdpath = 0; + int error = 0; struct UPNPDev * devlist = 0; char lanaddr[64]; - devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0); + devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, &error); struct UPNPUrls urls; struct IGDdatas data; @@ -1093,14 +1096,9 @@ void ThreadMapPort2(void* parg) char intClient[16]; char intPort[6]; string strDesc = "Bitcoin " + FormatFullVersion(); - -#ifndef __WXMSW__ - r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, - port, port, lanaddr, strDesc.c_str(), "TCP", 0); -#else r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, port, port, lanaddr, strDesc.c_str(), "TCP", 0, "0"); -#endif + if(r!=UPNPCOMMAND_SUCCESS) printf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n", port, port, lanaddr, r, strupnperror(r)); @@ -1143,6 +1141,11 @@ void MapPort(bool fMapPort) printf("Error: ThreadMapPort(ThreadMapPort) failed\n"); } } +#else +void MapPort(bool /* unused fMapPort */) +{ + // Intentionally left blank. +} #endif @@ -1196,46 +1199,70 @@ void DNSAddressSeed() unsigned int pnSeed[] = { - 0x1ddb1032, 0x6242ce40, 0x52d6a445, 0x2dd7a445, 0x8a53cd47, 0x73263750, 0xda23c257, 0xecd4ed57, - 0x0a40ec59, 0x75dce160, 0x7df76791, 0x89370bad, 0xa4f214ad, 0x767700ae, 0x638b0418, 0x868a1018, - 0xcd9f332e, 0x0129653e, 0xcc92dc3e, 0x96671640, 0x56487e40, 0x5b66f440, 0xb1d01f41, 0xf1dc6041, - 0xc1d12b42, 0x86ba1243, 0x6be4df43, 0x6d4cef43, 0xd18e0644, 0x1ab0b344, 0x6584a345, 0xe7c1a445, - 0x58cea445, 0xc5daa445, 0x21dda445, 0x3d3b5346, 0x13e55347, 0x1080d24a, 0x8e611e4b, 0x81518e4b, - 0x6c839e4b, 0xe2ad0a4c, 0xfbbc0a4c, 0x7f5b6e4c, 0x7244224e, 0x1300554e, 0x20690652, 0x5a48b652, - 0x75c5c752, 0x4335cc54, 0x340fd154, 0x87c07455, 0x087b2b56, 0x8a133a57, 0xac23c257, 0x70374959, - 0xfb63d45b, 0xb9a1685c, 0x180d765c, 0x674f645d, 0x04d3495e, 0x1de44b5e, 0x4ee8a362, 0x0ded1b63, - 0xc1b04b6d, 0x8d921581, 0x97b7ea82, 0x1cf83a8e, 0x91490bad, 0x09dc75ae, 0x9a6d79ae, 0xa26d79ae, - 0x0fd08fae, 0x0f3e3fb2, 0x4f944fb2, 0xcca448b8, 0x3ecd6ab8, 0xa9d5a5bc, 0x8d0119c1, 0x045997d5, - 0xca019dd9, 0x0d526c4d, 0xabf1ba44, 0x66b1ab55, 0x1165f462, 0x3ed7cbad, 0xa38fae6e, 0x3bd2cbad, - 0xd36f0547, 0x20df7840, 0x7a337742, 0x549f8e4b, 0x9062365c, 0xd399f562, 0x2b5274a1, 0x8edfa153, - 0x3bffb347, 0x7074bf58, 0xb74fcbad, 0x5b5a795b, 0x02fa29ce, 0x5a6738d4, 0xe8a1d23e, 0xef98c445, - 0x4b0f494c, 0xa2bc1e56, 0x7694ad63, 0xa4a800c3, 0x05fda6cd, 0x9f22175e, 0x364a795b, 0x536285d5, - 0xac44c9d4, 0x0b06254d, 0x150c2fd4, 0x32a50dcc, 0xfd79ce48, 0xf15cfa53, 0x66c01e60, 0x6bc26661, - 0xc03b47ae, 0x4dda1b81, 0x3285a4c1, 0x883ca96d, 0x35d60a4c, 0xdae09744, 0x2e314d61, 0x84e247cf, - 0x6c814552, 0x3a1cc658, 0x98d8f382, 0xe584cb5b, 0x15e86057, 0x7b01504e, 0xd852dd48, 0x56382f56, - 0x0a5df454, 0xa0d18d18, 0x2e89b148, 0xa79c114c, 0xcbdcd054, 0x5523bc43, 0xa9832640, 0x8a066144, - 0x3894c3bc, 0xab76bf58, 0x6a018ac1, 0xfebf4f43, 0x2f26c658, 0x31102f4e, 0x85e929d5, 0x2a1c175e, - 0xfc6c2cd1, 0x27b04b6d, 0xdf024650, 0x161748b8, 0x28be6580, 0x57be6580, 0x1cee677a, 0xaa6bb742, - 0x9a53964b, 0x0a5a2d4d, 0x2434c658, 0x9a494f57, 0x1ebb0e48, 0xf610b85d, 0x077ecf44, 0x085128bc, - 0x5ba17a18, 0x27ca1b42, 0xf8a00b56, 0xfcd4c257, 0xcf2fc15e, 0xd897e052, 0x4cada04f, 0x2f35f6d5, - 0x382ce8c9, 0xe523984b, 0x3f946846, 0x60c8be43, 0x41da6257, 0xde0be142, 0xae8a544b, 0xeff0c254, - 0x1e0f795b, 0xaeb28890, 0xca16acd9, 0x1e47ddd8, 0x8c8c4829, 0xd27dc747, 0xd53b1663, 0x4096b163, - 0x9c8dd958, 0xcb12f860, 0x9e79305c, 0x40c1a445, 0x4a90c2bc, 0x2c3a464d, 0x2727f23c, 0x30b04b6d, - 0x59024cb8, 0xa091e6ad, 0x31b04b6d, 0xc29d46a6, 0x63934fb2, 0xd9224dbe, 0x9f5910d8, 0x7f530a6b, - 0x752e9c95, 0x65453548, 0xa484be46, 0xce5a1b59, 0x710e0718, 0x46a13d18, 0xdaaf5318, 0xc4a8ff53, - 0x87abaa52, 0xb764cf51, 0xb2025d4a, 0x6d351e41, 0xc035c33e, 0xa432c162, 0x61ef34ae, 0xd16fddbc, - 0x0870e8c1, 0x3070e8c1, 0x9c71e8c1, 0xa4992363, 0x85a1f663, 0x4184e559, 0x18d96ed8, 0x17b8dbd5, - 0x60e7cd18, 0xe5ee104c, 0xab17ac62, 0x1e786e1b, 0x5d23b762, 0xf2388fae, 0x88270360, 0x9e5b3d80, - 0x7da518b2, 0xb5613b45, 0x1ad41f3e, 0xd550854a, 0x8617e9a9, 0x925b229c, 0xf2e92542, 0x47af0544, - 0x73b5a843, 0xb9b7a0ad, 0x03a748d0, 0x0a6ff862, 0x6694df62, 0x3bfac948, 0x8e098f4f, 0x746916c3, - 0x02f38e4f, 0x40bb1243, 0x6a54d162, 0x6008414b, 0xa513794c, 0x514aa343, 0x63781747, 0xdbb6795b, - 0xed065058, 0x42d24b46, 0x1518794c, 0x9b271681, 0x73e4ffad, 0x0654784f, 0x438dc945, 0x641846a6, - 0x2d1b0944, 0x94b59148, 0x8d369558, 0xa5a97662, 0x8b705b42, 0xce9204ae, 0x8d584450, 0x2df61555, - 0xeebff943, 0x2e75fb4d, 0x3ef8fc57, 0x9921135e, 0x8e31042e, 0xb5afad43, 0x89ecedd1, 0x9cfcc047, - 0x8fcd0f4c, 0xbe49f5ad, 0x146a8d45, 0x98669ab8, 0x98d9175e, 0xd1a8e46d, 0x839a3ab8, 0x40a0016c, - 0x6d27c257, 0x977fffad, 0x7baa5d5d, 0x1213be43, 0xb167e5a9, 0x640fe8ca, 0xbc9ea655, 0x0f820a4c, - 0x0f097059, 0x69ac957c, 0x366d8453, 0xb1ba2844, 0x8857f081, 0x70b5be63, 0xc545454b, 0xaf36ded1, - 0xb5a4b052, 0x21f062d1, 0x72ab89b2, 0x74a45318, 0x8312e6bc, 0xb916965f, 0x8aa7c858, 0xfe7effad, + 0x6884ac63, 0x3ffecead, 0x2919b953, 0x0942fe50, 0x7a1d922e, 0xcdd6734a, 0x953a5bb6, 0x2c46922e, + 0xe2a5f143, 0xaa39103a, 0xa06afa5c, 0x135ffd59, 0xe8e82863, 0xf61ef029, 0xf75f042e, 0x2b363532, + 0x29b2df42, 0x16b1f64e, 0xd46e281b, 0x5280bf58, 0x60372229, 0x1be58e4f, 0xa8496f45, 0x1fb1a057, + 0x756b3844, 0x3bb79445, 0x0b375518, 0xcccb0102, 0xb682bf2e, 0x46431c02, 0x3a81073a, 0xa3771f1f, + 0x213a121f, 0x85dc2c1b, 0x56b4323b, 0xb34e8945, 0x3c40b33d, 0xfa276418, 0x1f818d29, 0xebe1e344, + 0xf6160a18, 0xf4fa384a, 0x34b09558, 0xb882b543, 0xe3ce2253, 0x6abf56d8, 0xe91b1155, 0x688ee6ad, + 0x2efc6058, 0x4792cd47, 0x0c32f757, 0x4c813a46, 0x8c93644a, 0x37507444, 0x813ad218, 0xdac06d4a, + 0xe4c63e4b, 0x21a1ea3c, 0x8d88556f, 0x30e9173a, 0x041f681b, 0xdc77ba50, 0xc0072753, 0xceddd44f, + 0x052d1743, 0xe3c77a4a, 0x13981c3a, 0x5685d918, 0x3c0e4e70, 0x3e56fb54, 0xb676ae0c, 0xac93c859, + 0x22279f43, 0x975a4542, 0xe527f071, 0xea162f2e, 0x3c65a32e, 0x5be5713b, 0x961ec418, 0xb202922e, + 0x5ef7be50, 0xce49f53e, 0x05803b47, 0x8463b055, 0x78576153, 0x3ec2ae3a, 0x4bbd7118, 0xafcee043, + 0x56a3e8ba, 0x6174de4d, 0x8d01ba4b, 0xc9af564e, 0xdbc9c547, 0xa627474d, 0xdada9244, 0xd3b3083a, + 0x523e071f, 0xd6b96f18, 0xbd527c46, 0xdf2bbb4d, 0xd37b4a4b, 0x3a6a2158, 0xc064b055, 0x18a8e055, + 0xec4dae3b, 0x0540416c, 0x475b4fbe, 0x064803b2, 0x48e9f062, 0x2898524b, 0xd315ff43, 0xf786d247, + 0xc7ea2f3e, 0xc087f043, 0xc163354b, 0x8250284d, 0xed300029, 0xbf36e05c, 0x8eb3ae4c, 0xe7aa623e, + 0x7ced0274, 0xdd362c1b, 0x362b995a, 0xca26b629, 0x3fc41618, 0xb97b364e, 0xa05b8729, 0x0f5e3c43, + 0xdf942618, 0x6aeb9b5b, 0xbf04762e, 0xfaaeb118, 0x87579958, 0x76520044, 0xc2660c5b, 0x628b201b, + 0xf193932e, 0x1c0ad045, 0xff908346, 0x8da9d4da, 0xed201c1f, 0xa47a2b1b, 0x330007d4, 0x8ba1ed47, + 0xb2f02d44, 0x7db62c1b, 0x781c454b, 0xc0300029, 0xb7062a45, 0x88b52e3a, 0x78dd6b63, 0x1cb9b718, + 0x5d358e47, 0x59912c3b, 0x79607544, 0x5197f759, 0xc023be48, 0xd1013743, 0x0f354057, 0x8e3aac3b, + 0x4114693e, 0x22316318, 0xe27dda50, 0x878eac3b, 0x4948a21f, 0x5db7f24c, 0x8ccb6157, 0x26a5de18, + 0x0a11bd43, 0x27bb1e41, 0x60a7a951, 0x3e16b35e, 0x07888b53, 0x5648a853, 0x0149fe50, 0xd070a34f, + 0x6454c96d, 0xd6e54758, 0xa96dc152, 0x65447861, 0xf6bdf95e, 0x10400202, 0x2c29d483, 0x18174732, + 0x1d840618, 0x12e61818, 0x089d3f3c, 0x917e931f, 0xd1b0c90e, 0x25bd3c42, 0xeb05775b, 0x7d550c59, + 0x6cfacb01, 0xe4224444, 0xa41dd943, 0x0f5aa643, 0x5e33731b, 0x81036d50, 0x6f46a0d1, 0x7731be43, + 0x14840e18, 0xf1e8d059, 0x661d2b1f, 0x40a3201b, 0x9407b843, 0xedf0254d, 0x7bd1a5bc, 0x073dbe51, + 0xe864a97b, 0x2efd947b, 0xb9ca0e45, 0x4e2113ad, 0xcc305731, 0xd39ca63c, 0x733df918, 0xda172b1f, + 0xaa03b34d, 0x7230fd4d, 0xf1ce6e3a, 0x2e9fab43, 0xa4010750, 0xa928bd18, 0x6809be42, 0xb19de348, + 0xff956270, 0x0d795f51, 0xd2dec247, 0x6df5774b, 0xbac11f79, 0xdfb05c75, 0x887683d8, 0xa1e83632, + 0x2c0f7671, 0x28bcb65d, 0xac2a7545, 0x3eebfc60, 0x304ad7c4, 0xa215a462, 0xc86f0f58, 0xcfb92ebe, + 0x5e23ed82, 0xf506184b, 0xec0f19b7, 0x060c59ad, 0x86ee3174, 0x85380774, 0xa199a562, 0x02b507ae, + 0x33eb2163, 0xf2112b1f, 0xb702ba50, 0x131b9618, 0x90ccd04a, 0x08f3273b, 0xecb61718, 0x64b8b44d, + 0x182bf4dc, 0xc7b68286, 0x6e318d5f, 0xfdb03654, 0xb3272e54, 0xe014ad4b, 0x274e4a31, 0x7806375c, + 0xbc34a748, 0x1b5ad94a, 0x6b54d10e, 0x73e2ae6e, 0x5529d483, 0x8455a76d, 0x99c13f47, 0x1d811741, + 0xa9782a78, 0x0b00464d, 0x7266ea50, 0x532dab46, 0x33e1413e, 0x780d0c18, 0x0fb0854e, 0x03370155, + 0x2693042e, 0xfa3d824a, 0x2bb1681b, 0x37ea2a18, 0x7fb8414b, 0x32e0713b, 0xacf38d3f, 0xa282716f, + 0xb1a09d7b, 0xa04b764b, 0x83c94d18, 0x05ee4c6d, 0x0e795f51, 0x46984352, 0xf80fc247, 0x3fccb946, + 0xd7ae244b, 0x0a8e0a4c, 0x57b141bc, 0x3647bed1, 0x1431b052, 0x803a8bbb, 0xfc69056b, 0xf5991862, + 0x14963b2e, 0xd35d5dda, 0xc6c73574, 0xc8f1405b, 0x0ca4224d, 0xecd36071, 0xa9461754, 0xe7a0ed72, + 0x559e8346, 0x1c9beec1, 0xc786ea4a, 0x9561b44d, 0x9788074d, 0x1a69934f, 0x23c5614c, 0x07c79d4b, + 0xc7ee52db, 0xc72df351, 0xcb135e44, 0xa0988346, 0xc211fc4c, 0x87dec34b, 0x1381074d, 0x04a65cb7, + 0x4409083a, 0x4a407a4c, 0x92b8d37d, 0xacf50b4d, 0xa58aa5bc, 0x448f801f, 0x9c83762e, 0x6fd5734a, + 0xfe2d454b, 0x84144c55, 0x05190e4c, 0xb2151448, 0x63867a3e, 0x16099018, 0x9c010d3c, 0x962d8f3d, + 0xd51ee453, 0x9d86801f, 0x68e87b47, 0x6bf7bb73, 0x5fc7910e, 0x10d90118, 0x3db04442, 0x729d3e4b, + 0xc397d842, 0x57bb15ad, 0x72f31f4e, 0xc9380043, 0x2bb24e18, 0xd9b8ab50, 0xb786801f, 0xf4dc4847, + 0x85f4bb51, 0x4435995b, 0x5ba07e40, 0x2c57392e, 0x3628124b, 0x9839b64b, 0x6fe8b24d, 0xaddce847, + 0x75260e45, 0x0c572a43, 0xfea21902, 0xb9f9742e, 0x5a70d443, 0x8fc5910e, 0x868d4744, 0x56245e02, + 0xd7eb5f02, 0x35c12c1b, 0x4373034b, 0x8786554c, 0xa6facf18, 0x4b11a31f, 0x3570664e, 0x5a64bc42, + 0x0b03983f, 0x8f457e4c, 0x0fd874c3, 0xb6cf31b2, 0x2bbc2d4e, 0x146ca5b2, 0x9d00b150, 0x048a4153, + 0xca4dcd43, 0xc1607cca, 0x8234cf57, 0x9c7daead, 0x3dc07658, 0xea5c6e4c, 0xf1a0084e, 0x16d2ee53, + 0x1b849418, 0xfe913a47, 0x1e988f62, 0x208b644c, 0xc55ee980, 0xbdbce747, 0xf59a384e, 0x0f56091b, + 0x7417b745, 0x0c37344e, 0x2c62ab47, 0xf8533a4d, 0x8030084d, 0x76b93c4b, 0xda6ea0ad, 0x3c54f618, + 0x63b0de1f, 0x7370d858, 0x1a70bb4c, 0xdda63b2e, 0x60b2ba50, 0x1ba7d048, 0xbe1b2c1b, 0xabea5747, + 0x29ad2e4d, 0xe8cd7642, 0x66c80e18, 0x138bf34a, 0xc6145e44, 0x2586794c, 0x07bc5478, 0x0da0b14d, + 0x8f95354e, 0x9eb11c62, 0xa1545e46, 0x2e7a2602, 0x408c9c3d, 0x59065d55, 0xf51d1a4c, 0x3bbc6a4e, + 0xc71b2a2e, 0xcdaaa545, 0x17d659d0, 0x5202e7ad, 0xf1b68445, 0x93375961, 0xbd88a043, 0x066ad655, + 0x890f6318, 0x7b7dca47, 0x99bdd662, 0x3bb4fc53, 0x1231efdc, 0xc0a99444, 0x96bbea47, 0x61ed8748, + 0x27dfa73b, 0x8d4d1754, 0x3460042e, 0x551f0c4c, 0x8d0e0718, 0x162ddc53, 0x53231718, 0x1ecd65d0, + 0x944d28bc, 0x3b79d058, 0xaff97fbc, 0x4860006c, 0xc101c90e, 0xace41743, 0xa5975d4c, 0x5cc2703e, + 0xb55a4450, 0x02d18840, 0xee2765ae, 0xd6012fd5, 0x24c94d7d, 0x8c6eec47, 0x7520ba5d, 0x9e15e460, + 0x8510b04c, 0x75ec3847, 0x1dfa6661, 0xe172b3ad, 0x5744c90e, 0x52a0a152, 0x8d6fad18, 0x67b74b6d, + 0x93a089b2, 0x0f3ac5d5, 0xe5de1855, 0x43d25747, 0x4bad804a, 0x55b408d8, 0x60a36441, 0xf553e860, + 0xdb2fa2c8, 0x03152b32, 0xdd27a7d5, 0x3116a8b8, 0x0a1d708c, 0xeee2f13c, 0x6acf436f, 0xce6eb4ca, + 0x101cd3d9, 0x1c48a6b8, 0xe57d6f44, 0x93dcf562, }; @@ -1328,7 +1355,6 @@ void ThreadOpenConnections2(void* parg) CRITICAL_BLOCK(cs_mapAddresses) { // Add seed nodes if IRC isn't working - static bool fSeedUsed; bool fTOR = (fUseProxy && addrProxy.port == htons(9050)); if (mapAddresses.empty() && (GetTime() - nStart > 60 || fTOR) && !fTestNet) { @@ -1336,40 +1362,14 @@ void ThreadOpenConnections2(void* parg) { // It'll only connect to one or two seed nodes because once it connects, // it'll get a pile of addresses with newer timestamps. + // Seed nodes are given a random 'last seen time' of between one and two + // weeks ago. + const int64 nOneWeek = 7*24*60*60; CAddress addr; addr.ip = pnSeed[i]; - addr.nTime = 0; + addr.nTime = GetTime()-GetRand(nOneWeek)-nOneWeek; AddAddress(addr); } - fSeedUsed = true; - } - - if (fSeedUsed && mapAddresses.size() > ARRAYLEN(pnSeed) + 100) - { - // Disconnect seed nodes - set<unsigned int> setSeed(pnSeed, pnSeed + ARRAYLEN(pnSeed)); - static int64 nSeedDisconnected; - if (nSeedDisconnected == 0) - { - nSeedDisconnected = GetTime(); - CRITICAL_BLOCK(cs_vNodes) - BOOST_FOREACH(CNode* pnode, vNodes) - if (setSeed.count(pnode->addr.ip)) - pnode->fDisconnect = true; - } - - // Keep setting timestamps to 0 so they won't reconnect - if (GetTime() - nSeedDisconnected < 60 * 60) - { - BOOST_FOREACH(PAIRTYPE(const vector<unsigned char>, CAddress)& item, mapAddresses) - { - if (setSeed.count(item.second.ip) && item.second.nTime != 0) - { - item.second.nTime = 0; - CAddrDB().WriteAddress(item.second); - } - } - } } } @@ -1579,7 +1579,7 @@ bool BindListenPort(string& strError) return false; } -#ifdef BSD +#ifdef SO_NOSIGPIPE // Different way of disabling SIGPIPE on BSD setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int)); #endif @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_NET_H @@ -6,16 +7,16 @@ #include <deque> #include <boost/array.hpp> +#include <boost/foreach.hpp> #include <openssl/rand.h> #ifndef __WXMSW__ #include <arpa/inet.h> #endif -class CMessageHeader; -class CAddress; +#include "protocol.h" + class CAddrDB; -class CInv; class CRequestTracker; class CNode; class CBlockIndex; @@ -26,15 +27,7 @@ extern int nConnectTimeout; inline unsigned int ReceiveBufferSize() { return 1000*GetArg("-maxreceivebuffer", 10*1000); } inline unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 10*1000); } -inline unsigned short GetDefaultPort() { return fTestNet ? 18333 : 8333; } static const unsigned int PUBLISH_HOPS = 5; -enum -{ - NODE_NETWORK = (1 << 0), -}; - - - bool ConnectSocket(const CAddress& addrConnect, SOCKET& hSocketRet, int nTimeout=nConnectTimeout); bool Lookup(const char *pszName, std::vector<CAddress>& vaddr, int nServices, int nMaxSolutions, bool fAllowLookup = false, int portDefault = 0, bool fAllowPort = false); @@ -52,402 +45,12 @@ bool BindListenPort(std::string& strError=REF(std::string())); void StartNode(void* parg); bool StopNode(); - - - - - - - -// -// Message header -// (4) message start -// (12) command -// (4) size -// (4) checksum - -extern char pchMessageStart[4]; - -class CMessageHeader -{ -public: - enum { COMMAND_SIZE=12 }; - char pchMessageStart[sizeof(::pchMessageStart)]; - char pchCommand[COMMAND_SIZE]; - unsigned int nMessageSize; - unsigned int nChecksum; - - CMessageHeader() - { - memcpy(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart)); - memset(pchCommand, 0, sizeof(pchCommand)); - pchCommand[1] = 1; - nMessageSize = -1; - nChecksum = 0; - } - - CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn) - { - memcpy(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart)); - strncpy(pchCommand, pszCommand, COMMAND_SIZE); - nMessageSize = nMessageSizeIn; - nChecksum = 0; - } - - IMPLEMENT_SERIALIZE - ( - READWRITE(FLATDATA(pchMessageStart)); - READWRITE(FLATDATA(pchCommand)); - READWRITE(nMessageSize); - if (nVersion >= 209) - READWRITE(nChecksum); - ) - - std::string GetCommand() - { - if (pchCommand[COMMAND_SIZE-1] == 0) - return std::string(pchCommand, pchCommand + strlen(pchCommand)); - else - return std::string(pchCommand, pchCommand + COMMAND_SIZE); - } - - bool IsValid() - { - // Check start string - if (memcmp(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart)) != 0) - return false; - - // Check the command string for errors - for (char* p1 = pchCommand; p1 < pchCommand + COMMAND_SIZE; p1++) - { - if (*p1 == 0) - { - // Must be all zeros after the first zero - for (; p1 < pchCommand + COMMAND_SIZE; p1++) - if (*p1 != 0) - return false; - } - else if (*p1 < ' ' || *p1 > 0x7E) - return false; - } - - // Message size - if (nMessageSize > MAX_SIZE) - { - printf("CMessageHeader::IsValid() : (%s, %u bytes) nMessageSize > MAX_SIZE\n", GetCommand().c_str(), nMessageSize); - return false; - } - - return true; - } -}; - - - - - - -static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff }; - -class CAddress -{ -public: - uint64 nServices; - unsigned char pchReserved[12]; - unsigned int ip; - unsigned short port; - - // disk and network only - unsigned int nTime; - - // memory only - unsigned int nLastTry; - - CAddress() - { - Init(); - } - - CAddress(unsigned int ipIn, unsigned short portIn=0, uint64 nServicesIn=NODE_NETWORK) - { - Init(); - ip = ipIn; - port = htons(portIn == 0 ? GetDefaultPort() : portIn); - nServices = nServicesIn; - } - - explicit CAddress(const struct sockaddr_in& sockaddr, uint64 nServicesIn=NODE_NETWORK) - { - Init(); - ip = sockaddr.sin_addr.s_addr; - port = sockaddr.sin_port; - nServices = nServicesIn; - } - - explicit CAddress(const char* pszIn, int portIn, bool fNameLookup = false, uint64 nServicesIn=NODE_NETWORK) - { - Init(); - Lookup(pszIn, *this, nServicesIn, fNameLookup, portIn); - } - - explicit CAddress(const char* pszIn, bool fNameLookup = false, uint64 nServicesIn=NODE_NETWORK) - { - Init(); - Lookup(pszIn, *this, nServicesIn, fNameLookup, 0, true); - } - - explicit CAddress(std::string strIn, int portIn, bool fNameLookup = false, uint64 nServicesIn=NODE_NETWORK) - { - Init(); - Lookup(strIn.c_str(), *this, nServicesIn, fNameLookup, portIn); - } - - explicit CAddress(std::string strIn, bool fNameLookup = false, uint64 nServicesIn=NODE_NETWORK) - { - Init(); - Lookup(strIn.c_str(), *this, nServicesIn, fNameLookup, 0, true); - } - - void Init() - { - nServices = NODE_NETWORK; - memcpy(pchReserved, pchIPv4, sizeof(pchReserved)); - ip = INADDR_NONE; - port = htons(GetDefaultPort()); - nTime = 100000000; - nLastTry = 0; - } - - IMPLEMENT_SERIALIZE - ( - if (fRead) - const_cast<CAddress*>(this)->Init(); - if (nType & SER_DISK) - READWRITE(nVersion); - if ((nType & SER_DISK) || (nVersion >= 31402 && !(nType & SER_GETHASH))) - READWRITE(nTime); - READWRITE(nServices); - READWRITE(FLATDATA(pchReserved)); // for IPv6 - READWRITE(ip); - READWRITE(port); - ) - - friend inline bool operator==(const CAddress& a, const CAddress& b) - { - return (memcmp(a.pchReserved, b.pchReserved, sizeof(a.pchReserved)) == 0 && - a.ip == b.ip && - a.port == b.port); - } - - friend inline bool operator!=(const CAddress& a, const CAddress& b) - { - return (!(a == b)); - } - - friend inline bool operator<(const CAddress& a, const CAddress& b) - { - int ret = memcmp(a.pchReserved, b.pchReserved, sizeof(a.pchReserved)); - if (ret < 0) - return true; - else if (ret == 0) - { - if (ntohl(a.ip) < ntohl(b.ip)) - return true; - else if (a.ip == b.ip) - return ntohs(a.port) < ntohs(b.port); - } - return false; - } - - std::vector<unsigned char> GetKey() const - { - CDataStream ss; - ss.reserve(18); - ss << FLATDATA(pchReserved) << ip << port; - - #if defined(_MSC_VER) && _MSC_VER < 1300 - return std::vector<unsigned char>((unsigned char*)&ss.begin()[0], (unsigned char*)&ss.end()[0]); - #else - return std::vector<unsigned char>(ss.begin(), ss.end()); - #endif - } - - struct sockaddr_in GetSockAddr() const - { - struct sockaddr_in sockaddr; - memset(&sockaddr, 0, sizeof(sockaddr)); - sockaddr.sin_family = AF_INET; - sockaddr.sin_addr.s_addr = ip; - sockaddr.sin_port = port; - return sockaddr; - } - - bool IsIPv4() const - { - return (memcmp(pchReserved, pchIPv4, sizeof(pchIPv4)) == 0); - } - - bool IsRFC1918() const - { - return IsIPv4() && (GetByte(3) == 10 || - (GetByte(3) == 192 && GetByte(2) == 168) || - (GetByte(3) == 172 && - (GetByte(2) >= 16 && GetByte(2) <= 31))); - } - - bool IsRFC3927() const - { - return IsIPv4() && (GetByte(3) == 169 && GetByte(2) == 254); - } - - bool IsLocal() const - { - return IsIPv4() && (GetByte(3) == 127 || - GetByte(3) == 0); - } - - bool IsRoutable() const - { - return IsValid() && - !(IsRFC1918() || IsRFC3927() || IsLocal()); - } - - bool IsValid() const - { - // Clean up 3-byte shifted addresses caused by garbage in size field - // of addr messages from versions before 0.2.9 checksum. - // Two consecutive addr messages look like this: - // header20 vectorlen3 addr26 addr26 addr26 header20 vectorlen3 addr26 addr26 addr26... - // so if the first length field is garbled, it reads the second batch - // of addr misaligned by 3 bytes. - if (memcmp(pchReserved, pchIPv4+3, sizeof(pchIPv4)-3) == 0) - return false; - - return (ip != 0 && ip != INADDR_NONE && port != htons(USHRT_MAX)); - } - - unsigned char GetByte(int n) const - { - return ((unsigned char*)&ip)[3-n]; - } - - std::string ToStringIPPort() const - { - return strprintf("%u.%u.%u.%u:%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0), ntohs(port)); - } - - std::string ToStringIP() const - { - return strprintf("%u.%u.%u.%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0)); - } - - std::string ToStringPort() const - { - return strprintf("%u", ntohs(port)); - } - - std::string ToString() const - { - return strprintf("%u.%u.%u.%u:%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0), ntohs(port)); - } - - void print() const - { - printf("CAddress(%s)\n", ToString().c_str()); - } -}; - - - - - - - enum { MSG_TX = 1, MSG_BLOCK, }; -static const char* ppszTypeName[] = -{ - "ERROR", - "tx", - "block", -}; - -class CInv -{ -public: - int type; - uint256 hash; - - CInv() - { - type = 0; - hash = 0; - } - - CInv(int typeIn, const uint256& hashIn) - { - type = typeIn; - hash = hashIn; - } - - CInv(const std::string& strType, const uint256& hashIn) - { - int i; - for (i = 1; i < ARRAYLEN(ppszTypeName); i++) - { - if (strType == ppszTypeName[i]) - { - type = i; - break; - } - } - if (i == ARRAYLEN(ppszTypeName)) - throw std::out_of_range(strprintf("CInv::CInv(string, uint256) : unknown type '%s'", strType.c_str())); - hash = hashIn; - } - - IMPLEMENT_SERIALIZE - ( - READWRITE(type); - READWRITE(hash); - ) - - friend inline bool operator<(const CInv& a, const CInv& b) - { - return (a.type < b.type || (a.type == b.type && a.hash < b.hash)); - } - - bool IsKnownType() const - { - return (type >= 1 && type < ARRAYLEN(ppszTypeName)); - } - - const char* GetCommand() const - { - if (!IsKnownType()) - throw std::out_of_range(strprintf("CInv::GetCommand() : type=%d unknown type", type)); - return ppszTypeName[type]; - } - - std::string ToString() const - { - return strprintf("%s %s", GetCommand(), hash.ToString().substr(0,20).c_str()); - } - - void print() const - { - printf("CInv(%s)\n", ToString().c_str()); - } -}; - - - - - class CRequestTracker { public: @@ -474,10 +77,8 @@ extern bool fClient; extern bool fAllowDNS; extern uint64 nLocalServices; extern CAddress addrLocalHost; -extern CNode* pnodeLocalHost; extern uint64 nLocalHostNonce; extern boost::array<int, 10> vnThreadsRunning; -extern SOCKET hListenSocket; extern std::vector<CNode*> vNodes; extern CCriticalSection cs_vNodes; @@ -675,7 +276,7 @@ public: void BeginMessage(const char* pszCommand) { - cs_vSend.Enter(); + cs_vSend.Enter("cs_vSend", __FILE__, __LINE__); if (nHeaderStart != -1) AbortMessage(); nHeaderStart = vSend.size(); diff --git a/src/noui.h b/src/noui.h index d0072df7f2..cbe6fa4c7b 100644 --- a/src/noui.h +++ b/src/noui.h @@ -1,4 +1,5 @@ // Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_NOUI_H diff --git a/src/protocol.cpp b/src/protocol.cpp new file mode 100644 index 0000000000..48784b9cfb --- /dev/null +++ b/src/protocol.cpp @@ -0,0 +1,312 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file license.txt or http://www.opensource.org/licenses/mit-license.php. + +#include "protocol.h" +#include "util.h" + +#ifndef __WXMSW__ +# include <arpa/inet.h> +#endif + +// Prototypes from net.h, but that header (currently) stinks, can't #include it without breaking things +bool Lookup(const char *pszName, std::vector<CAddress>& vaddr, int nServices, int nMaxSolutions, bool fAllowLookup = false, int portDefault = 0, bool fAllowPort = false); +bool Lookup(const char *pszName, CAddress& addr, int nServices, bool fAllowLookup = false, int portDefault = 0, bool fAllowPort = false); + +static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff }; +static const char* ppszTypeName[] = +{ + "ERROR", + "tx", + "block", +}; + +CMessageHeader::CMessageHeader() +{ + memcpy(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart)); + memset(pchCommand, 0, sizeof(pchCommand)); + pchCommand[1] = 1; + nMessageSize = -1; + nChecksum = 0; +} + +CMessageHeader::CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn) +{ + memcpy(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart)); + strncpy(pchCommand, pszCommand, COMMAND_SIZE); + nMessageSize = nMessageSizeIn; + nChecksum = 0; +} + +std::string CMessageHeader::GetCommand() const +{ + if (pchCommand[COMMAND_SIZE-1] == 0) + return std::string(pchCommand, pchCommand + strlen(pchCommand)); + else + return std::string(pchCommand, pchCommand + COMMAND_SIZE); +} + +bool CMessageHeader::IsValid() const +{ + // Check start string + if (memcmp(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart)) != 0) + return false; + + // Check the command string for errors + for (const char* p1 = pchCommand; p1 < pchCommand + COMMAND_SIZE; p1++) + { + if (*p1 == 0) + { + // Must be all zeros after the first zero + for (; p1 < pchCommand + COMMAND_SIZE; p1++) + if (*p1 != 0) + return false; + } + else if (*p1 < ' ' || *p1 > 0x7E) + return false; + } + + // Message size + if (nMessageSize > MAX_SIZE) + { + printf("CMessageHeader::IsValid() : (%s, %u bytes) nMessageSize > MAX_SIZE\n", GetCommand().c_str(), nMessageSize); + return false; + } + + return true; +} + +CAddress::CAddress() +{ + Init(); +} + +CAddress::CAddress(unsigned int ipIn, unsigned short portIn, uint64 nServicesIn) +{ + Init(); + ip = ipIn; + port = htons(portIn == 0 ? GetDefaultPort() : portIn); + nServices = nServicesIn; +} + +CAddress::CAddress(const struct sockaddr_in& sockaddr, uint64 nServicesIn) +{ + Init(); + ip = sockaddr.sin_addr.s_addr; + port = sockaddr.sin_port; + nServices = nServicesIn; +} + +CAddress::CAddress(const char* pszIn, int portIn, bool fNameLookup, uint64 nServicesIn) +{ + Init(); + Lookup(pszIn, *this, nServicesIn, fNameLookup, portIn); +} + +CAddress::CAddress(const char* pszIn, bool fNameLookup, uint64 nServicesIn) +{ + Init(); + Lookup(pszIn, *this, nServicesIn, fNameLookup, 0, true); +} + +CAddress::CAddress(std::string strIn, int portIn, bool fNameLookup, uint64 nServicesIn) +{ + Init(); + Lookup(strIn.c_str(), *this, nServicesIn, fNameLookup, portIn); +} + +CAddress::CAddress(std::string strIn, bool fNameLookup, uint64 nServicesIn) +{ + Init(); + Lookup(strIn.c_str(), *this, nServicesIn, fNameLookup, 0, true); +} + +void CAddress::Init() +{ + nServices = NODE_NETWORK; + memcpy(pchReserved, pchIPv4, sizeof(pchReserved)); + ip = INADDR_NONE; + port = htons(GetDefaultPort()); + nTime = 100000000; + nLastTry = 0; +} + +bool operator==(const CAddress& a, const CAddress& b) +{ + return (memcmp(a.pchReserved, b.pchReserved, sizeof(a.pchReserved)) == 0 && + a.ip == b.ip && + a.port == b.port); +} + +bool operator!=(const CAddress& a, const CAddress& b) +{ + return (!(a == b)); +} + +bool operator<(const CAddress& a, const CAddress& b) +{ + int ret = memcmp(a.pchReserved, b.pchReserved, sizeof(a.pchReserved)); + if (ret < 0) + return true; + else if (ret == 0) + { + if (ntohl(a.ip) < ntohl(b.ip)) + return true; + else if (a.ip == b.ip) + return ntohs(a.port) < ntohs(b.port); + } + return false; +} + +std::vector<unsigned char> CAddress::GetKey() const +{ + CDataStream ss; + ss.reserve(18); + ss << FLATDATA(pchReserved) << ip << port; + + #if defined(_MSC_VER) && _MSC_VER < 1300 + return std::vector<unsigned char>((unsigned char*)&ss.begin()[0], (unsigned char*)&ss.end()[0]); + #else + return std::vector<unsigned char>(ss.begin(), ss.end()); + #endif +} + +struct sockaddr_in CAddress::GetSockAddr() const +{ + struct sockaddr_in sockaddr; + memset(&sockaddr, 0, sizeof(sockaddr)); + sockaddr.sin_family = AF_INET; + sockaddr.sin_addr.s_addr = ip; + sockaddr.sin_port = port; + return sockaddr; +} + +bool CAddress::IsIPv4() const +{ + return (memcmp(pchReserved, pchIPv4, sizeof(pchIPv4)) == 0); +} + +bool CAddress::IsRFC1918() const +{ + return IsIPv4() && (GetByte(3) == 10 || + (GetByte(3) == 192 && GetByte(2) == 168) || + (GetByte(3) == 172 && + (GetByte(2) >= 16 && GetByte(2) <= 31))); +} + +bool CAddress::IsRFC3927() const +{ + return IsIPv4() && (GetByte(3) == 169 && GetByte(2) == 254); +} + +bool CAddress::IsLocal() const +{ + return IsIPv4() && (GetByte(3) == 127 || + GetByte(3) == 0); +} + +bool CAddress::IsRoutable() const +{ + return IsValid() && + !(IsRFC1918() || IsRFC3927() || IsLocal()); +} + +bool CAddress::IsValid() const +{ + // Clean up 3-byte shifted addresses caused by garbage in size field + // of addr messages from versions before 0.2.9 checksum. + // Two consecutive addr messages look like this: + // header20 vectorlen3 addr26 addr26 addr26 header20 vectorlen3 addr26 addr26 addr26... + // so if the first length field is garbled, it reads the second batch + // of addr misaligned by 3 bytes. + if (memcmp(pchReserved, pchIPv4+3, sizeof(pchIPv4)-3) == 0) + return false; + + return (ip != 0 && ip != INADDR_NONE && port != htons(USHRT_MAX)); +} + +unsigned char CAddress::GetByte(int n) const +{ + return ((unsigned char*)&ip)[3-n]; +} + +std::string CAddress::ToStringIPPort() const +{ + return strprintf("%u.%u.%u.%u:%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0), ntohs(port)); +} + +std::string CAddress::ToStringIP() const +{ + return strprintf("%u.%u.%u.%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0)); +} + +std::string CAddress::ToStringPort() const +{ + return strprintf("%u", ntohs(port)); +} + +std::string CAddress::ToString() const +{ + return strprintf("%u.%u.%u.%u:%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0), ntohs(port)); +} + +void CAddress::print() const +{ + printf("CAddress(%s)\n", ToString().c_str()); +} + +CInv::CInv() +{ + type = 0; + hash = 0; +} + +CInv::CInv(int typeIn, const uint256& hashIn) +{ + type = typeIn; + hash = hashIn; +} + +CInv::CInv(const std::string& strType, const uint256& hashIn) +{ + int i; + for (i = 1; i < ARRAYLEN(ppszTypeName); i++) + { + if (strType == ppszTypeName[i]) + { + type = i; + break; + } + } + if (i == ARRAYLEN(ppszTypeName)) + throw std::out_of_range(strprintf("CInv::CInv(string, uint256) : unknown type '%s'", strType.c_str())); + hash = hashIn; +} + +bool operator<(const CInv& a, const CInv& b) +{ + return (a.type < b.type || (a.type == b.type && a.hash < b.hash)); +} + +bool CInv::IsKnownType() const +{ + return (type >= 1 && type < ARRAYLEN(ppszTypeName)); +} + +const char* CInv::GetCommand() const +{ + if (!IsKnownType()) + throw std::out_of_range(strprintf("CInv::GetCommand() : type=%d unknown type", type)); + return ppszTypeName[type]; +} + +std::string CInv::ToString() const +{ + return strprintf("%s %s", GetCommand(), hash.ToString().substr(0,20).c_str()); +} + +void CInv::print() const +{ + printf("CInv(%s)\n", ToString().c_str()); +} diff --git a/src/protocol.h b/src/protocol.h new file mode 100644 index 0000000000..53d3eef4d5 --- /dev/null +++ b/src/protocol.h @@ -0,0 +1,150 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file license.txt or http://www.opensource.org/licenses/mit-license.php. + +#ifndef __cplusplus +# error This header can only be compiled as C++. +#endif + +#ifndef __INCLUDED_PROTOCOL_H__ +#define __INCLUDED_PROTOCOL_H__ + +#include "serialize.h" +#include <string> +#include "uint256.h" + +extern bool fTestNet; +static inline unsigned short GetDefaultPort(const bool testnet = fTestNet) +{ + return testnet ? 18333 : 8333; +} + +// +// Message header +// (4) message start +// (12) command +// (4) size +// (4) checksum + +extern unsigned char pchMessageStart[4]; + +class CMessageHeader +{ + public: + CMessageHeader(); + CMessageHeader(const char* pszCommand, unsigned int nMessageSizeIn); + + std::string GetCommand() const; + bool IsValid() const; + + IMPLEMENT_SERIALIZE + ( + READWRITE(FLATDATA(pchMessageStart)); + READWRITE(FLATDATA(pchCommand)); + READWRITE(nMessageSize); + if (nVersion >= 209) + READWRITE(nChecksum); + ) + + // TODO: make private (improves encapsulation) + public: + enum { COMMAND_SIZE=12 }; + char pchMessageStart[sizeof(::pchMessageStart)]; + char pchCommand[COMMAND_SIZE]; + unsigned int nMessageSize; + unsigned int nChecksum; +}; + +enum +{ + NODE_NETWORK = (1 << 0), +}; + +class CAddress +{ + public: + CAddress(); + CAddress(unsigned int ipIn, unsigned short portIn=0, uint64 nServicesIn=NODE_NETWORK); + explicit CAddress(const struct sockaddr_in& sockaddr, uint64 nServicesIn=NODE_NETWORK); + explicit CAddress(const char* pszIn, int portIn, bool fNameLookup = false, uint64 nServicesIn=NODE_NETWORK); + explicit CAddress(const char* pszIn, bool fNameLookup = false, uint64 nServicesIn=NODE_NETWORK); + explicit CAddress(std::string strIn, int portIn, bool fNameLookup = false, uint64 nServicesIn=NODE_NETWORK); + explicit CAddress(std::string strIn, bool fNameLookup = false, uint64 nServicesIn=NODE_NETWORK); + + void Init(); + + IMPLEMENT_SERIALIZE + ( + if (fRead) + const_cast<CAddress*>(this)->Init(); + if (nType & SER_DISK) + READWRITE(nVersion); + if ((nType & SER_DISK) || (nVersion >= 31402 && !(nType & SER_GETHASH))) + READWRITE(nTime); + READWRITE(nServices); + READWRITE(FLATDATA(pchReserved)); // for IPv6 + READWRITE(ip); + READWRITE(port); + ) + + friend bool operator==(const CAddress& a, const CAddress& b); + friend bool operator!=(const CAddress& a, const CAddress& b); + friend bool operator<(const CAddress& a, const CAddress& b); + + std::vector<unsigned char> GetKey() const; + struct sockaddr_in GetSockAddr() const; + bool IsIPv4() const; + bool IsRFC1918() const; + bool IsRFC3927() const; + bool IsLocal() const; + bool IsRoutable() const; + bool IsValid() const; + unsigned char GetByte(int n) const; + std::string ToStringIPPort() const; + std::string ToStringIP() const; + std::string ToStringPort() const; + std::string ToString() const; + void print() const; + + // TODO: make private (improves encapsulation) + public: + uint64 nServices; + unsigned char pchReserved[12]; + unsigned int ip; + unsigned short port; + + // disk and network only + unsigned int nTime; + + // memory only + unsigned int nLastTry; +}; + +class CInv +{ + public: + CInv(); + CInv(int typeIn, const uint256& hashIn); + CInv(const std::string& strType, const uint256& hashIn); + + IMPLEMENT_SERIALIZE + ( + READWRITE(type); + READWRITE(hash); + ) + + friend bool operator<(const CInv& a, const CInv& b); + + bool IsKnownType() const; + const char* GetCommand() const; + std::string ToString() const; + void print() const; + + // TODO: make private (improves encapsulation) + public: + int type; + uint256 hash; +}; + +#endif // __INCLUDED_PROTOCOL_H__ diff --git a/src/rpc.cpp b/src/rpc.cpp index a4deece6b2..885ffd1f2b 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. @@ -330,71 +331,59 @@ Value getnewaddress(const Array& params, bool fHelp) "If [account] is specified (recommended), it is added to the address book " "so payments received with the address will be credited to [account]."); - if (!pwalletMain->IsLocked()) - pwalletMain->TopUpKeyPool(); - - if (pwalletMain->GetKeyPoolSize() < 1) - throw JSONRPCError(-12, "Error: Keypool ran out, please call keypoolrefill first"); - // Parse the account first so we don't generate a key if there's an error string strAccount; if (params.size() > 0) strAccount = AccountFromValue(params[0]); + if (!pwalletMain->IsLocked()) + pwalletMain->TopUpKeyPool(); + // Generate a new key that is added to wallet - CBitcoinAddress address(pwalletMain->GetOrReuseKeyFromPool()); + std::vector<unsigned char> newKey; + if (!pwalletMain->GetKeyFromPool(newKey, false)) + throw JSONRPCError(-12, "Error: Keypool ran out, please call keypoolrefill first"); + CBitcoinAddress address(newKey); - // This could be done in the same main CS as GetKeyFromKeyPool. - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) - pwalletMain->SetAddressBookName(address, strAccount); + pwalletMain->SetAddressBookName(address, strAccount); return address.ToString(); } -// requires cs_main, cs_mapWallet, cs_mapAddressBook locks CBitcoinAddress GetAccountAddress(string strAccount, bool bForceNew=false) { CWalletDB walletdb(pwalletMain->strWalletFile); CAccount account; - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) - { - walletdb.ReadAccount(strAccount, account); + walletdb.ReadAccount(strAccount, account); - bool bKeyUsed = false; + bool bKeyUsed = false; - // Check if the current key has been used - if (!account.vchPubKey.empty()) + // Check if the current key has been used + if (!account.vchPubKey.empty()) + { + CScript scriptPubKey; + scriptPubKey.SetBitcoinAddress(account.vchPubKey); + for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); + it != pwalletMain->mapWallet.end() && !account.vchPubKey.empty(); + ++it) { - CScript scriptPubKey; - scriptPubKey.SetBitcoinAddress(account.vchPubKey); - for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); - it != pwalletMain->mapWallet.end() && !account.vchPubKey.empty(); - ++it) - { - const CWalletTx& wtx = (*it).second; - BOOST_FOREACH(const CTxOut& txout, wtx.vout) - if (txout.scriptPubKey == scriptPubKey) - bKeyUsed = true; - } + const CWalletTx& wtx = (*it).second; + BOOST_FOREACH(const CTxOut& txout, wtx.vout) + if (txout.scriptPubKey == scriptPubKey) + bKeyUsed = true; } + } - // Generate a new key - if (account.vchPubKey.empty() || bForceNew || bKeyUsed) - { - if (pwalletMain->GetKeyPoolSize() < 1) - { - if (bKeyUsed || bForceNew) - throw JSONRPCError(-12, "Error: Keypool ran out, please call topupkeypool first"); - } - else - { - account.vchPubKey = pwalletMain->GetOrReuseKeyFromPool(); - pwalletMain->SetAddressBookName(CBitcoinAddress(account.vchPubKey), strAccount); - walletdb.WriteAccount(strAccount, account); - } - } + // Generate a new key + if (account.vchPubKey.empty() || bForceNew || bKeyUsed) + { + if (!pwalletMain->GetKeyFromPool(account.vchPubKey, false)) + throw JSONRPCError(-12, "Error: Keypool ran out, please call keypoolrefill first"); + + pwalletMain->SetAddressBookName(CBitcoinAddress(account.vchPubKey), strAccount); + walletdb.WriteAccount(strAccount, account); } return CBitcoinAddress(account.vchPubKey); @@ -412,12 +401,7 @@ Value getaccountaddress(const Array& params, bool fHelp) Value ret; - CRITICAL_BLOCK(cs_main) - CRITICAL_BLOCK(pwalletMain->cs_mapWallet) - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) - { - ret = GetAccountAddress(strAccount).ToString(); - } + ret = GetAccountAddress(strAccount).ToString(); return ret; } @@ -441,20 +425,15 @@ Value setaccount(const Array& params, bool fHelp) strAccount = AccountFromValue(params[1]); // Detect when changing the account of an address that is the 'unused current key' of another account: - CRITICAL_BLOCK(cs_main) - CRITICAL_BLOCK(pwalletMain->cs_mapWallet) - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) + if (pwalletMain->mapAddressBook.count(address)) { - if (pwalletMain->mapAddressBook.count(address)) - { - string strOldAccount = pwalletMain->mapAddressBook[address]; - if (address == GetAccountAddress(strOldAccount)) - GetAccountAddress(strOldAccount, true); - } - - pwalletMain->SetAddressBookName(address, strAccount); + string strOldAccount = pwalletMain->mapAddressBook[address]; + if (address == GetAccountAddress(strOldAccount)) + GetAccountAddress(strOldAccount, true); } + pwalletMain->SetAddressBookName(address, strAccount); + return Value::null; } @@ -471,12 +450,9 @@ Value getaccount(const Array& params, bool fHelp) throw JSONRPCError(-5, "Invalid bitcoin address"); string strAccount; - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) - { - map<CBitcoinAddress, string>::iterator mi = pwalletMain->mapAddressBook.find(address); - if (mi != pwalletMain->mapAddressBook.end() && !(*mi).second.empty()) - strAccount = (*mi).second; - } + map<CBitcoinAddress, string>::iterator mi = pwalletMain->mapAddressBook.find(address); + if (mi != pwalletMain->mapAddressBook.end() && !(*mi).second.empty()) + strAccount = (*mi).second; return strAccount; } @@ -492,15 +468,12 @@ Value getaddressesbyaccount(const Array& params, bool fHelp) // Find all addresses that have the given account Array ret; - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) + BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& item, pwalletMain->mapAddressBook) { - BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& item, pwalletMain->mapAddressBook) - { - const CBitcoinAddress& address = item.first; - const string& strName = item.second; - if (strName == strAccount) - ret.push_back(address.ToString()); - } + const CBitcoinAddress& address = item.first; + const string& strName = item.second; + if (strName == strAccount) + ret.push_back(address.ToString()); } return ret; } @@ -547,16 +520,12 @@ Value sendtoaddress(const Array& params, bool fHelp) if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty()) wtx.mapValue["to"] = params[3].get_str(); - CRITICAL_BLOCK(cs_main) - CRITICAL_BLOCK(pwalletMain->cs_vMasterKey) - { - if(pwalletMain->IsLocked()) - throw JSONRPCError(-14, "Error: The wallet passphrase entered was incorrect."); + if (pwalletMain->IsLocked()) + throw JSONRPCError(-13, "Error: Please enter the wallet passphrase with walletpassphrase first."); - string strError = pwalletMain->SendMoneyToBitcoinAddress(address, nAmount, wtx); - if (strError != "") - throw JSONRPCError(-4, strError); - } + string strError = pwalletMain->SendMoneyToBitcoinAddress(address, nAmount, wtx); + if (strError != "") + throw JSONRPCError(-4, strError); return wtx.GetHash().GetHex(); } @@ -585,19 +554,16 @@ Value getreceivedbyaddress(const Array& params, bool fHelp) // Tally int64 nAmount = 0; - CRITICAL_BLOCK(pwalletMain->cs_mapWallet) + for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { - for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) - { - const CWalletTx& wtx = (*it).second; - if (wtx.IsCoinBase() || !wtx.IsFinal()) - continue; + const CWalletTx& wtx = (*it).second; + if (wtx.IsCoinBase() || !wtx.IsFinal()) + continue; - BOOST_FOREACH(const CTxOut& txout, wtx.vout) - if (txout.scriptPubKey == scriptPubKey) - if (wtx.GetDepthInMainChain() >= nMinDepth) - nAmount += txout.nValue; - } + BOOST_FOREACH(const CTxOut& txout, wtx.vout) + if (txout.scriptPubKey == scriptPubKey) + if (wtx.GetDepthInMainChain() >= nMinDepth) + nAmount += txout.nValue; } return ValueFromAmount(nAmount); @@ -606,15 +572,12 @@ Value getreceivedbyaddress(const Array& params, bool fHelp) void GetAccountAddresses(string strAccount, set<CBitcoinAddress>& setAddress) { - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) + BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& item, pwalletMain->mapAddressBook) { - BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& item, pwalletMain->mapAddressBook) - { - const CBitcoinAddress& address = item.first; - const string& strName = item.second; - if (strName == strAccount) - setAddress.insert(address); - } + const CBitcoinAddress& address = item.first; + const string& strName = item.second; + if (strName == strAccount) + setAddress.insert(address); } } @@ -638,21 +601,18 @@ Value getreceivedbyaccount(const Array& params, bool fHelp) // Tally int64 nAmount = 0; - CRITICAL_BLOCK(pwalletMain->cs_mapWallet) + for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { - for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) - { - const CWalletTx& wtx = (*it).second; - if (wtx.IsCoinBase() || !wtx.IsFinal()) - continue; + const CWalletTx& wtx = (*it).second; + if (wtx.IsCoinBase() || !wtx.IsFinal()) + continue; - BOOST_FOREACH(const CTxOut& txout, wtx.vout) - { - CBitcoinAddress address; - if (ExtractAddress(txout.scriptPubKey, pwalletMain, address) && setAddress.count(address)) - if (wtx.GetDepthInMainChain() >= nMinDepth) - nAmount += txout.nValue; - } + BOOST_FOREACH(const CTxOut& txout, wtx.vout) + { + CBitcoinAddress address; + if (ExtractAddress(txout.scriptPubKey, pwalletMain, address) && setAddress.count(address)) + if (wtx.GetDepthInMainChain() >= nMinDepth) + nAmount += txout.nValue; } } @@ -663,27 +623,25 @@ Value getreceivedbyaccount(const Array& params, bool fHelp) int64 GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMinDepth) { int64 nBalance = 0; - CRITICAL_BLOCK(pwalletMain->cs_mapWallet) - { - // Tally wallet transactions - for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) - { - const CWalletTx& wtx = (*it).second; - if (!wtx.IsFinal()) - continue; - int64 nGenerated, nReceived, nSent, nFee; - wtx.GetAccountAmounts(strAccount, nGenerated, nReceived, nSent, nFee); + // Tally wallet transactions + for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + const CWalletTx& wtx = (*it).second; + if (!wtx.IsFinal()) + continue; - if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth) - nBalance += nReceived; - nBalance += nGenerated - nSent - nFee; - } + int64 nGenerated, nReceived, nSent, nFee; + wtx.GetAccountAmounts(strAccount, nGenerated, nReceived, nSent, nFee); - // Tally internal accounting entries - nBalance += walletdb.GetAccountCreditDebit(strAccount); + if (nReceived != 0 && wtx.GetDepthInMainChain() >= nMinDepth) + nBalance += nReceived; + nBalance += nGenerated - nSent - nFee; } + // Tally internal accounting entries + nBalance += walletdb.GetAccountCreditDebit(strAccount); + return nBalance; } @@ -762,33 +720,31 @@ Value movecmd(const Array& params, bool fHelp) if (params.size() > 4) strComment = params[4].get_str(); - CRITICAL_BLOCK(pwalletMain->cs_mapWallet) - { - CWalletDB walletdb(pwalletMain->strWalletFile); - walletdb.TxnBegin(); - - int64 nNow = GetAdjustedTime(); - - // Debit - CAccountingEntry debit; - debit.strAccount = strFrom; - debit.nCreditDebit = -nAmount; - debit.nTime = nNow; - debit.strOtherAccount = strTo; - debit.strComment = strComment; - walletdb.WriteAccountingEntry(debit); - - // Credit - CAccountingEntry credit; - credit.strAccount = strTo; - credit.nCreditDebit = nAmount; - credit.nTime = nNow; - credit.strOtherAccount = strFrom; - credit.strComment = strComment; - walletdb.WriteAccountingEntry(credit); - - walletdb.TxnCommit(); - } + CWalletDB walletdb(pwalletMain->strWalletFile); + walletdb.TxnBegin(); + + int64 nNow = GetAdjustedTime(); + + // Debit + CAccountingEntry debit; + debit.strAccount = strFrom; + debit.nCreditDebit = -nAmount; + debit.nTime = nNow; + debit.strOtherAccount = strTo; + debit.strComment = strComment; + walletdb.WriteAccountingEntry(debit); + + // Credit + CAccountingEntry credit; + credit.strAccount = strTo; + credit.nCreditDebit = nAmount; + credit.nTime = nNow; + credit.strOtherAccount = strFrom; + credit.strComment = strComment; + walletdb.WriteAccountingEntry(credit); + + walletdb.TxnCommit(); + return true; } @@ -821,23 +777,18 @@ Value sendfrom(const Array& params, bool fHelp) if (params.size() > 5 && params[5].type() != null_type && !params[5].get_str().empty()) wtx.mapValue["to"] = params[5].get_str(); - CRITICAL_BLOCK(cs_main) - CRITICAL_BLOCK(pwalletMain->cs_mapWallet) - CRITICAL_BLOCK(pwalletMain->cs_vMasterKey) - { - if(pwalletMain->IsLocked()) - throw JSONRPCError(-14, "Error: The wallet passphrase entered was incorrect."); + if (pwalletMain->IsLocked()) + throw JSONRPCError(-13, "Error: Please enter the wallet passphrase with walletpassphrase first."); - // Check funds - int64 nBalance = GetAccountBalance(strAccount, nMinDepth); - if (nAmount > nBalance) - throw JSONRPCError(-6, "Account has insufficient funds"); + // Check funds + int64 nBalance = GetAccountBalance(strAccount, nMinDepth); + if (nAmount > nBalance) + throw JSONRPCError(-6, "Account has insufficient funds"); - // Send - string strError = pwalletMain->SendMoneyToBitcoinAddress(address, nAmount, wtx); - if (strError != "") - throw JSONRPCError(-4, strError); - } + // Send + string strError = pwalletMain->SendMoneyToBitcoinAddress(address, nAmount, wtx); + if (strError != "") + throw JSONRPCError(-4, strError); return wtx.GetHash().GetHex(); } @@ -888,31 +839,26 @@ Value sendmany(const Array& params, bool fHelp) vecSend.push_back(make_pair(scriptPubKey, nAmount)); } - CRITICAL_BLOCK(cs_main) - CRITICAL_BLOCK(pwalletMain->cs_mapWallet) - CRITICAL_BLOCK(pwalletMain->cs_vMasterKey) - { - if(pwalletMain->IsLocked()) - throw JSONRPCError(-14, "Error: The wallet passphrase entered was incorrect."); - - // Check funds - int64 nBalance = GetAccountBalance(strAccount, nMinDepth); - if (totalAmount > nBalance) - throw JSONRPCError(-6, "Account has insufficient funds"); + if (pwalletMain->IsLocked()) + throw JSONRPCError(-13, "Error: Please enter the wallet passphrase with walletpassphrase first."); - // Send - CReserveKey keyChange(pwalletMain); - int64 nFeeRequired = 0; - bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired); - if (!fCreated) - { - if (totalAmount + nFeeRequired > pwalletMain->GetBalance()) - throw JSONRPCError(-6, "Insufficient funds"); - throw JSONRPCError(-4, "Transaction creation failed"); - } - if (!pwalletMain->CommitTransaction(wtx, keyChange)) - throw JSONRPCError(-4, "Transaction commit failed"); + // Check funds + int64 nBalance = GetAccountBalance(strAccount, nMinDepth); + if (totalAmount > nBalance) + throw JSONRPCError(-6, "Account has insufficient funds"); + + // Send + CReserveKey keyChange(pwalletMain); + int64 nFeeRequired = 0; + bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired); + if (!fCreated) + { + if (totalAmount + nFeeRequired > pwalletMain->GetBalance()) + throw JSONRPCError(-6, "Insufficient funds"); + throw JSONRPCError(-4, "Transaction creation failed"); } + if (!pwalletMain->CommitTransaction(wtx, keyChange)) + throw JSONRPCError(-4, "Transaction commit failed"); return wtx.GetHash().GetHex(); } @@ -943,68 +889,62 @@ Value ListReceived(const Array& params, bool fByAccounts) // Tally map<CBitcoinAddress, tallyitem> mapTally; - CRITICAL_BLOCK(pwalletMain->cs_mapWallet) + for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) { - for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) - { - const CWalletTx& wtx = (*it).second; - if (wtx.IsCoinBase() || !wtx.IsFinal()) - continue; + const CWalletTx& wtx = (*it).second; + if (wtx.IsCoinBase() || !wtx.IsFinal()) + continue; - int nDepth = wtx.GetDepthInMainChain(); - if (nDepth < nMinDepth) - continue; + int nDepth = wtx.GetDepthInMainChain(); + if (nDepth < nMinDepth) + continue; - BOOST_FOREACH(const CTxOut& txout, wtx.vout) - { - CBitcoinAddress address; - if (!ExtractAddress(txout.scriptPubKey, pwalletMain, address) || !address.IsValid()) - continue; + BOOST_FOREACH(const CTxOut& txout, wtx.vout) + { + CBitcoinAddress address; + if (!ExtractAddress(txout.scriptPubKey, pwalletMain, address) || !address.IsValid()) + continue; - tallyitem& item = mapTally[address]; - item.nAmount += txout.nValue; - item.nConf = min(item.nConf, nDepth); - } + tallyitem& item = mapTally[address]; + item.nAmount += txout.nValue; + item.nConf = min(item.nConf, nDepth); } } // Reply Array ret; map<string, tallyitem> mapAccountTally; - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) + BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& item, pwalletMain->mapAddressBook) { - BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& item, pwalletMain->mapAddressBook) - { - const CBitcoinAddress& address = item.first; - const string& strAccount = item.second; - map<CBitcoinAddress, tallyitem>::iterator it = mapTally.find(address); - if (it == mapTally.end() && !fIncludeEmpty) - continue; + const CBitcoinAddress& address = item.first; + const string& strAccount = item.second; + map<CBitcoinAddress, tallyitem>::iterator it = mapTally.find(address); + if (it == mapTally.end() && !fIncludeEmpty) + continue; - int64 nAmount = 0; - int nConf = INT_MAX; - if (it != mapTally.end()) - { - nAmount = (*it).second.nAmount; - nConf = (*it).second.nConf; - } + int64 nAmount = 0; + int nConf = INT_MAX; + if (it != mapTally.end()) + { + nAmount = (*it).second.nAmount; + nConf = (*it).second.nConf; + } - if (fByAccounts) - { - tallyitem& item = mapAccountTally[strAccount]; - item.nAmount += nAmount; - item.nConf = min(item.nConf, nConf); - } - else - { - Object obj; - obj.push_back(Pair("address", address.ToString())); - obj.push_back(Pair("account", strAccount)); - obj.push_back(Pair("label", strAccount)); // deprecated - obj.push_back(Pair("amount", ValueFromAmount(nAmount))); - obj.push_back(Pair("confirmations", (nConf == INT_MAX ? 0 : nConf))); - ret.push_back(obj); - } + if (fByAccounts) + { + tallyitem& item = mapAccountTally[strAccount]; + item.nAmount += nAmount; + item.nConf = min(item.nConf, nConf); + } + else + { + Object obj; + obj.push_back(Pair("address", address.ToString())); + obj.push_back(Pair("account", strAccount)); + obj.push_back(Pair("label", strAccount)); // deprecated + obj.push_back(Pair("amount", ValueFromAmount(nAmount))); + obj.push_back(Pair("confirmations", (nConf == INT_MAX ? 0 : nConf))); + ret.push_back(obj); } } @@ -1106,27 +1046,23 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe // Received if (listReceived.size() > 0 && wtx.GetDepthInMainChain() >= nMinDepth) - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) + BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64)& r, listReceived) { - BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64)& r, listReceived) + string account; + if (pwalletMain->mapAddressBook.count(r.first)) + account = pwalletMain->mapAddressBook[r.first]; + if (fAllAccounts || (account == strAccount)) { - string account; - if (pwalletMain->mapAddressBook.count(r.first)) - account = pwalletMain->mapAddressBook[r.first]; - if (fAllAccounts || (account == strAccount)) - { - Object entry; - entry.push_back(Pair("account", account)); - entry.push_back(Pair("address", r.first.ToString())); - entry.push_back(Pair("category", "receive")); - entry.push_back(Pair("amount", ValueFromAmount(r.second))); - if (fLong) - WalletTxToJSON(wtx, entry); - ret.push_back(entry); - } + Object entry; + entry.push_back(Pair("account", account)); + entry.push_back(Pair("address", r.first.ToString())); + entry.push_back(Pair("category", "receive")); + entry.push_back(Pair("amount", ValueFromAmount(r.second))); + if (fLong) + WalletTxToJSON(wtx, entry); + ret.push_back(entry); } } - } void AcentryToJSON(const CAccountingEntry& acentry, const string& strAccount, Array& ret) @@ -1166,40 +1102,38 @@ Value listtransactions(const Array& params, bool fHelp) Array ret; CWalletDB walletdb(pwalletMain->strWalletFile); - CRITICAL_BLOCK(pwalletMain->cs_mapWallet) - { - // Firs: get all CWalletTx and CAccountingEntry into a sorted-by-time multimap: - typedef pair<CWalletTx*, CAccountingEntry*> TxPair; - typedef multimap<int64, TxPair > TxItems; - TxItems txByTime; + // Firs: get all CWalletTx and CAccountingEntry into a sorted-by-time multimap: + typedef pair<CWalletTx*, CAccountingEntry*> TxPair; + typedef multimap<int64, TxPair > TxItems; + TxItems txByTime; - for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) - { - CWalletTx* wtx = &((*it).second); - txByTime.insert(make_pair(wtx->GetTxTime(), TxPair(wtx, (CAccountingEntry*)0))); - } - list<CAccountingEntry> acentries; - walletdb.ListAccountCreditDebit(strAccount, acentries); - BOOST_FOREACH(CAccountingEntry& entry, acentries) - { - txByTime.insert(make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry))); - } + for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + CWalletTx* wtx = &((*it).second); + txByTime.insert(make_pair(wtx->GetTxTime(), TxPair(wtx, (CAccountingEntry*)0))); + } + list<CAccountingEntry> acentries; + walletdb.ListAccountCreditDebit(strAccount, acentries); + BOOST_FOREACH(CAccountingEntry& entry, acentries) + { + txByTime.insert(make_pair(entry.nTime, TxPair((CWalletTx*)0, &entry))); + } - // Now: iterate backwards until we have nCount items to return: - TxItems::reverse_iterator it = txByTime.rbegin(); - for (std::advance(it, nFrom); it != txByTime.rend(); ++it) - { - CWalletTx *const pwtx = (*it).second.first; - if (pwtx != 0) - ListTransactions(*pwtx, strAccount, 0, true, ret); - CAccountingEntry *const pacentry = (*it).second.second; - if (pacentry != 0) - AcentryToJSON(*pacentry, strAccount, ret); - - if (ret.size() >= nCount) break; - } - // ret is now newest to oldest + // Now: iterate backwards until we have nCount items to return: + TxItems::reverse_iterator it = txByTime.rbegin(); + if (txByTime.size() > nFrom) std::advance(it, nFrom); + for (; it != txByTime.rend(); ++it) + { + CWalletTx *const pwtx = (*it).second.first; + if (pwtx != 0) + ListTransactions(*pwtx, strAccount, 0, true, ret); + CAccountingEntry *const pacentry = (*it).second.second; + if (pacentry != 0) + AcentryToJSON(*pacentry, strAccount, ret); + + if (ret.size() >= nCount) break; } + // ret is now newest to oldest // Make sure we return only last nCount items (sends-to-self might give us an extra): if (ret.size() > nCount) @@ -1225,34 +1159,30 @@ Value listaccounts(const Array& params, bool fHelp) nMinDepth = params[0].get_int(); map<string, int64> mapAccountBalances; - CRITICAL_BLOCK(pwalletMain->cs_mapWallet) - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) - { - BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& entry, pwalletMain->mapAddressBook) { - if (pwalletMain->HaveKey(entry.first)) // This address belongs to me - mapAccountBalances[entry.second] = 0; - } + BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& entry, pwalletMain->mapAddressBook) { + if (pwalletMain->HaveKey(entry.first)) // This address belongs to me + mapAccountBalances[entry.second] = 0; + } - for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) + { + const CWalletTx& wtx = (*it).second; + int64 nGeneratedImmature, nGeneratedMature, nFee; + string strSentAccount; + list<pair<CBitcoinAddress, int64> > listReceived; + list<pair<CBitcoinAddress, int64> > listSent; + wtx.GetAmounts(nGeneratedImmature, nGeneratedMature, listReceived, listSent, nFee, strSentAccount); + mapAccountBalances[strSentAccount] -= nFee; + BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64)& s, listSent) + mapAccountBalances[strSentAccount] -= s.second; + if (wtx.GetDepthInMainChain() >= nMinDepth) { - const CWalletTx& wtx = (*it).second; - int64 nGeneratedImmature, nGeneratedMature, nFee; - string strSentAccount; - list<pair<CBitcoinAddress, int64> > listReceived; - list<pair<CBitcoinAddress, int64> > listSent; - wtx.GetAmounts(nGeneratedImmature, nGeneratedMature, listReceived, listSent, nFee, strSentAccount); - mapAccountBalances[strSentAccount] -= nFee; - BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64)& s, listSent) - mapAccountBalances[strSentAccount] -= s.second; - if (wtx.GetDepthInMainChain() >= nMinDepth) - { - mapAccountBalances[""] += nGeneratedMature; - BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64)& r, listReceived) - if (pwalletMain->mapAddressBook.count(r.first)) - mapAccountBalances[pwalletMain->mapAddressBook[r.first]] += r.second; - else - mapAccountBalances[""] += r.second; - } + mapAccountBalances[""] += nGeneratedMature; + BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, int64)& r, listReceived) + if (pwalletMain->mapAddressBook.count(r.first)) + mapAccountBalances[pwalletMain->mapAddressBook[r.first]] += r.second; + else + mapAccountBalances[""] += r.second; } } @@ -1279,27 +1209,25 @@ Value gettransaction(const Array& params, bool fHelp) hash.SetHex(params[0].get_str()); Object entry; - CRITICAL_BLOCK(pwalletMain->cs_mapWallet) - { - if (!pwalletMain->mapWallet.count(hash)) - throw JSONRPCError(-5, "Invalid or non-wallet transaction id"); - const CWalletTx& wtx = pwalletMain->mapWallet[hash]; - int64 nCredit = wtx.GetCredit(); - int64 nDebit = wtx.GetDebit(); - int64 nNet = nCredit - nDebit; - int64 nFee = (wtx.IsFromMe() ? wtx.GetValueOut() - nDebit : 0); + if (!pwalletMain->mapWallet.count(hash)) + throw JSONRPCError(-5, "Invalid or non-wallet transaction id"); + const CWalletTx& wtx = pwalletMain->mapWallet[hash]; - entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee))); - if (wtx.IsFromMe()) - entry.push_back(Pair("fee", ValueFromAmount(nFee))); + int64 nCredit = wtx.GetCredit(); + int64 nDebit = wtx.GetDebit(); + int64 nNet = nCredit - nDebit; + int64 nFee = (wtx.IsFromMe() ? wtx.GetValueOut() - nDebit : 0); - WalletTxToJSON(pwalletMain->mapWallet[hash], entry); + entry.push_back(Pair("amount", ValueFromAmount(nNet - nFee))); + if (wtx.IsFromMe()) + entry.push_back(Pair("fee", ValueFromAmount(nFee))); - Array details; - ListTransactions(pwalletMain->mapWallet[hash], "*", 0, false, details); - entry.push_back(Pair("details", details)); - } + WalletTxToJSON(pwalletMain->mapWallet[hash], entry); + + Array details; + ListTransactions(pwalletMain->mapWallet[hash], "*", 0, false, details); + entry.push_back(Pair("details", details)); return entry; } @@ -1330,13 +1258,10 @@ Value keypoolrefill(const Array& params, bool fHelp) "keypoolrefill\n" "Fills the keypool."); - CRITICAL_BLOCK(pwalletMain->cs_vMasterKey) - { - if (pwalletMain->IsLocked()) - throw JSONRPCError(-13, "Error: Please enter the wallet passphrase with walletpassphrase first."); + if (pwalletMain->IsLocked()) + throw JSONRPCError(-13, "Error: Please enter the wallet passphrase with walletpassphrase first."); - pwalletMain->TopUpKeyPool(); - } + pwalletMain->TopUpKeyPool(); if (pwalletMain->GetKeyPoolSize() < GetArg("-keypool", 100)) throw JSONRPCError(-4, "Error refreshing keypool."); @@ -1405,24 +1330,21 @@ Value walletpassphrase(const Array& params, bool fHelp) mlock(&strWalletPass[0], strWalletPass.capacity()); strWalletPass = params[0].get_str(); - CRITICAL_BLOCK(pwalletMain->cs_vMasterKey) + if (strWalletPass.length() > 0) { - if (strWalletPass.length() > 0) + if (!pwalletMain->Unlock(strWalletPass)) { - if (!pwalletMain->Unlock(strWalletPass)) - { - fill(strWalletPass.begin(), strWalletPass.end(), '\0'); - munlock(&strWalletPass[0], strWalletPass.capacity()); - throw JSONRPCError(-14, "Error: The wallet passphrase entered was incorrect."); - } fill(strWalletPass.begin(), strWalletPass.end(), '\0'); munlock(&strWalletPass[0], strWalletPass.capacity()); + throw JSONRPCError(-14, "Error: The wallet passphrase entered was incorrect."); } - else - throw runtime_error( - "walletpassphrase <passphrase> <timeout>\n" - "Stores the wallet decryption key in memory for <timeout> seconds."); + fill(strWalletPass.begin(), strWalletPass.end(), '\0'); + munlock(&strWalletPass[0], strWalletPass.capacity()); } + else + throw runtime_error( + "walletpassphrase <passphrase> <timeout>\n" + "Stores the wallet decryption key in memory for <timeout> seconds."); CreateThread(ThreadTopUpKeyPool, NULL); int* pnSleepTime = new int(params[1].get_int()); @@ -1551,11 +1473,8 @@ Value validateaddress(const Array& params, bool fHelp) string currentAddress = address.ToString(); ret.push_back(Pair("address", currentAddress)); ret.push_back(Pair("ismine", (pwalletMain->HaveKey(address) > 0))); - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) - { - if (pwalletMain->mapAddressBook.count(address)) - ret.push_back(Pair("account", pwalletMain->mapAddressBook[address])); - } + if (pwalletMain->mapAddressBook.count(address)) + ret.push_back(Pair("account", pwalletMain->mapAddressBook[address])); } return ret; } @@ -1579,7 +1498,8 @@ Value getwork(const Array& params, bool fHelp) if (IsInitialBlockDownload()) throw JSONRPCError(-10, "Bitcoin is downloading blocks..."); - static map<uint256, pair<CBlock*, unsigned int> > mapNewBlock; + typedef map<uint256, pair<CBlock*, CScript> > mapNewBlock_t; + static mapNewBlock_t mapNewBlock; static vector<CBlock*> vNewBlock; static CReserveKey reservekey(pwalletMain); @@ -1618,11 +1538,10 @@ Value getwork(const Array& params, bool fHelp) // Update nExtraNonce static unsigned int nExtraNonce = 0; - static int64 nPrevTime = 0; - IncrementExtraNonce(pblock, pindexPrev, nExtraNonce, nPrevTime); + IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); // Save - mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, nExtraNonce); + mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, pblock->vtx[0].vin[0].scriptSig); // Prebuild hash buffers char pmidstate[32]; @@ -1655,11 +1574,10 @@ Value getwork(const Array& params, bool fHelp) if (!mapNewBlock.count(pdata->hashMerkleRoot)) return false; CBlock* pblock = mapNewBlock[pdata->hashMerkleRoot].first; - unsigned int nExtraNonce = mapNewBlock[pdata->hashMerkleRoot].second; pblock->nTime = pdata->nTime; pblock->nNonce = pdata->nNonce; - pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nBits << CBigNum(nExtraNonce); + pblock->vtx[0].vin[0].scriptSig = mapNewBlock[pdata->hashMerkleRoot].second; pblock->hashMerkleRoot = pblock->BuildMerkleTree(); return CheckWork(pblock, *pwalletMain, reservekey); @@ -2231,7 +2149,10 @@ void ThreadRPCServer2(void* parg) try { // Execute - Value result = (*(*mi).second)(params, false); + Value result; + CRITICAL_BLOCK(cs_main) + CRITICAL_BLOCK(pwalletMain->cs_wallet) + result = (*(*mi).second)(params, false); // Send reply string strReply = JSONRPCReply(result, Value::null, id); @@ -1,4 +1,5 @@ // Copyright (c) 2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/script.cpp b/src/script.cpp index 0fc4611fda..6e7bcb5e14 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #include "headers.h" @@ -1032,48 +1033,45 @@ bool Solver(const CKeyStore& keystore, const CScript& scriptPubKey, uint256 hash return false; // Compile solution - CRITICAL_BLOCK(keystore.cs_KeyStore) + BOOST_FOREACH(PAIRTYPE(opcodetype, valtype)& item, vSolution) { - BOOST_FOREACH(PAIRTYPE(opcodetype, valtype)& item, vSolution) + if (item.first == OP_PUBKEY) { - if (item.first == OP_PUBKEY) + // Sign + const valtype& vchPubKey = item.second; + CKey key; + if (!keystore.GetKey(Hash160(vchPubKey), key)) + return false; + if (key.GetPubKey() != vchPubKey) + return false; + if (hash != 0) { - // Sign - const valtype& vchPubKey = item.second; - CKey key; - if (!keystore.GetKey(Hash160(vchPubKey), key)) - return false; - if (key.GetPubKey() != vchPubKey) + vector<unsigned char> vchSig; + if (!key.Sign(hash, vchSig)) return false; - if (hash != 0) - { - vector<unsigned char> vchSig; - if (!key.Sign(hash, vchSig)) - return false; - vchSig.push_back((unsigned char)nHashType); - scriptSigRet << vchSig; - } + vchSig.push_back((unsigned char)nHashType); + scriptSigRet << vchSig; } - else if (item.first == OP_PUBKEYHASH) + } + else if (item.first == OP_PUBKEYHASH) + { + // Sign and give pubkey + CKey key; + if (!keystore.GetKey(uint160(item.second), key)) + return false; + if (hash != 0) { - // Sign and give pubkey - CKey key; - if (!keystore.GetKey(uint160(item.second), key)) + vector<unsigned char> vchSig; + if (!key.Sign(hash, vchSig)) return false; - if (hash != 0) - { - vector<unsigned char> vchSig; - if (!key.Sign(hash, vchSig)) - return false; - vchSig.push_back((unsigned char)nHashType); - scriptSigRet << vchSig << key.GetPubKey(); - } - } - else - { - return false; + vchSig.push_back((unsigned char)nHashType); + scriptSigRet << vchSig << key.GetPubKey(); } } + else + { + return false; + } } return true; @@ -1094,35 +1092,31 @@ bool IsMine(const CKeyStore &keystore, const CScript& scriptPubKey) return false; // Compile solution - CRITICAL_BLOCK(keystore.cs_KeyStore) + BOOST_FOREACH(PAIRTYPE(opcodetype, valtype)& item, vSolution) { - BOOST_FOREACH(PAIRTYPE(opcodetype, valtype)& item, vSolution) + if (item.first == OP_PUBKEY) { - if (item.first == OP_PUBKEY) - { - const valtype& vchPubKey = item.second; - vector<unsigned char> vchPubKeyFound; - if (!keystore.GetPubKey(Hash160(vchPubKey), vchPubKeyFound)) - return false; - if (vchPubKeyFound != vchPubKey) - return false; - } - else if (item.first == OP_PUBKEYHASH) - { - if (!keystore.HaveKey(uint160(item.second))) - return false; - } - else - { + const valtype& vchPubKey = item.second; + vector<unsigned char> vchPubKeyFound; + if (!keystore.GetPubKey(Hash160(vchPubKey), vchPubKeyFound)) return false; - } + if (vchPubKeyFound != vchPubKey) + return false; + } + else if (item.first == OP_PUBKEYHASH) + { + if (!keystore.HaveKey(uint160(item.second))) + return false; + } + else + { + return false; } } return true; } -// requires either keystore==0, or a lock on keystore->cs_KeyStore bool static ExtractAddressInner(const CScript& scriptPubKey, const CKeyStore* keystore, CBitcoinAddress& addressRet) { vector<pair<opcodetype, valtype> > vSolution; @@ -1145,8 +1139,7 @@ bool static ExtractAddressInner(const CScript& scriptPubKey, const CKeyStore* ke bool ExtractAddress(const CScript& scriptPubKey, const CKeyStore* keystore, CBitcoinAddress& addressRet) { if (keystore) - CRITICAL_BLOCK(keystore->cs_KeyStore) - return ExtractAddressInner(scriptPubKey, keystore, addressRet); + return ExtractAddressInner(scriptPubKey, keystore, addressRet); else return ExtractAddressInner(scriptPubKey, NULL, addressRet); return false; diff --git a/src/script.h b/src/script.h index 9d94e3f5c8..e61ea2fd7e 100644 --- a/src/script.h +++ b/src/script.h @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef H_BITCOIN_SCRIPT @@ -10,6 +11,8 @@ #include <string> #include <vector> +#include <boost/foreach.hpp> + class CTransaction; enum @@ -689,6 +692,7 @@ public: +bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, int nHashType); bool IsStandard(const CScript& scriptPubKey); bool IsMine(const CKeyStore& keystore, const CScript& scriptPubKey); diff --git a/src/serialize.h b/src/serialize.h index cb3a3ea03c..698bdfe6a9 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_SERIALIZE_H @@ -34,6 +35,7 @@ typedef unsigned long long uint64; // Note that VirtualLock does not provide this as a guarantee on Windows, // but, in practice, memory that has been VirtualLock'd almost never gets written to // the pagefile except in rare circumstances where memory is extremely low. +#include <windows.h> #define mlock(p, n) VirtualLock((p), (n)); #define munlock(p, n) VirtualUnlock((p), (n)); #else @@ -57,14 +59,17 @@ class CDataStream; class CAutoFile; static const unsigned int MAX_SIZE = 0x02000000; -static const int VERSION = 32500; +static const int VERSION = 40000; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; - - - - +// Used to bypass the rule against non-const reference to temporary +// where it makes sense with wrappers such as CFlatData or CTxDB +template<typename T> +inline T& REF(const T& val) +{ + return const_cast<T&>(val); +} ///////////////////////////////////////////////////////////////// // diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp new file mode 100644 index 0000000000..13feb86b97 --- /dev/null +++ b/src/test/script_tests.cpp @@ -0,0 +1,173 @@ +#include <vector> +#include <boost/test/unit_test.hpp> +#include <boost/foreach.hpp> + +#include "../main.h" +#include "../wallet.h" + +using namespace std; +extern uint256 SignatureHash(CScript scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType); +extern bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, int nHashType); +extern bool VerifySignature(const CTransaction& txFrom, const CTransaction& txTo, unsigned int nIn, int nHashType); + +BOOST_AUTO_TEST_SUITE(script_tests) + +BOOST_AUTO_TEST_CASE(script_PushData) +{ + // Check that PUSHDATA1, PUSHDATA2, and PUSHDATA4 create the same value on + // the stack as the 1-75 opcodes do. + static const unsigned char direct[] = { 1, 0x5a }; + static const unsigned char pushdata1[] = { OP_PUSHDATA1, 1, 0x5a }; + static const unsigned char pushdata2[] = { OP_PUSHDATA2, 1, 0, 0x5a }; + static const unsigned char pushdata4[] = { OP_PUSHDATA4, 1, 0, 0, 0, 0x5a }; + + vector<vector<unsigned char> > directStack; + BOOST_CHECK(EvalScript(directStack, CScript(&direct[0], &direct[sizeof(direct)]), CTransaction(), 0, 0)); + + vector<vector<unsigned char> > pushdata1Stack; + BOOST_CHECK(EvalScript(pushdata1Stack, CScript(&pushdata1[0], &pushdata1[sizeof(pushdata1)]), CTransaction(), 0, 0)); + BOOST_CHECK(pushdata1Stack == directStack); + + vector<vector<unsigned char> > pushdata2Stack; + BOOST_CHECK(EvalScript(pushdata2Stack, CScript(&pushdata2[0], &pushdata2[sizeof(pushdata2)]), CTransaction(), 0, 0)); + BOOST_CHECK(pushdata2Stack == directStack); + + vector<vector<unsigned char> > pushdata4Stack; + BOOST_CHECK(EvalScript(pushdata4Stack, CScript(&pushdata4[0], &pushdata4[sizeof(pushdata4)]), CTransaction(), 0, 0)); + BOOST_CHECK(pushdata4Stack == directStack); +} + +CScript +sign_multisig(CScript scriptPubKey, std::vector<CKey> keys, CTransaction transaction) +{ + uint256 hash = SignatureHash(scriptPubKey, transaction, 0, SIGHASH_ALL); + + CScript result; + // + // NOTE: CHECKMULTISIG has an unfortunate bug; it requires + // one extra item on the stack, before the signatures. + // Putting OP_0 on the stack is the workaround; + // fixing the bug would mean splitting the blockchain (old + // clients would not accept new CHECKMULTISIG transactions, + // and vice-versa) + // + result << OP_0; + BOOST_FOREACH(CKey key, keys) + { + vector<unsigned char> vchSig; + BOOST_CHECK(key.Sign(hash, vchSig)); + vchSig.push_back((unsigned char)SIGHASH_ALL); + result << vchSig; + } + return result; +} +CScript +sign_multisig(CScript scriptPubKey, CKey key, CTransaction transaction) +{ + std::vector<CKey> keys; + keys.push_back(key); + return sign_multisig(scriptPubKey, keys, transaction); +} + +BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG12) +{ + CKey key1, key2, key3; + key1.MakeNewKey(); + key2.MakeNewKey(); + key3.MakeNewKey(); + + CScript scriptPubKey12; + scriptPubKey12 << OP_1 << key1.GetPubKey() << key2.GetPubKey() << OP_2 << OP_CHECKMULTISIG; + + CTransaction txFrom12; + txFrom12.vout.resize(1); + txFrom12.vout[0].scriptPubKey = scriptPubKey12; + + CTransaction txTo12; + txTo12.vin.resize(1); + txTo12.vout.resize(1); + txTo12.vin[0].prevout.n = 0; + txTo12.vin[0].prevout.hash = txFrom12.GetHash(); + txTo12.vout[0].nValue = 1; + + CScript goodsig1 = sign_multisig(scriptPubKey12, key1, txTo12); + BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, 0)); + txTo12.vout[0].nValue = 2; + BOOST_CHECK(!VerifyScript(goodsig1, scriptPubKey12, txTo12, 0, 0)); + + CScript goodsig2 = sign_multisig(scriptPubKey12, key2, txTo12); + BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey12, txTo12, 0, 0)); + + CScript badsig1 = sign_multisig(scriptPubKey12, key3, txTo12); + BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey12, txTo12, 0, 0)); +} + +BOOST_AUTO_TEST_CASE(script_CHECKMULTISIG23) +{ + CKey key1, key2, key3, key4; + key1.MakeNewKey(); + key2.MakeNewKey(); + key3.MakeNewKey(); + key4.MakeNewKey(); + + CScript scriptPubKey23; + scriptPubKey23 << OP_2 << key1.GetPubKey() << key2.GetPubKey() << key3.GetPubKey() << OP_3 << OP_CHECKMULTISIG; + + CTransaction txFrom23; + txFrom23.vout.resize(1); + txFrom23.vout[0].scriptPubKey = scriptPubKey23; + + CTransaction txTo23; + txTo23.vin.resize(1); + txTo23.vout.resize(1); + txTo23.vin[0].prevout.n = 0; + txTo23.vin[0].prevout.hash = txFrom23.GetHash(); + txTo23.vout[0].nValue = 1; + + std::vector<CKey> keys; + keys.push_back(key1); keys.push_back(key2); + CScript goodsig1 = sign_multisig(scriptPubKey23, keys, txTo23); + BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey23, txTo23, 0, 0)); + + keys.clear(); + keys.push_back(key1); keys.push_back(key3); + CScript goodsig2 = sign_multisig(scriptPubKey23, keys, txTo23); + BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey23, txTo23, 0, 0)); + + keys.clear(); + keys.push_back(key2); keys.push_back(key3); + CScript goodsig3 = sign_multisig(scriptPubKey23, keys, txTo23); + BOOST_CHECK(VerifyScript(goodsig3, scriptPubKey23, txTo23, 0, 0)); + + keys.clear(); + keys.push_back(key2); keys.push_back(key2); // Can't re-use sig + CScript badsig1 = sign_multisig(scriptPubKey23, keys, txTo23); + BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey23, txTo23, 0, 0)); + + keys.clear(); + keys.push_back(key2); keys.push_back(key1); // sigs must be in correct order + CScript badsig2 = sign_multisig(scriptPubKey23, keys, txTo23); + BOOST_CHECK(!VerifyScript(badsig2, scriptPubKey23, txTo23, 0, 0)); + + keys.clear(); + keys.push_back(key3); keys.push_back(key2); // sigs must be in correct order + CScript badsig3 = sign_multisig(scriptPubKey23, keys, txTo23); + BOOST_CHECK(!VerifyScript(badsig3, scriptPubKey23, txTo23, 0, 0)); + + keys.clear(); + keys.push_back(key4); keys.push_back(key2); // sigs must match pubkeys + CScript badsig4 = sign_multisig(scriptPubKey23, keys, txTo23); + BOOST_CHECK(!VerifyScript(badsig4, scriptPubKey23, txTo23, 0, 0)); + + keys.clear(); + keys.push_back(key1); keys.push_back(key4); // sigs must match pubkeys + CScript badsig5 = sign_multisig(scriptPubKey23, keys, txTo23); + BOOST_CHECK(!VerifyScript(badsig5, scriptPubKey23, txTo23, 0, 0)); + + keys.clear(); // Must have signatures + CScript badsig6 = sign_multisig(scriptPubKey23, keys, txTo23); + BOOST_CHECK(!VerifyScript(badsig6, scriptPubKey23, txTo23, 0, 0)); +} + + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index 3b7d2d2f2c..0230bb6eca 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -1,6 +1,18 @@ -#define BOOST_TEST_MODULE uint160 +#define BOOST_TEST_MODULE Bitcoin Test Suite #include <boost/test/unit_test.hpp> +#include "../main.h" +#include "../wallet.h" + #include "uint160_tests.cpp" #include "uint256_tests.cpp" +#include "script_tests.cpp" +#include "transaction_tests.cpp" + + +CWallet* pwalletMain; +void Shutdown(void* parg) +{ + exit(0); +} diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp new file mode 100644 index 0000000000..e6eb0f054f --- /dev/null +++ b/src/test/transaction_tests.cpp @@ -0,0 +1,25 @@ +#include <boost/test/unit_test.hpp> + +#include "../main.h" +#include "../wallet.h" + +using namespace std; + +BOOST_AUTO_TEST_SUITE(transaction_tests) + +BOOST_AUTO_TEST_CASE(basic_transaction_tests) +{ + // Random real transaction (e2769b09e784f32f62ef849763d4f45b98e07ba658647343b915ff832b110436) + unsigned char ch[] = {0x01, 0x00, 0x00, 0x00, 0x01, 0x6b, 0xff, 0x7f, 0xcd, 0x4f, 0x85, 0x65, 0xef, 0x40, 0x6d, 0xd5, 0xd6, 0x3d, 0x4f, 0xf9, 0x4f, 0x31, 0x8f, 0xe8, 0x20, 0x27, 0xfd, 0x4d, 0xc4, 0x51, 0xb0, 0x44, 0x74, 0x01, 0x9f, 0x74, 0xb4, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x49, 0x30, 0x46, 0x02, 0x21, 0x00, 0xda, 0x0d, 0xc6, 0xae, 0xce, 0xfe, 0x1e, 0x06, 0xef, 0xdf, 0x05, 0x77, 0x37, 0x57, 0xde, 0xb1, 0x68, 0x82, 0x09, 0x30, 0xe3, 0xb0, 0xd0, 0x3f, 0x46, 0xf5, 0xfc, 0xf1, 0x50, 0xbf, 0x99, 0x0c, 0x02, 0x21, 0x00, 0xd2, 0x5b, 0x5c, 0x87, 0x04, 0x00, 0x76, 0xe4, 0xf2, 0x53, 0xf8, 0x26, 0x2e, 0x76, 0x3e, 0x2d, 0xd5, 0x1e, 0x7f, 0xf0, 0xbe, 0x15, 0x77, 0x27, 0xc4, 0xbc, 0x42, 0x80, 0x7f, 0x17, 0xbd, 0x39, 0x01, 0x41, 0x04, 0xe6, 0xc2, 0x6e, 0xf6, 0x7d, 0xc6, 0x10, 0xd2, 0xcd, 0x19, 0x24, 0x84, 0x78, 0x9a, 0x6c, 0xf9, 0xae, 0xa9, 0x93, 0x0b, 0x94, 0x4b, 0x7e, 0x2d, 0xb5, 0x34, 0x2b, 0x9d, 0x9e, 0x5b, 0x9f, 0xf7, 0x9a, 0xff, 0x9a, 0x2e, 0xe1, 0x97, 0x8d, 0xd7, 0xfd, 0x01, 0xdf, 0xc5, 0x22, 0xee, 0x02, 0x28, 0x3d, 0x3b, 0x06, 0xa9, 0xd0, 0x3a, 0xcf, 0x80, 0x96, 0x96, 0x8d, 0x7d, 0xbb, 0x0f, 0x91, 0x78, 0xff, 0xff, 0xff, 0xff, 0x02, 0x8b, 0xa7, 0x94, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x19, 0x76, 0xa9, 0x14, 0xba, 0xde, 0xec, 0xfd, 0xef, 0x05, 0x07, 0x24, 0x7f, 0xc8, 0xf7, 0x42, 0x41, 0xd7, 0x3b, 0xc0, 0x39, 0x97, 0x2d, 0x7b, 0x88, 0xac, 0x40, 0x94, 0xa8, 0x02, 0x00, 0x00, 0x00, 0x00, 0x19, 0x76, 0xa9, 0x14, 0xc1, 0x09, 0x32, 0x48, 0x3f, 0xec, 0x93, 0xed, 0x51, 0xf5, 0xfe, 0x95, 0xe7, 0x25, 0x59, 0xf2, 0xcc, 0x70, 0x43, 0xf9, 0x88, 0xac, 0x00, 0x00, 0x00, 0x00, 0x00}; + vector<unsigned char> vch(ch, ch + sizeof(ch) -1); + CDataStream stream(vch); + CTransaction tx; + stream >> tx; + BOOST_CHECK_MESSAGE(tx.CheckTransaction(), "Simple deserialized transaction should be valid."); + + // Check that duplicate txins fail + tx.vin.push_back(tx.vin[0]); + BOOST_CHECK_MESSAGE(!tx.CheckTransaction(), "Transaction with duplicate txins should be invalid."); +} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/test/uint160_tests.cpp b/src/test/uint160_tests.cpp index 66ffd285b8..42c8275afe 100644 --- a/src/test/uint160_tests.cpp +++ b/src/test/uint160_tests.cpp @@ -1,8 +1,10 @@ +#include <boost/test/unit_test.hpp> + #include "../uint256.h" BOOST_AUTO_TEST_SUITE(uint160_tests) -BOOST_AUTO_TEST_CASE(equality) +BOOST_AUTO_TEST_CASE(uint160_equality) { uint160 num1 = 10; uint160 num2 = 11; diff --git a/src/test/uint256_tests.cpp b/src/test/uint256_tests.cpp index cbae9bf6d2..c5d45e215e 100644 --- a/src/test/uint256_tests.cpp +++ b/src/test/uint256_tests.cpp @@ -1,8 +1,10 @@ +#include <boost/test/unit_test.hpp> + #include "../uint256.h" BOOST_AUTO_TEST_SUITE(uint256_tests) -BOOST_AUTO_TEST_CASE(equality) +BOOST_AUTO_TEST_CASE(uint256_equality) { uint256 num1 = 10; uint256 num2 = 11; diff --git a/src/ui.cpp b/src/ui.cpp index c3c234439c..6b7ecdbc8d 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. @@ -707,7 +708,7 @@ bool CMainFrame::InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex) CBitcoinAddress address; if (ExtractAddress(txout.scriptPubKey, pwalletMain, address)) { - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) + CRITICAL_BLOCK(pwalletMain->cs_wallet) { //strDescription += _("Received payment to "); //strDescription += _("Received with address "); @@ -791,7 +792,7 @@ bool CMainFrame::InsertTransaction(const CWalletTx& wtx, bool fNew, int nIndex) } string strDescription = _("To: "); - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) + CRITICAL_BLOCK(pwalletMain->cs_wallet) if (pwalletMain->mapAddressBook.count(address) && !pwalletMain->mapAddressBook[address].empty()) strDescription += pwalletMain->mapAddressBook[address] + " "; strDescription += strAddress; @@ -861,7 +862,7 @@ void CMainFrame::OnIdle(wxIdleEvent& event) // Collect list of wallet transactions and sort newest first bool fEntered = false; vector<pair<unsigned int, uint256> > vSorted; - TRY_CRITICAL_BLOCK(pwalletMain->cs_mapWallet) + TRY_CRITICAL_BLOCK(pwalletMain->cs_wallet) { printf("RefreshListCtrl starting\n"); fEntered = true; @@ -889,7 +890,7 @@ void CMainFrame::OnIdle(wxIdleEvent& event) if (fShutdown) return; bool fEntered = false; - TRY_CRITICAL_BLOCK(pwalletMain->cs_mapWallet) + TRY_CRITICAL_BLOCK(pwalletMain->cs_wallet) { fEntered = true; uint256& hash = vSorted[i++].second; @@ -912,7 +913,7 @@ void CMainFrame::OnIdle(wxIdleEvent& event) static int64 nLastTime; if (GetTime() > nLastTime + 30) { - TRY_CRITICAL_BLOCK(pwalletMain->cs_mapWallet) + TRY_CRITICAL_BLOCK(pwalletMain->cs_wallet) { nLastTime = GetTime(); for (map<uint256, CWalletTx>::iterator it = pwalletMain->mapWallet.begin(); it != pwalletMain->mapWallet.end(); ++it) @@ -936,7 +937,7 @@ void CMainFrame::RefreshStatusColumn() if (nTop == nLastTop && pindexLastBest == pindexBest) return; - TRY_CRITICAL_BLOCK(pwalletMain->cs_mapWallet) + TRY_CRITICAL_BLOCK(pwalletMain->cs_wallet) { int nStart = nTop; int nEnd = min(nStart + 100, m_listCtrl->GetItemCount()); @@ -1056,7 +1057,7 @@ void CMainFrame::OnPaintListCtrl(wxPaintEvent& event) // Update listctrl contents if (!pwalletMain->vWalletUpdated.empty()) { - TRY_CRITICAL_BLOCK(pwalletMain->cs_mapWallet) + TRY_CRITICAL_BLOCK(pwalletMain->cs_wallet) { string strTop; if (m_listCtrl->GetItemCount()) @@ -1074,7 +1075,7 @@ void CMainFrame::OnPaintListCtrl(wxPaintEvent& event) } // Balance total - TRY_CRITICAL_BLOCK(pwalletMain->cs_mapWallet) + TRY_CRITICAL_BLOCK(pwalletMain->cs_wallet) { fPaintedBalance = true; m_staticTextBalance->SetLabel(FormatMoney(pwalletMain->GetBalance()) + " "); @@ -1246,83 +1247,80 @@ void CMainFrame::OnMenuOptionsChangeWalletPassphrase(wxCommandEvent& event) strOldWalletPass = wxGetPasswordFromUser(_("Enter the current passphrase to the wallet."), _("Passphrase")).ToStdString(); - CRITICAL_BLOCK(pwalletMain->cs_vMasterKey) - { - bool fWasLocked = pwalletMain->IsLocked(); - pwalletMain->Lock(); + bool fWasLocked = pwalletMain->IsLocked(); + pwalletMain->Lock(); - if (!strOldWalletPass.size() || !pwalletMain->Unlock(strOldWalletPass)) - { - fill(strOldWalletPass.begin(), strOldWalletPass.end(), '\0'); - munlock(&strOldWalletPass[0], strOldWalletPass.capacity()); - wxMessageBox(_("The passphrase entered for the wallet decryption was incorrect."), "Bitcoin", wxOK | wxICON_ERROR); - return; - } + if (!strOldWalletPass.size() || !pwalletMain->Unlock(strOldWalletPass)) + { + fill(strOldWalletPass.begin(), strOldWalletPass.end(), '\0'); + munlock(&strOldWalletPass[0], strOldWalletPass.capacity()); + wxMessageBox(_("The passphrase entered for the wallet decryption was incorrect."), "Bitcoin", wxOK | wxICON_ERROR); + return; + } - if (fWasLocked) - pwalletMain->Lock(); + if (fWasLocked) + pwalletMain->Lock(); - string strNewWalletPass; - strNewWalletPass.reserve(100); - mlock(&strNewWalletPass[0], strNewWalletPass.capacity()); + string strNewWalletPass; + strNewWalletPass.reserve(100); + mlock(&strNewWalletPass[0], strNewWalletPass.capacity()); - // obtain new wallet encrypt/decrypt key, from passphrase - // Note that the passphrase is not mlock()d during this entry and could potentially - // be obtained from disk long after bitcoin has run. - strNewWalletPass = wxGetPasswordFromUser(_("Enter the new passphrase for the wallet."), - _("Passphrase")).ToStdString(); + // obtain new wallet encrypt/decrypt key, from passphrase + // Note that the passphrase is not mlock()d during this entry and could potentially + // be obtained from disk long after bitcoin has run. + strNewWalletPass = wxGetPasswordFromUser(_("Enter the new passphrase for the wallet."), + _("Passphrase")).ToStdString(); - if (!strNewWalletPass.size()) - { - fill(strOldWalletPass.begin(), strOldWalletPass.end(), '\0'); - fill(strNewWalletPass.begin(), strNewWalletPass.end(), '\0'); - munlock(&strOldWalletPass[0], strOldWalletPass.capacity()); - munlock(&strNewWalletPass[0], strNewWalletPass.capacity()); - wxMessageBox(_("Error: The supplied passphrase was too short."), "Bitcoin", wxOK | wxICON_ERROR); - return; - } + if (!strNewWalletPass.size()) + { + fill(strOldWalletPass.begin(), strOldWalletPass.end(), '\0'); + fill(strNewWalletPass.begin(), strNewWalletPass.end(), '\0'); + munlock(&strOldWalletPass[0], strOldWalletPass.capacity()); + munlock(&strNewWalletPass[0], strNewWalletPass.capacity()); + wxMessageBox(_("Error: The supplied passphrase was too short."), "Bitcoin", wxOK | wxICON_ERROR); + return; + } - string strNewWalletPassTest; - strNewWalletPassTest.reserve(100); - mlock(&strNewWalletPassTest[0], strNewWalletPassTest.capacity()); + string strNewWalletPassTest; + strNewWalletPassTest.reserve(100); + mlock(&strNewWalletPassTest[0], strNewWalletPassTest.capacity()); - // obtain new wallet encrypt/decrypt key, from passphrase - // Note that the passphrase is not mlock()d during this entry and could potentially - // be obtained from disk long after bitcoin has run. - strNewWalletPassTest = wxGetPasswordFromUser(_("Re-enter the new passphrase for the wallet."), - _("Passphrase")).ToStdString(); + // obtain new wallet encrypt/decrypt key, from passphrase + // Note that the passphrase is not mlock()d during this entry and could potentially + // be obtained from disk long after bitcoin has run. + strNewWalletPassTest = wxGetPasswordFromUser(_("Re-enter the new passphrase for the wallet."), + _("Passphrase")).ToStdString(); - if (strNewWalletPassTest != strNewWalletPass) - { - fill(strOldWalletPass.begin(), strOldWalletPass.end(), '\0'); - fill(strNewWalletPass.begin(), strNewWalletPass.end(), '\0'); - fill(strNewWalletPassTest.begin(), strNewWalletPassTest.end(), '\0'); - munlock(&strOldWalletPass[0], strOldWalletPass.capacity()); - munlock(&strNewWalletPass[0], strNewWalletPass.capacity()); - munlock(&strNewWalletPassTest[0], strNewWalletPassTest.capacity()); - wxMessageBox(_("Error: the supplied passphrases didn't match."), "Bitcoin", wxOK | wxICON_ERROR); - return; - } + if (strNewWalletPassTest != strNewWalletPass) + { + fill(strOldWalletPass.begin(), strOldWalletPass.end(), '\0'); + fill(strNewWalletPass.begin(), strNewWalletPass.end(), '\0'); + fill(strNewWalletPassTest.begin(), strNewWalletPassTest.end(), '\0'); + munlock(&strOldWalletPass[0], strOldWalletPass.capacity()); + munlock(&strNewWalletPass[0], strNewWalletPass.capacity()); + munlock(&strNewWalletPassTest[0], strNewWalletPassTest.capacity()); + wxMessageBox(_("Error: the supplied passphrases didn't match."), "Bitcoin", wxOK | wxICON_ERROR); + return; + } - if (!pwalletMain->ChangeWalletPassphrase(strOldWalletPass, strNewWalletPass)) - { - fill(strOldWalletPass.begin(), strOldWalletPass.end(), '\0'); - fill(strNewWalletPass.begin(), strNewWalletPass.end(), '\0'); - fill(strNewWalletPassTest.begin(), strNewWalletPassTest.end(), '\0'); - munlock(&strOldWalletPass[0], strOldWalletPass.capacity()); - munlock(&strNewWalletPass[0], strNewWalletPass.capacity()); - munlock(&strNewWalletPassTest[0], strNewWalletPassTest.capacity()); - wxMessageBox(_("The passphrase entered for the wallet decryption was incorrect."), "Bitcoin", wxOK | wxICON_ERROR); - return; - } + if (!pwalletMain->ChangeWalletPassphrase(strOldWalletPass, strNewWalletPass)) + { fill(strOldWalletPass.begin(), strOldWalletPass.end(), '\0'); fill(strNewWalletPass.begin(), strNewWalletPass.end(), '\0'); fill(strNewWalletPassTest.begin(), strNewWalletPassTest.end(), '\0'); munlock(&strOldWalletPass[0], strOldWalletPass.capacity()); munlock(&strNewWalletPass[0], strNewWalletPass.capacity()); munlock(&strNewWalletPassTest[0], strNewWalletPassTest.capacity()); - wxMessageBox(_("Wallet Passphrase Changed."), "Bitcoin"); + wxMessageBox(_("The passphrase entered for the wallet decryption was incorrect."), "Bitcoin", wxOK | wxICON_ERROR); + return; } + fill(strOldWalletPass.begin(), strOldWalletPass.end(), '\0'); + fill(strNewWalletPass.begin(), strNewWalletPass.end(), '\0'); + fill(strNewWalletPassTest.begin(), strNewWalletPassTest.end(), '\0'); + munlock(&strOldWalletPass[0], strOldWalletPass.capacity()); + munlock(&strNewWalletPass[0], strNewWalletPass.capacity()); + munlock(&strNewWalletPassTest[0], strNewWalletPassTest.capacity()); + wxMessageBox(_("Wallet Passphrase Changed."), "Bitcoin"); } void CMainFrame::OnMenuOptionsOptions(wxCommandEvent& event) @@ -1386,21 +1384,21 @@ void CMainFrame::OnButtonNew(wxCommandEvent& event) string strName = dialog.GetValue(); string strAddress; - CRITICAL_BLOCK(pwalletMain->cs_vMasterKey) - { - bool fWasLocked = pwalletMain->IsLocked(); - if (!GetWalletPassphrase()) - return; - // Generate new key - strAddress = CBitcoinAddress(pwalletMain->GetOrReuseKeyFromPool()).ToString(); + bool fWasLocked = pwalletMain->IsLocked(); + if (!GetWalletPassphrase()) + return; - if (fWasLocked) - pwalletMain->Lock(); - } + // Generate new key + std::vector<unsigned char> newKey; + pwalletMain->GetKeyFromPool(newKey, true); + strAddress = CBitcoinAddress(newKey).ToString(); + + if (fWasLocked) + pwalletMain->Lock(); // Save - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) + CRITICAL_BLOCK(pwalletMain->cs_wallet) pwalletMain->SetAddressBookName(strAddress, strName); SetDefaultReceivingAddress(strAddress); } @@ -1419,7 +1417,7 @@ void CMainFrame::OnListItemActivated(wxListEvent& event) { uint256 hash((string)GetItemText(m_listCtrl, event.GetIndex(), 1)); CWalletTx wtx; - CRITICAL_BLOCK(pwalletMain->cs_mapWallet) + CRITICAL_BLOCK(pwalletMain->cs_wallet) { map<uint256, CWalletTx>::iterator mi = pwalletMain->mapWallet.find(hash); if (mi == pwalletMain->mapWallet.end()) @@ -1450,7 +1448,7 @@ CTxDetailsDialog::CTxDetailsDialog(wxWindow* parent, CWalletTx wtx) : CTxDetails #ifdef __WXMSW__ SetSize(nScaleX * GetSize().GetWidth(), nScaleY * GetSize().GetHeight()); #endif - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) + CRITICAL_BLOCK(pwalletMain->cs_wallet) { string strHTML; strHTML.reserve(4000); @@ -1661,7 +1659,7 @@ CTxDetailsDialog::CTxDetailsDialog(wxWindow* parent, CWalletTx wtx) : CTxDetails strHTML += HtmlEscape(wtx.ToString(), true); strHTML += "<br><b>Inputs:</b><br>"; - CRITICAL_BLOCK(pwalletMain->cs_mapWallet) + CRITICAL_BLOCK(pwalletMain->cs_wallet) { BOOST_FOREACH(const CTxIn& txin, wtx.vin) { @@ -1807,7 +1805,11 @@ void SetStartOnSystemStartup(bool fAutoStart) { if (!fAutoStart) { +#if defined(BOOST_FILESYSTEM_VERSION) && BOOST_FILESYSTEM_VERSION >= 3 + unlink(GetAutostartFilePath().string().c_str()); +#else unlink(GetAutostartFilePath().native_file_string().c_str()); +#endif } else { @@ -2159,38 +2161,42 @@ void CSendDialog::OnButtonSend(wxCommandEvent& event) if (fBitcoinAddress) { + bool fWasLocked = pwalletMain->IsLocked(); + if (!GetWalletPassphrase()) + return; + + string strError; CRITICAL_BLOCK(cs_main) - CRITICAL_BLOCK(pwalletMain->cs_vMasterKey) + CRITICAL_BLOCK(pwalletMain->cs_wallet) { - bool fWasLocked = pwalletMain->IsLocked(); - if (!GetWalletPassphrase()) - return; - // Send to bitcoin address CScript scriptPubKey; scriptPubKey.SetBitcoinAddress(address); - string strError = pwalletMain->SendMoney(scriptPubKey, nValue, wtx, true); - if (strError == "") - wxMessageBox(_("Payment sent "), _("Sending...")); - else if (strError == "ABORTED") - { - if (fWasLocked) - pwalletMain->Lock(); - return; // leave send dialog open - } - else - { - wxMessageBox(strError + " ", _("Sending...")); - EndModal(false); - if (fWasLocked) - pwalletMain->Lock(); - return; - } - + strError = pwalletMain->SendMoney(scriptPubKey, nValue, wtx, true); + } + if (strError == "") + { + pframeMain->RefreshListCtrl(); + wxMessageBox(_("Payment sent "), _("Sending...")); + } + else if (strError == "ABORTED") + { + if (fWasLocked) + pwalletMain->Lock(); + return; // leave send dialog open + } + else + { + wxMessageBox(strError + " ", _("Sending...")); + EndModal(false); if (fWasLocked) pwalletMain->Lock(); - } + return; + } + + if (fWasLocked) + pwalletMain->Lock(); } else { @@ -2211,7 +2217,7 @@ void CSendDialog::OnButtonSend(wxCommandEvent& event) return; } - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) + CRITICAL_BLOCK(pwalletMain->cs_wallet) if (!pwalletMain->mapAddressBook.count(address)) pwalletMain->SetAddressBookName(strAddress, ""); @@ -2463,83 +2469,89 @@ void CSendingDialog::OnReply2(CDataStream& vRecv) return; } - CRITICAL_BLOCK(cs_main) + // Pay + if (!Status(_("Creating transaction..."))) + return; + if (nPrice + nTransactionFee > pwalletMain->GetBalance()) { - // Pay - if (!Status(_("Creating transaction..."))) - return; - if (nPrice + nTransactionFee > pwalletMain->GetBalance()) - { - Error(_("Insufficient funds")); - return; - } + Error(_("Insufficient funds")); + return; + } - CReserveKey reservekey(pwalletMain); - int64 nFeeRequired; - CRITICAL_BLOCK(pwalletMain->cs_vMasterKey) - { - bool fWasLocked = pwalletMain->IsLocked(); - if (!GetWalletPassphrase()) - return; + CReserveKey reservekey(pwalletMain); + int64 nFeeRequired; + bool fWasLocked = pwalletMain->IsLocked(); + if (!GetWalletPassphrase()) + return; - if (!pwalletMain->CreateTransaction(scriptPubKey, nPrice, wtx, reservekey, nFeeRequired)) - { - if (nPrice + nFeeRequired > pwalletMain->GetBalance()) - Error(strprintf(_("This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds"), FormatMoney(nFeeRequired).c_str())); - else - Error(_("Transaction creation failed")); - return; - } + bool fTxCreated = false; + CRITICAL_BLOCK(cs_main) + CRITICAL_BLOCK(pwalletMain->cs_wallet) + { + fTxCreated = pwalletMain->CreateTransaction(scriptPubKey, nPrice, wtx, reservekey, nFeeRequired); + } + if (!fTxCreated) + { + if (nPrice + nFeeRequired > pwalletMain->GetBalance()) + Error(strprintf(_("This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds"), FormatMoney(nFeeRequired).c_str())); + else + Error(_("Transaction creation failed")); + return; + } - if (fWasLocked) - pwalletMain->Lock(); - } + if (fWasLocked) + pwalletMain->Lock(); - // Transaction fee - if (!ThreadSafeAskFee(nFeeRequired, _("Sending..."), this)) - { - Error(_("Transaction aborted")); - return; - } + // Transaction fee + if (!ThreadSafeAskFee(nFeeRequired, _("Sending..."), this)) + { + Error(_("Transaction aborted")); + return; + } - // Make sure we're still connected - CNode* pnode = ConnectNode(addr, 2 * 60 * 60); - if (!pnode) - { - Error(_("Lost connection, transaction cancelled")); - return; - } + // Make sure we're still connected + CNode* pnode = ConnectNode(addr, 2 * 60 * 60); + if (!pnode) + { + Error(_("Lost connection, transaction cancelled")); + return; + } - // Last chance to cancel - Sleep(50); + // Last chance to cancel + Sleep(50); + if (!Status()) + return; + fCanCancel = false; + if (fAbort) + { + fCanCancel = true; if (!Status()) return; fCanCancel = false; - if (fAbort) - { - fCanCancel = true; - if (!Status()) - return; - fCanCancel = false; - } - if (!Status(_("Sending payment..."))) - return; + } + if (!Status(_("Sending payment..."))) + return; - // Commit - if (!pwalletMain->CommitTransaction(wtx, reservekey)) - { - Error(_("The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.")); - return; - } + // Commit + bool fTxCommitted = false; + CRITICAL_BLOCK(cs_main) + CRITICAL_BLOCK(pwalletMain->cs_wallet) + { + fTxCommitted = pwalletMain->CommitTransaction(wtx, reservekey); + } + if (!fTxCommitted) + { + Error(_("The transaction was rejected. This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here.")); + return; + } - // Send payment tx to seller, with response going to OnReply3 via event handler - CWalletTx wtxSend = wtx; - wtxSend.fFromMe = false; - pnode->PushRequest("submitorder", wtxSend, SendingDialogOnReply3, this); + // Send payment tx to seller, with response going to OnReply3 via event handler + CWalletTx wtxSend = wtx; + wtxSend.fFromMe = false; + pnode->PushRequest("submitorder", wtxSend, SendingDialogOnReply3, this); - Status(_("Waiting for confirmation...")); - MainFrameRepaint(); - } + Status(_("Waiting for confirmation...")); + MainFrameRepaint(); } void SendingDialogOnReply3(void* parg, CDataStream& vRecv) @@ -2620,8 +2632,7 @@ CAddressBookDialog::CAddressBookDialog(wxWindow* parent, const wxString& strInit m_listCtrlReceiving->SetFocus(); // Fill listctrl with address book data - CRITICAL_BLOCK(pwalletMain->cs_KeyStore) - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) + CRITICAL_BLOCK(pwalletMain->cs_wallet) { string strDefaultReceiving = (string)pframeMain->m_textCtrlAddress->GetValue(); BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress, string)& item, pwalletMain->mapAddressBook) @@ -2682,7 +2693,7 @@ void CAddressBookDialog::OnListEndLabelEdit(wxListEvent& event) if (event.IsEditCancelled()) return; string strAddress = (string)GetItemText(m_listCtrl, event.GetIndex(), 1); - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) + CRITICAL_BLOCK(pwalletMain->cs_wallet) pwalletMain->SetAddressBookName(strAddress, string(event.GetText())); pframeMain->RefreshListCtrl(); } @@ -2718,7 +2729,7 @@ void CAddressBookDialog::OnButtonDelete(wxCommandEvent& event) if (m_listCtrl->GetItemState(nIndex, wxLIST_STATE_SELECTED)) { string strAddress = (string)GetItemText(m_listCtrl, nIndex, 1); - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) + CRITICAL_BLOCK(pwalletMain->cs_wallet) pwalletMain->DelAddressBookName(strAddress); m_listCtrl->DeleteItem(nIndex); } @@ -2778,7 +2789,7 @@ void CAddressBookDialog::OnButtonEdit(wxCommandEvent& event) } // Write back - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) + CRITICAL_BLOCK(pwalletMain->cs_wallet) { if (strAddress != strAddressOrg) pwalletMain->DelAddressBookName(strAddressOrg); @@ -2818,22 +2829,21 @@ void CAddressBookDialog::OnButtonNew(wxCommandEvent& event) return; strName = dialog.GetValue(); - CRITICAL_BLOCK(pwalletMain->cs_vMasterKey) - { - bool fWasLocked = pwalletMain->IsLocked(); - if (!GetWalletPassphrase()) - return; + bool fWasLocked = pwalletMain->IsLocked(); + if (!GetWalletPassphrase()) + return; - // Generate new key - strAddress = CBitcoinAddress(pwalletMain->GetOrReuseKeyFromPool()).ToString(); + // Generate new key + std::vector<unsigned char> newKey; + pwalletMain->GetKeyFromPool(newKey, true); + strAddress = CBitcoinAddress(newKey).ToString(); - if (fWasLocked) - pwalletMain->Lock(); - } + if (fWasLocked) + pwalletMain->Lock(); } // Add to list and select it - CRITICAL_BLOCK(pwalletMain->cs_mapAddressBook) + CRITICAL_BLOCK(pwalletMain->cs_wallet) pwalletMain->SetAddressBookName(strAddress, strName); int nIndex = InsertLine(m_listCtrl, strName, strAddress); SetSelection(m_listCtrl, nIndex); @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_UI_H diff --git a/src/uint256.h b/src/uint256.h index 14feb1683d..3e20201387 100644 --- a/src/uint256.h +++ b/src/uint256.h @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_UINT256_H diff --git a/src/util.cpp b/src/util.cpp index 7693aaa52a..76a2700271 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #include "headers.h" @@ -908,4 +909,140 @@ string FormatFullVersion() +#ifdef DEBUG_LOCKORDER +// +// Early deadlock detection. +// Problem being solved: +// Thread 1 locks A, then B, then C +// Thread 2 locks D, then C, then A +// --> may result in deadlock between the two threads, depending on when they run. +// Solution implemented here: +// Keep track of pairs of locks: (A before B), (A before C), etc. +// Complain if any thread trys to lock in a different order. +// + +struct CLockLocation +{ + CLockLocation(const char* pszName, const char* pszFile, int nLine) + { + mutexName = pszName; + sourceFile = pszFile; + sourceLine = nLine; + } + + std::string ToString() const + { + return mutexName+" "+sourceFile+":"+itostr(sourceLine); + } + +private: + std::string mutexName; + std::string sourceFile; + int sourceLine; +}; + +typedef std::vector< std::pair<CCriticalSection*, CLockLocation> > LockStack; + +static boost::interprocess::interprocess_mutex dd_mutex; +static std::map<std::pair<CCriticalSection*, CCriticalSection*>, LockStack> lockorders; +static boost::thread_specific_ptr<LockStack> lockstack; + + +static void potential_deadlock_detected(const std::pair<CCriticalSection*, CCriticalSection*>& mismatch, const LockStack& s1, const LockStack& s2) +{ + printf("POTENTIAL DEADLOCK DETECTED\n"); + printf("Previous lock order was:\n"); + BOOST_FOREACH(const PAIRTYPE(CCriticalSection*, CLockLocation)& i, s2) + { + if (i.first == mismatch.first) printf(" (1)"); + if (i.first == mismatch.second) printf(" (2)"); + printf(" %s\n", i.second.ToString().c_str()); + } + printf("Current lock order is:\n"); + BOOST_FOREACH(const PAIRTYPE(CCriticalSection*, CLockLocation)& i, s1) + { + if (i.first == mismatch.first) printf(" (1)"); + if (i.first == mismatch.second) printf(" (2)"); + printf(" %s\n", i.second.ToString().c_str()); + } +} + +static void push_lock(CCriticalSection* c, const CLockLocation& locklocation) +{ + bool fOrderOK = true; + if (lockstack.get() == NULL) + lockstack.reset(new LockStack); + + if (fDebug) printf("Locking: %s\n", locklocation.ToString().c_str()); + dd_mutex.lock(); + + (*lockstack).push_back(std::make_pair(c, locklocation)); + + BOOST_FOREACH(const PAIRTYPE(CCriticalSection*, CLockLocation)& i, (*lockstack)) + { + if (i.first == c) break; + + std::pair<CCriticalSection*, CCriticalSection*> p1 = std::make_pair(i.first, c); + if (lockorders.count(p1)) + continue; + lockorders[p1] = (*lockstack); + + std::pair<CCriticalSection*, CCriticalSection*> p2 = std::make_pair(c, i.first); + if (lockorders.count(p2)) + { + potential_deadlock_detected(p1, lockorders[p2], lockorders[p1]); + break; + } + } + dd_mutex.unlock(); +} + +static void pop_lock() +{ + if (fDebug) + { + const CLockLocation& locklocation = (*lockstack).rbegin()->second; + printf("Unlocked: %s\n", locklocation.ToString().c_str()); + } + dd_mutex.lock(); + (*lockstack).pop_back(); + dd_mutex.unlock(); +} + +void CCriticalSection::Enter(const char* pszName, const char* pszFile, int nLine) +{ + push_lock(this, CLockLocation(pszName, pszFile, nLine)); + mutex.lock(); +} +void CCriticalSection::Leave() +{ + mutex.unlock(); + pop_lock(); +} +bool CCriticalSection::TryEnter(const char* pszName, const char* pszFile, int nLine) +{ + push_lock(this, CLockLocation(pszName, pszFile, nLine)); + bool result = mutex.try_lock(); + if (!result) pop_lock(); + return result; +} + +#else + +void CCriticalSection::Enter(const char*, const char*, int) +{ + mutex.lock(); +} + +void CCriticalSection::Leave() +{ + mutex.unlock(); +} + +bool CCriticalSection::TryEnter(const char*, const char*, int) +{ + bool result = mutex.try_lock(); + return result; +} +#endif /* DEBUG_LOCKORDER */ diff --git a/src/util.h b/src/util.h index 8588201dae..3d7ef108b4 100644 --- a/src/util.h +++ b/src/util.h @@ -1,4 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_UTIL_H @@ -66,14 +67,6 @@ typedef unsigned long long uint64; // This is needed because the foreach macro can't get over the comma in pair<t1, t2> #define PAIRTYPE(t1, t2) pair<t1, t2> -// Used to bypass the rule against non-const reference to temporary -// where it makes sense with wrappers such as CFlatData or CTxDB -template<typename T> -inline T& REF(const T& val) -{ - return (T&)val; -} - // Align by increasing pointer, must have extra space at end of buffer template <size_t nBytes, typename T> T* alignup(T* p) @@ -222,31 +215,17 @@ std::string FormatFullVersion(); -// Wrapper to automatically initialize critical sections +// Wrapper to automatically initialize mutex class CCriticalSection { -#ifdef __WXMSW__ -protected: - CRITICAL_SECTION cs; -public: - explicit CCriticalSection() { InitializeCriticalSection(&cs); } - ~CCriticalSection() { DeleteCriticalSection(&cs); } - void Enter() { EnterCriticalSection(&cs); } - void Leave() { LeaveCriticalSection(&cs); } - bool TryEnter() { return TryEnterCriticalSection(&cs); } -#else protected: boost::interprocess::interprocess_recursive_mutex mutex; public: explicit CCriticalSection() { } ~CCriticalSection() { } - void Enter() { mutex.lock(); } - void Leave() { mutex.unlock(); } - bool TryEnter() { return mutex.try_lock(); } -#endif -public: - const char* pszFile; - int nLine; + void Enter(const char* pszName, const char* pszFile, int nLine); + void Leave(); + bool TryEnter(const char* pszName, const char* pszFile, int nLine); }; // Automatically leave critical section when leaving block, needed for exception safety @@ -254,9 +233,17 @@ class CCriticalBlock { protected: CCriticalSection* pcs; + public: - CCriticalBlock(CCriticalSection& csIn) { pcs = &csIn; pcs->Enter(); } - ~CCriticalBlock() { pcs->Leave(); } + CCriticalBlock(CCriticalSection& csIn, const char* pszName, const char* pszFile, int nLine) + { + pcs = &csIn; + pcs->Enter(pszName, pszFile, nLine); + } + ~CCriticalBlock() + { + pcs->Leave(); + } }; // WARNING: This will catch continue and break! @@ -264,22 +251,32 @@ public: // I'd rather be careful than suffer the other more error prone syntax. // The compiler will optimise away all this loop junk. #define CRITICAL_BLOCK(cs) \ - for (bool fcriticalblockonce=true; fcriticalblockonce; assert("break caught by CRITICAL_BLOCK!" && !fcriticalblockonce), fcriticalblockonce=false) \ - for (CCriticalBlock criticalblock(cs); fcriticalblockonce && (cs.pszFile=__FILE__, cs.nLine=__LINE__, true); fcriticalblockonce=false, cs.pszFile=NULL, cs.nLine=0) + for (bool fcriticalblockonce=true; fcriticalblockonce; assert(("break caught by CRITICAL_BLOCK!" && !fcriticalblockonce)), fcriticalblockonce=false) \ + for (CCriticalBlock criticalblock(cs, #cs, __FILE__, __LINE__); fcriticalblockonce; fcriticalblockonce=false) class CTryCriticalBlock { protected: CCriticalSection* pcs; + public: - CTryCriticalBlock(CCriticalSection& csIn) { pcs = (csIn.TryEnter() ? &csIn : NULL); } - ~CTryCriticalBlock() { if (pcs) pcs->Leave(); } + CTryCriticalBlock(CCriticalSection& csIn, const char* pszName, const char* pszFile, int nLine) + { + pcs = (csIn.TryEnter(pszName, pszFile, nLine) ? &csIn : NULL); + } + ~CTryCriticalBlock() + { + if (pcs) + { + pcs->Leave(); + } + } bool Entered() { return pcs != NULL; } }; #define TRY_CRITICAL_BLOCK(cs) \ - for (bool fcriticalblockonce=true; fcriticalblockonce; assert("break caught by TRY_CRITICAL_BLOCK!" && !fcriticalblockonce), fcriticalblockonce=false) \ - for (CTryCriticalBlock criticalblock(cs); fcriticalblockonce && (fcriticalblockonce = criticalblock.Entered()) && (cs.pszFile=__FILE__, cs.nLine=__LINE__, true); fcriticalblockonce=false, cs.pszFile=NULL, cs.nLine=0) + for (bool fcriticalblockonce=true; fcriticalblockonce; assert(("break caught by TRY_CRITICAL_BLOCK!" && !fcriticalblockonce)), fcriticalblockonce=false) \ + for (CTryCriticalBlock criticalblock(cs, #cs, __FILE__, __LINE__); fcriticalblockonce && (fcriticalblockonce = criticalblock.Entered()); fcriticalblockonce=false) diff --git a/src/wallet.cpp b/src/wallet.cpp index 1f3f44bfa0..8bbb80cf25 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1,4 +1,5 @@ -// Copyright (c) 2009-2011 Satoshi Nakamoto & Bitcoin developers +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. @@ -32,7 +33,7 @@ bool CWallet::AddCryptedKey(const vector<unsigned char> &vchPubKey, const vector return false; if (!fFileBacked) return true; - CRITICAL_BLOCK(cs_pwalletdbEncryption) + CRITICAL_BLOCK(cs_wallet) { if (pwalletdbEncryption) return pwalletdbEncryption->WriteCryptedKey(vchPubKey, vchCryptedSecret); @@ -43,14 +44,13 @@ bool CWallet::AddCryptedKey(const vector<unsigned char> &vchPubKey, const vector bool CWallet::Unlock(const string& strWalletPassphrase) { - CRITICAL_BLOCK(cs_vMasterKey) - { - if (!IsLocked()) - return false; + if (!IsLocked()) + return false; - CCrypter crypter; - CKeyingMaterial vMasterKey; + CCrypter crypter; + CKeyingMaterial vMasterKey; + CRITICAL_BLOCK(cs_wallet) BOOST_FOREACH(const MasterKeyMap::value_type& pMasterKey, mapMasterKeys) { if(!crypter.SetKeyFromPassphrase(strWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) @@ -60,16 +60,15 @@ bool CWallet::Unlock(const string& strWalletPassphrase) if (CCryptoKeyStore::Unlock(vMasterKey)) return true; } - } return false; } bool CWallet::ChangeWalletPassphrase(const string& strOldWalletPassphrase, const string& strNewWalletPassphrase) { - CRITICAL_BLOCK(cs_vMasterKey) - { - bool fWasLocked = IsLocked(); + bool fWasLocked = IsLocked(); + CRITICAL_BLOCK(cs_wallet) + { Lock(); CCrypter crypter; @@ -78,7 +77,7 @@ bool CWallet::ChangeWalletPassphrase(const string& strOldWalletPassphrase, const { if(!crypter.SetKeyFromPassphrase(strOldWalletPassphrase, pMasterKey.second.vchSalt, pMasterKey.second.nDeriveIterations, pMasterKey.second.nDerivationMethod)) return false; - if(!crypter.Decrypt(pMasterKey.second.vchCryptedKey, vMasterKey)) + if (!crypter.Decrypt(pMasterKey.second.vchCryptedKey, vMasterKey)) return false; if (CCryptoKeyStore::Unlock(vMasterKey)) { @@ -106,6 +105,7 @@ bool CWallet::ChangeWalletPassphrase(const string& strOldWalletPassphrase, const } } } + return false; } @@ -124,44 +124,42 @@ public: bool CWallet::EncryptWallet(const string& strWalletPassphrase) { - CRITICAL_BLOCK(cs_KeyStore) - CRITICAL_BLOCK(cs_vMasterKey) - CRITICAL_BLOCK(cs_pwalletdbEncryption) - { - if (IsCrypted()) - return false; + if (IsCrypted()) + return false; - CKeyingMaterial vMasterKey; - RandAddSeedPerfmon(); + CKeyingMaterial vMasterKey; + RandAddSeedPerfmon(); - vMasterKey.resize(WALLET_CRYPTO_KEY_SIZE); - RAND_bytes(&vMasterKey[0], WALLET_CRYPTO_KEY_SIZE); + vMasterKey.resize(WALLET_CRYPTO_KEY_SIZE); + RAND_bytes(&vMasterKey[0], WALLET_CRYPTO_KEY_SIZE); - CMasterKey kMasterKey; + CMasterKey kMasterKey; - RandAddSeedPerfmon(); - kMasterKey.vchSalt.resize(WALLET_CRYPTO_SALT_SIZE); - RAND_bytes(&kMasterKey.vchSalt[0], WALLET_CRYPTO_SALT_SIZE); + RandAddSeedPerfmon(); + kMasterKey.vchSalt.resize(WALLET_CRYPTO_SALT_SIZE); + RAND_bytes(&kMasterKey.vchSalt[0], WALLET_CRYPTO_SALT_SIZE); - CCrypter crypter; - int64 nStartTime = GetTimeMillis(); - crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, 25000, kMasterKey.nDerivationMethod); - kMasterKey.nDeriveIterations = 2500000 / ((double)(GetTimeMillis() - nStartTime)); + CCrypter crypter; + int64 nStartTime = GetTimeMillis(); + crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, 25000, kMasterKey.nDerivationMethod); + kMasterKey.nDeriveIterations = 2500000 / ((double)(GetTimeMillis() - nStartTime)); - nStartTime = GetTimeMillis(); - crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, kMasterKey.nDeriveIterations, kMasterKey.nDerivationMethod); - kMasterKey.nDeriveIterations = (kMasterKey.nDeriveIterations + kMasterKey.nDeriveIterations * 100 / ((double)(GetTimeMillis() - nStartTime))) / 2; + nStartTime = GetTimeMillis(); + crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, kMasterKey.nDeriveIterations, kMasterKey.nDerivationMethod); + kMasterKey.nDeriveIterations = (kMasterKey.nDeriveIterations + kMasterKey.nDeriveIterations * 100 / ((double)(GetTimeMillis() - nStartTime))) / 2; - if (kMasterKey.nDeriveIterations < 25000) - kMasterKey.nDeriveIterations = 25000; + if (kMasterKey.nDeriveIterations < 25000) + kMasterKey.nDeriveIterations = 25000; - printf("Encrypting Wallet with an nDeriveIterations of %i\n", kMasterKey.nDeriveIterations); + printf("Encrypting Wallet with an nDeriveIterations of %i\n", kMasterKey.nDeriveIterations); - if (!crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, kMasterKey.nDeriveIterations, kMasterKey.nDerivationMethod)) - return false; - if (!crypter.Encrypt(vMasterKey, kMasterKey.vchCryptedKey)) - return false; + if (!crypter.SetKeyFromPassphrase(strWalletPassphrase, kMasterKey.vchSalt, kMasterKey.nDeriveIterations, kMasterKey.nDerivationMethod)) + return false; + if (!crypter.Encrypt(vMasterKey, kMasterKey.vchCryptedKey)) + return false; + CRITICAL_BLOCK(cs_wallet) + { mapMasterKeys[++nMasterKeyMaxID] = kMasterKey; if (fFileBacked) { @@ -190,6 +188,7 @@ bool CWallet::EncryptWallet(const string& strWalletPassphrase) Lock(); } + return true; } @@ -198,7 +197,7 @@ void CWallet::WalletUpdateSpent(const CTransaction &tx) // Anytime a signature is successfully verified, it's proof the outpoint is spent. // Update the wallet spent flag if it doesn't know due to wallet.dat being // restored from backup or the user making copies of wallet.dat. - CRITICAL_BLOCK(cs_mapWallet) + CRITICAL_BLOCK(cs_wallet) { BOOST_FOREACH(const CTxIn& txin, tx.vin) { @@ -221,7 +220,7 @@ void CWallet::WalletUpdateSpent(const CTransaction &tx) bool CWallet::AddToWallet(const CWalletTx& wtxIn) { uint256 hash = wtxIn.GetHash(); - CRITICAL_BLOCK(cs_mapWallet) + CRITICAL_BLOCK(cs_wallet) { // Inserts only if not already there, returns tx inserted or tx found pair<map<uint256, CWalletTx>::iterator, bool> ret = mapWallet.insert(make_pair(hash, wtxIn)); @@ -269,8 +268,12 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn) { if (txout.scriptPubKey == scriptDefaultKey) { - SetDefaultKey(GetOrReuseKeyFromPool()); - SetAddressBookName(CBitcoinAddress(vchDefaultKey), ""); + std::vector<unsigned char> newDefaultKey; + if (GetKeyFromPool(newDefaultKey, false)) + { + SetDefaultKey(newDefaultKey); + SetAddressBookName(CBitcoinAddress(vchDefaultKey), ""); + } } } @@ -289,18 +292,21 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn) bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { uint256 hash = tx.GetHash(); - bool fExisted = mapWallet.count(hash); - if (fExisted && !fUpdate) return false; - if (fExisted || IsMine(tx) || IsFromMe(tx)) + CRITICAL_BLOCK(cs_wallet) { - CWalletTx wtx(this,tx); - // Get merkle branch if transaction was found in a block - if (pblock) - wtx.SetMerkleBranch(pblock); - return AddToWallet(wtx); + bool fExisted = mapWallet.count(hash); + if (fExisted && !fUpdate) return false; + if (fExisted || IsMine(tx) || IsFromMe(tx)) + { + CWalletTx wtx(this,tx); + // Get merkle branch if transaction was found in a block + if (pblock) + wtx.SetMerkleBranch(pblock); + return AddToWallet(wtx); + } + else + WalletUpdateSpent(tx); } - else - WalletUpdateSpent(tx); return false; } @@ -308,7 +314,7 @@ bool CWallet::EraseFromWallet(uint256 hash) { if (!fFileBacked) return false; - CRITICAL_BLOCK(cs_mapWallet) + CRITICAL_BLOCK(cs_wallet) { if (mapWallet.erase(hash)) CWalletDB(strWalletFile).EraseTx(hash); @@ -319,7 +325,7 @@ bool CWallet::EraseFromWallet(uint256 hash) bool CWallet::IsMine(const CTxIn &txin) const { - CRITICAL_BLOCK(cs_mapWallet) + CRITICAL_BLOCK(cs_wallet) { map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(txin.prevout.hash); if (mi != mapWallet.end()) @@ -335,7 +341,7 @@ bool CWallet::IsMine(const CTxIn &txin) const int64 CWallet::GetDebit(const CTxIn &txin) const { - CRITICAL_BLOCK(cs_mapWallet) + CRITICAL_BLOCK(cs_wallet) { map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(txin.prevout.hash); if (mi != mapWallet.end()) @@ -351,19 +357,6 @@ int64 CWallet::GetDebit(const CTxIn &txin) const int64 CWalletTx::GetTxTime() const { - if (!fTimeReceivedIsTxTime && hashBlock != 0) - { - // If we did not receive the transaction directly, we rely on the block's - // time to figure out when it happened. We use the median over a range - // of blocks to try to filter out inaccurate block times. - map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock); - if (mi != mapBlockIndex.end()) - { - CBlockIndex* pindex = (*mi).second; - if (pindex) - return pindex->GetMedianTime(); - } - } return nTimeReceived; } @@ -371,7 +364,7 @@ int CWalletTx::GetRequestCount() const { // Returns -1 if it wasn't being tracked int nRequests = -1; - CRITICAL_BLOCK(pwallet->cs_mapRequestCount) + CRITICAL_BLOCK(pwallet->cs_wallet) { if (IsCoinBase()) { @@ -477,7 +470,7 @@ void CWalletTx::GetAccountAmounts(const string& strAccount, int64& nGenerated, i nSent += s.second; nFee = allFee; } - CRITICAL_BLOCK(pwallet->cs_mapAddressBook) + CRITICAL_BLOCK(pwallet->cs_wallet) { BOOST_FOREACH(const PAIRTYPE(CBitcoinAddress,int64)& r, listReceived) { @@ -507,7 +500,7 @@ void CWalletTx::AddSupportingTransactions(CTxDB& txdb) vWorkQueue.push_back(txin.prevout.hash); // This critsect is OK because txdb is already open - CRITICAL_BLOCK(pwallet->cs_mapWallet) + CRITICAL_BLOCK(pwallet->cs_wallet) { map<uint256, const CMerkleTx*> mapWalletPrev; set<uint256> setAlreadyDone; @@ -563,7 +556,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) int ret = 0; CBlockIndex* pindex = pindexStart; - CRITICAL_BLOCK(cs_mapWallet) + CRITICAL_BLOCK(cs_wallet) { while (pindex) { @@ -584,7 +577,7 @@ void CWallet::ReacceptWalletTransactions() { CTxDB txdb("r"); bool fRepeat = true; - while (fRepeat) CRITICAL_BLOCK(cs_mapWallet) + while (fRepeat) CRITICAL_BLOCK(cs_wallet) { fRepeat = false; vector<CDiskTxPos> vMissingTx; @@ -687,7 +680,7 @@ void CWallet::ResendWalletTransactions() // Rebroadcast any of our txes that aren't in a block yet printf("ResendWalletTransactions()\n"); CTxDB txdb("r"); - CRITICAL_BLOCK(cs_mapWallet) + CRITICAL_BLOCK(cs_wallet) { // Sort them in chronological order multimap<unsigned int, CWalletTx*> mapSorted; @@ -721,7 +714,7 @@ void CWallet::ResendWalletTransactions() int64 CWallet::GetBalance() const { int64 nTotal = 0; - CRITICAL_BLOCK(cs_mapWallet) + CRITICAL_BLOCK(cs_wallet) { for (map<uint256, CWalletTx>::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { @@ -748,7 +741,7 @@ bool CWallet::SelectCoinsMinConf(int64 nTargetValue, int nConfMine, int nConfThe vector<pair<int64, pair<const CWalletTx*,unsigned int> > > vValue; int64 nTotalLower = 0; - CRITICAL_BLOCK(cs_mapWallet) + CRITICAL_BLOCK(cs_wallet) { vector<const CWalletTx*> vCoins; vCoins.reserve(mapWallet.size()); @@ -906,10 +899,10 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64> >& vecSend, CW wtxNew.pwallet = this; CRITICAL_BLOCK(cs_main) + CRITICAL_BLOCK(cs_wallet) { // txdb must be opened before the mapWallet lock CTxDB txdb("r"); - CRITICAL_BLOCK(cs_mapWallet) { nFeeRet = nTransactionFee; loop @@ -1020,9 +1013,9 @@ bool CWallet::CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& w bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) { CRITICAL_BLOCK(cs_main) + CRITICAL_BLOCK(cs_wallet) { printf("CommitTransaction:\n%s", wtxNew.ToString().c_str()); - CRITICAL_BLOCK(cs_mapWallet) { // This is only to keep the database open to defeat the auto-flush for the // duration of this scope. This is the only place where this optimization @@ -1052,8 +1045,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) } // Track how many getdata requests our transaction gets - CRITICAL_BLOCK(cs_mapRequestCount) - mapRequestCount[wtxNew.GetHash()] = 0; + mapRequestCount[wtxNew.GetHash()] = 0; // Broadcast if (!wtxNew.AcceptToMemoryPool()) @@ -1071,29 +1063,26 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) -// requires cs_main lock string CWallet::SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee) { CReserveKey reservekey(this); int64 nFeeRequired; - CRITICAL_BLOCK(cs_vMasterKey) + + if (IsLocked()) { - if (IsLocked()) - { - string strError = _("Error: Wallet locked, unable to create transaction "); - printf("SendMoney() : %s", strError.c_str()); - return strError; - } - if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired)) - { - string strError; - if (nValue + nFeeRequired > GetBalance()) - strError = strprintf(_("Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds "), FormatMoney(nFeeRequired).c_str()); - else - strError = _("Error: Transaction creation failed "); - printf("SendMoney() : %s", strError.c_str()); - return strError; - } + string strError = _("Error: Wallet locked, unable to create transaction "); + printf("SendMoney() : %s", strError.c_str()); + return strError; + } + if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired)) + { + string strError; + if (nValue + nFeeRequired > GetBalance()) + strError = strprintf(_("Error: This transaction requires a transaction fee of at least %s because of its amount, complexity, or use of recently received funds "), FormatMoney(nFeeRequired).c_str()); + else + strError = _("Error: Transaction creation failed "); + printf("SendMoney() : %s", strError.c_str()); + return strError; } if (fAskFee && !ThreadSafeAskFee(nFeeRequired, _("Sending..."), NULL)) @@ -1108,7 +1097,6 @@ string CWallet::SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, -// requires cs_main lock string CWallet::SendMoneyToBitcoinAddress(const CBitcoinAddress& address, int64 nValue, CWalletTx& wtxNew, bool fAskFee) { // Check amount @@ -1142,7 +1130,10 @@ int CWallet::LoadWallet(bool& fFirstRunRet) // Create new keyUser and set as default key RandAddSeedPerfmon(); - SetDefaultKey(GetOrReuseKeyFromPool()); + std::vector<unsigned char> newDefaultKey; + if (!GetKeyFromPool(newDefaultKey, false)) + return DB_LOAD_FAIL; + SetDefaultKey(newDefaultKey); if (!SetAddressBookName(CBitcoinAddress(vchDefaultKey), "")) return DB_LOAD_FAIL; } @@ -1171,7 +1162,7 @@ bool CWallet::DelAddressBookName(const CBitcoinAddress& address) void CWallet::PrintWallet(const CBlock& block) { - CRITICAL_BLOCK(cs_mapWallet) + CRITICAL_BLOCK(cs_wallet) { if (mapWallet.count(block.vtx[0].GetHash())) { @@ -1184,7 +1175,7 @@ void CWallet::PrintWallet(const CBlock& block) bool CWallet::GetTransaction(const uint256 &hashTx, CWalletTx& wtx) { - CRITICAL_BLOCK(cs_mapWallet) + CRITICAL_BLOCK(cs_wallet) { map<uint256, CWalletTx>::iterator mi = mapWallet.find(hashTx); if (mi != mapWallet.end()) @@ -1217,10 +1208,7 @@ bool GetWalletFile(CWallet* pwallet, string &strWalletFileOut) bool CWallet::TopUpKeyPool() { - CRITICAL_BLOCK(cs_main) - CRITICAL_BLOCK(cs_mapWallet) - CRITICAL_BLOCK(cs_setKeyPool) - CRITICAL_BLOCK(cs_vMasterKey) + CRITICAL_BLOCK(cs_wallet) { if (IsLocked()) return false; @@ -1247,9 +1235,7 @@ void CWallet::ReserveKeyFromKeyPool(int64& nIndex, CKeyPool& keypool) { nIndex = -1; keypool.vchPubKey.clear(); - CRITICAL_BLOCK(cs_main) - CRITICAL_BLOCK(cs_mapWallet) - CRITICAL_BLOCK(cs_setKeyPool) + CRITICAL_BLOCK(cs_wallet) { if (!IsLocked()) TopUpKeyPool(); @@ -1277,10 +1263,7 @@ void CWallet::KeepKey(int64 nIndex) if (fFileBacked) { CWalletDB walletdb(strWalletFile); - CRITICAL_BLOCK(cs_main) - { - walletdb.ErasePool(nIndex); - } + walletdb.ErasePool(nIndex); } printf("keypool keep %"PRI64d"\n", nIndex); } @@ -1288,20 +1271,33 @@ void CWallet::KeepKey(int64 nIndex) void CWallet::ReturnKey(int64 nIndex) { // Return to key pool - CRITICAL_BLOCK(cs_setKeyPool) + CRITICAL_BLOCK(cs_wallet) setKeyPool.insert(nIndex); printf("keypool return %"PRI64d"\n", nIndex); } -vector<unsigned char> CWallet::GetOrReuseKeyFromPool() +bool CWallet::GetKeyFromPool(vector<unsigned char>& result, bool fAllowReuse) { int64 nIndex = 0; CKeyPool keypool; - ReserveKeyFromKeyPool(nIndex, keypool); - if(nIndex == -1) - return vchDefaultKey; - KeepKey(nIndex); - return keypool.vchPubKey; + CRITICAL_BLOCK(cs_wallet) + { + ReserveKeyFromKeyPool(nIndex, keypool); + if (nIndex == -1) + { + if (fAllowReuse && !vchDefaultKey.empty()) + { + result = vchDefaultKey; + return true; + } + if (IsLocked()) return false; + result = GenerateNewKey(); + return true; + } + KeepKey(nIndex); + result = keypool.vchPubKey; + } + return true; } int64 CWallet::GetOldestKeyPoolTime() diff --git a/src/wallet.h b/src/wallet.h index 51dfa5df5b..1dd2e51260 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -1,4 +1,5 @@ -// Copyright (c) 2009-2011 Satoshi Nakamoto & Bitcoin developers +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2011 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_WALLET_H @@ -19,14 +20,14 @@ private: bool SelectCoins(int64 nTargetValue, std::set<std::pair<const CWalletTx*,unsigned int> >& setCoinsRet, int64& nValueRet) const; CWalletDB *pwalletdbEncryption; - CCriticalSection cs_pwalletdbEncryption; public: + mutable CCriticalSection cs_wallet; + bool fFileBacked; std::string strWalletFile; std::set<int64> setKeyPool; - CCriticalSection cs_setKeyPool; typedef std::map<unsigned int, CMasterKey> MasterKeyMap; MasterKeyMap mapMasterKeys; @@ -46,15 +47,12 @@ public: pwalletdbEncryption = NULL; } - mutable CCriticalSection cs_mapWallet; std::map<uint256, CWalletTx> mapWallet; std::vector<uint256> vWalletUpdated; std::map<uint256, int> mapRequestCount; - mutable CCriticalSection cs_mapRequestCount; std::map<CBitcoinAddress, std::string> mapAddressBook; - mutable CCriticalSection cs_mapAddressBook; std::vector<unsigned char> vchDefaultKey; @@ -87,7 +85,7 @@ public: void ReserveKeyFromKeyPool(int64& nIndex, CKeyPool& keypool); void KeepKey(int64 nIndex); void ReturnKey(int64 nIndex); - std::vector<unsigned char> GetOrReuseKeyFromPool(); + bool GetKeyFromPool(std::vector<unsigned char> &key, bool fAllowReuse=true); int64 GetOldestKeyPoolTime(); bool IsMine(const CTxIn& txin) const; @@ -106,7 +104,7 @@ public: { CBitcoinAddress address; if (ExtractAddress(txout.scriptPubKey, this, address)) - CRITICAL_BLOCK(cs_mapAddressBook) + CRITICAL_BLOCK(cs_wallet) if (!mapAddressBook.count(address)) return true; return false; @@ -170,15 +168,13 @@ public: int LoadWallet(bool& fFirstRunRet); // bool BackupWallet(const std::string& strDest); - // requires cs_mapAddressBook lock bool SetAddressBookName(const CBitcoinAddress& address, const std::string& strName); - // requires cs_mapAddressBook lock bool DelAddressBookName(const CBitcoinAddress& address); void UpdatedTransaction(const uint256 &hashTx) { - CRITICAL_BLOCK(cs_mapWallet) + CRITICAL_BLOCK(cs_wallet) vWalletUpdated.push_back(hashTx); } @@ -186,7 +182,7 @@ public: void Inventory(const uint256 &hash) { - CRITICAL_BLOCK(cs_mapRequestCount) + CRITICAL_BLOCK(cs_wallet) { std::map<uint256, int>::iterator mi = mapRequestCount.find(hash); if (mi != mapRequestCount.end()) |