Skip to content

Commit

Permalink
Porting to Darkcoin TESTNET
Browse files Browse the repository at this point in the history
Updated sources for Darkcoin TESTNET
  • Loading branch information
ccur108 committed Jun 29, 2014
1 parent acc9b64 commit 623fe5e
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 22 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Darkcoin (DRK) Electrum-server for the Electrum client
======================================================
Porting of the Electrum server to Darkcoin.
Since there is no Electrum client yet, current sources work in Darkcoin TESTNET.
Install procedure isn't changed. Website to download the leveldb not available.
Any DRK tips here: XxEUFhbXPbuX58o1AbDqZssFebyNuBosxb
Thanks!

Electrum-server for the Electrum client
=========================================

Expand All @@ -11,12 +19,12 @@ Features
described by Alan Reiner (see the 'ultimate blockchain
compression' thread in the Bitcointalk forum)

* The server requires litecoind, leveldb and plyvel
* The server requires darkcoind, leveldb and plyvel

* The server code is open source. Anyone can run a server, removing
single points of failure concerns.

* The server knows which set of Litecoin addresses belong to the same
* The server knows which set of Darkcoin addresses belong to the same
wallet, which might raise concerns about anonymity. However, it
should be possible to write clients capable of using several
servers.
Expand Down
15 changes: 10 additions & 5 deletions backends/bitcoind/blockchain_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self, config, shared):
self.bitcoind('getinfo')
break
except:
print_log('cannot contact litecoind...')
print_log('cannot contact darkcoind...')
time.sleep(5)
continue

Expand Down Expand Up @@ -113,7 +113,7 @@ def bitcoind(self, method, params=[]):
try:
respdata = urllib.urlopen(self.bitcoind_url, postdata).read()
except:
print_log("error calling litecoind")
print_log("error calling darkcoind")
traceback.print_exc(file=sys.stdout)
self.shared.stop()

Expand Down Expand Up @@ -162,7 +162,12 @@ def init_headers(self, db_height):
height = height + 1
header = self.get_header(height)
if height > 1:
assert prev_hash == header.get('prev_block_hash')
#assert prev_hash == header.get('prev_block_hash')
if prev_hash != header.get('prev_block_hash'):
# The header in file seems to be orphaned, go back
height -= 2
prev_hash = self.hash_header(self.read_header(height))
continue
self.write_header(header, sync=False)
prev_hash = self.hash_header(header)
if (height % 1000) == 0:
Expand Down Expand Up @@ -618,7 +623,7 @@ def getfullblock(self, block_hash):
try:
respdata = urllib.urlopen(self.bitcoind_url, postdata).read()
except:
print_log("litecoind error (getfullblock)")
print_log("darkcoind error (getfullblock)")
traceback.print_exc(file=sys.stdout)
self.shared.stop()

Expand All @@ -627,7 +632,7 @@ def getfullblock(self, block_hash):
for ir in r:
if ir['error'] is not None:
self.shared.stop()
print_log("Error: make sure you run litecoind with txindex=1; use -reindex if needed.")
print_log("Error: make sure you run darkcoind with txindex=1; use -reindex if needed.")
raise BaseException(ir['error'])
rawtxdata.append(ir['result'])
block['tx'] = rawtxdata
Expand Down
3 changes: 2 additions & 1 deletion backends/bitcoind/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def __init__(self, config, shared, test_reorgs):
#traceback.print_exc(file=sys.stdout)
print_log('initializing database')
self.height = 0
self.last_hash = '12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2'
#mainnet self.last_hash = '00000ffd590b1485b3caadc19b22e6379c733355108f107a430458cdf3407ab6'
self.last_hash = '00000bafbc94add76cb75e2ec92894837288a481e5c005f6563d91623bf8bc2c'
db_version = self.db_version
# write root
self.put_node('', {})
Expand Down
4 changes: 2 additions & 2 deletions backends/irc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def run(self):
try:
s.send('USER electrum 0 * :' + self.host + ' ' + ircname + '\n')
s.send('NICK ' + self.nick + '\n')
s.send('JOIN #electrum-ltc\n')
s.send('JOIN #electrum-drk\n')
t = 0

while not self.processor.shared.stopped():
Expand Down Expand Up @@ -142,7 +142,7 @@ def run(self):

if time.time() - t > 5*60:
#self.processor.push_response({'method': 'server.peers', 'params': [self.get_peers()]})
s.send('NAMES #electrum-ltc\n')
s.send('NAMES #electrum-drk\n')
t = time.time()
self.peers = {}
except:
Expand Down
7 changes: 5 additions & 2 deletions electrum.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ pruning_limit = 100

[bitcoind]
host = localhost
port = 9332
# user and password from litecoin.conf
#testnet
port = 19998
#mainnet
#port = 9998
# user and password from darkcoin.conf
user = user
password = password
8 changes: 4 additions & 4 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ def create_config():
config.set('server', 'password', '')
config.set('server', 'irc', 'no')
config.set('server', 'irc_nick', '')
config.set('server', 'coin', 'litecoin')
config.set('server', 'coin', 'darkcoin')
config.set('server', 'datadir', '')

# use leveldb as default
config.set('server', 'backend', 'leveldb')
config.add_section('leveldb')
config.set('leveldb', 'path_fulltree', '/dev/shm/electrum-ltc_db')
config.set('leveldb', 'path_fulltree', '/dev/shm/electrum-drk_db')
config.set('leveldb', 'pruning_limit', '100')

for path in ('/etc/', ''):
filename = path + 'electrum-ltc.conf'
filename = path + 'electrum-drk.conf'
attempt_read_config(config, filename)

try:
with open('/etc/electrum-ltc.banner', 'r') as f:
with open('/etc/electrum-drk.banner', 'r') as f:
config.set('server', 'banner', f.read())
except IOError:
pass
Expand Down
8 changes: 4 additions & 4 deletions start
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [[ $PID != *[!0-9]* ]]; then
fi


electrum_config="/etc/electrum-ltc.conf"
electrum_config="/etc/electrum-drk.conf"

if [ ! -f $electrum_config ]; then
echo "$electrum_config does not exist"
Expand All @@ -26,13 +26,13 @@ rmdir $path --ignore-fail-on-non-empty

if [ ! -d $path ]; then
echo "Database not found in $path."
read -p "Do you want to download it from the Electrum-LTC foundry to $path ? " -n 1 -r
read -p "Do you want to download it from the Electrum-DRK foundry to $path ? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
mkdir -p $path
wget -O - "http://foundry.electrum-ltc.org/leveldb-dump/electrum-fulltree-100-latest.tar.gz" | tar --extract --gunzip --strip-components 1 --directory $path --file -
wget -O - "http://foundry.electrum-drk.org/leveldb-dump/electrum-fulltree-100-latest.tar.gz" | tar --extract --gunzip --strip-components 1 --directory $path --file -
fi
fi

echo "Starting server as daemon"
nohup /usr/bin/python -u server.py &> /var/log/electrum-ltc.log &
nohup /usr/bin/python -u server.py &> /var/log/electrum-drk.log &
4 changes: 2 additions & 2 deletions utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ def hash_160(public_key):
def public_key_to_bc_address(public_key):
return hash_160_to_bc_address(hash_160(public_key))


def hash_160_to_bc_address(h160, addrtype = 48):
#111=testnet 76=mainnet
def hash_160_to_bc_address(h160, addrtype = 111):
if h160 == 'None':
return 'None'
vh160 = chr(addrtype) + h160
Expand Down

0 comments on commit 623fe5e

Please sign in to comment.