write strange transactions if they have a nonzero value
authorThomasV <thomasv@gitorious>
Mon, 19 Nov 2012 17:06:33 +0000 (21:06 +0400)
committerThomasV <thomasv@gitorious>
Mon, 19 Nov 2012 17:06:33 +0000 (21:06 +0400)
README.leveldb [new file with mode: 0644]
backends/bitcoind/deserialize.py
backends/bitcoind/util.py

diff --git a/README.leveldb b/README.leveldb
new file mode 100644 (file)
index 0000000..e57b3a7
--- /dev/null
@@ -0,0 +1,62 @@
+How to run a pruning node with leveldb
+
+Pruning nodes use a lightweight database to store address histories.
+Only unspent coins are kept in that database; spent outputs are
+pruned.
+
+
+__________________________________________________________
+1. patch and compile bitcoind.
+
+Install version 0.8 or equivalent.
+
+Note: Even though Electrum's database uses pruning, you cannot use it
+with a pruning bitcoind. A full bitcoin node is required in order to
+know for each address if it has been used. Pruning occurs only at the
+level of the Electrum database.
+
+__________________________________________________________
+
+2. Install python-leveldb: 
+
+sudo apt-get install python-leveldb
+
+__________________________________________________________
+
+3. edit /etc/electrum.conf : 
+
+[server]
+backend = leveldb
+
+[leveldb]
+dbpath = /path/to/your/database
+
+______________________________________________________________
+
+4. catch up with the blockchain.
+
+In order to speed up the initial catch_up phase, it is recommended to
+locate your database in shared memory:
+
+ dbpath = /run/shm/electrum_db
+
+Once your server has finished catching up, copy your database to disk
+and update the path in /etc/electrum.conf
+
+During the catch_up phase, you can interrupt the server with Ctrl-C;
+it will safely write the current status in the database and exit.
+
+_________________________________
+
+5. enjoy!
+
+Once the server is synchronized, it will listen to ports, and the
+normal way to stop it is to type: ./server.py stop
+
+Other commands are available: 
+
+./server info   : view connections
+./server load   : view the size of the queue
+
+
+
index 613fa7c..614c15a 100644 (file)
@@ -289,8 +289,14 @@ def parse_Transaction(vds, is_coinbase):
   d['outputs'] = []
   for i in xrange(n_vout):
       o = parse_TxOut(vds, i)
-      if o['address'] != "(None)":
-          d['outputs'].append(o)
+
+      if o['address'] == "None" and o['value']==0:
+          print("skipping strange tx output with zero value")
+          continue
+
+      # if o['address'] != "None":
+      d['outputs'].append(o)
+
   d['lockTime'] = vds.read_uint32()
   return d
 
@@ -392,5 +398,10 @@ def extract_public_key(bytes):
   if match_decoded(decoded, match):
     return hash_160_to_bc_address(decoded[2][1])
 
+  # strange tx
+  match = [ opcodes.OP_DUP, opcodes.OP_HASH160, opcodes.OP_PUSHDATA4, opcodes.OP_EQUALVERIFY, opcodes.OP_CHECKSIG, opcodes.OP_NOP ]
+  if match_decoded(decoded, match):
+    return hash_160_to_bc_address(decoded[2][1])
+
   #raise BaseException("address not found in script") see ce35795fb64c268a52324b884793b3165233b1e6d678ccaadf760628ec34d76b
-  return "(None)"
+  return "None"
index 2f33d11..ec03b16 100644 (file)
@@ -83,10 +83,12 @@ def hash_160(public_key):
 
 
 def public_key_to_bc_address(public_key):
+    if public_key == 'None': return 'None'
     h160 = hash_160(public_key)
     return hash_160_to_bc_address(h160)
 
 def hash_160_to_bc_address(h160):
+    if h160 == 'None': return 'None'
     vh160 = chr(addrtype) + h160
     h = Hash(vh160)
     addr = vh160 + h[0:4]