Skip to content

Commit

Permalink
Add Litecoin network.
Browse files Browse the repository at this point in the history
  • Loading branch information
coblee committed Nov 6, 2011
1 parent c2f61ac commit 9b7cf5f
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*.pyc
*.dat
*.iml
*.log
*_shares.*
.idea
32 changes: 30 additions & 2 deletions p2pool/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from twisted.python import log

import p2pool
from p2pool import skiplists, namecoin, ixcoin, i0coin, solidcoin
from p2pool import skiplists, namecoin, ixcoin, i0coin, solidcoin, litecoin
from p2pool.bitcoin import data as bitcoin_data, script
from p2pool.util import memoize, expiring_dict, math

Expand Down Expand Up @@ -662,4 +662,32 @@ class SolidcoinMainnet(solidcoin.SolidcoinMainnet):
PERSIST = True
WORKER_PORT = 9328

nets = dict((net.NAME, net) for net in set([Mainnet, Testnet, NamecoinMainnet, NamecoinTestnet, IxcoinMainnet, IxcoinTestnet, I0coinMainnet, I0coinTestnet, SolidcoinMainnet]))
class LitecoinMainnet(litecoin.LitecoinMainnet):
SHARE_PERIOD = 10 # seconds
CHAIN_LENGTH = 24*60*60//5 # shares
TARGET_LOOKBEHIND = 200 # shares
SPREAD = 12 # blocks
SCRIPT = '410403ad3dee8ab3d8a9ce5dd2abfbe7364ccd9413df1d279bf1a207849310465b0956e5904b1155ecd17574778f9949589ebfd4fb33ce837c241474a225cf08d85dac'.decode('hex')
IDENTIFIER = 'e037d5b8c6923410'.decode('hex')
PREFIX = '7208c1a53ef629b0'.decode('hex')
NAME = 'litecoin'
P2P_PORT = 9338
MAX_TARGET = 2**256//2**32 - 1
PERSIST = True
WORKER_PORT = 9327

class LitecoinTestnet(litecoin.LitecoinTestnet):
SHARE_PERIOD = 1 # seconds
CHAIN_LENGTH = 24*60*60//5 # shares
TARGET_LOOKBEHIND = 200 # shares
SPREAD = 12 # blocks
SCRIPT = '410403ad3dee8ab3d8a9ce5dd2abfbe7364ccd9413df1d279bf1a207849310465b0956e5904b1155ecd17574778f9949589ebfd4fb33ce837c241474a225cf08d85dac'.decode('hex')
IDENTIFIER = 'cca5e24ec6408b1e'.decode('hex')
PREFIX = 'ad9614f6466a39cf'.decode('hex')
NAME = 'litecoin_testnet'
P2P_PORT = 19338
MAX_TARGET = 2**256//2**20 - 1
PERSIST = False
WORKER_PORT = 19327

nets = dict((net.NAME, net) for net in set([Mainnet, Testnet, NamecoinMainnet, NamecoinTestnet, IxcoinMainnet, IxcoinTestnet, I0coinMainnet, I0coinTestnet, SolidcoinMainnet, LitecoinMainnet, LitecoinTestnet]))
25 changes: 25 additions & 0 deletions p2pool/litecoin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from twisted.internet import defer

class LitecoinMainnet(object):
BITCOIN_P2P_PREFIX = 'fbc0b6db'.decode('hex')
BITCOIN_P2P_PORT = 9333
BITCOIN_ADDRESS_VERSION = 48
BITCOIN_RPC_PORT = 9332
BITCOIN_RPC_CHECK = staticmethod(defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
'litecoinaddress' in (yield bitcoind.rpc_help()) and
not (yield bitcoind.rpc_getinfo())['testnet']
)))
BITCOIN_SUBSIDY_FUNC = staticmethod(lambda height: 50*100000000 >> (height + 1)//840000)
BITCOIN_SYMBOL = 'LTC'

class LitecoinTestnet(object):
BITCOIN_P2P_PREFIX = 'fcc1b7dc'.decode('hex')
BITCOIN_P2P_PORT = 19333
BITCOIN_ADDRESS_VERSION = 111
BITCOIN_RPC_PORT = 19332
BITCOIN_RPC_CHECK = staticmethod(defer.inlineCallbacks(lambda bitcoind: defer.returnValue(
'litecoinaddress' in (yield bitcoind.rpc_help()) and
(yield bitcoind.rpc_getinfo())['testnet']
)))
BITCOIN_SUBSIDY_FUNC = staticmethod(lambda height: 50*100000000 >> (height + 1)//840000)
BITCOIN_SYMBOL = 'tLTC'
6 changes: 3 additions & 3 deletions p2pool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ def convert_arg_line_to_args(self, arg_line):

worker_group = parser.add_argument_group('worker interface')
worker_group.add_argument('-w', '--worker-port', metavar='PORT',
help='listen on PORT for RPC connections from miners asking for work and providing responses (default: bitcoin: 9332 namecoin: 9331 ixcoin: 9330 i0coin: 9329, +10000 for testnets)',
help='listen on PORT for RPC connections from miners asking for work and providing responses (default: bitcoin: 9332 namecoin: 9331 ixcoin: 9330 i0coin: 9329 solidcoin: 9328 litecoin: 9327, +10000 for testnets)',
type=int, action='store', default=None, dest='worker_port')
worker_group.add_argument('-f', '--fee', metavar='FEE_PERCENTAGE',
help='''charge workers mining to their own bitcoin address (by setting their miner's username to a bitcoin address) this percentage fee to mine on your p2pool instance. Amount displayed at http://127.0.0.1:9332/fee . default: 0''',
Expand All @@ -742,10 +742,10 @@ def convert_arg_line_to_args(self, arg_line):
help='connect to a bitcoind at this address (default: 127.0.0.1)',
type=str, action='store', default='127.0.0.1', dest='bitcoind_address')
bitcoind_group.add_argument('--bitcoind-rpc-port', metavar='BITCOIND_RPC_PORT',
help='connect to a bitcoind at this port over the RPC interface - used to get the current highest block via getwork (default: 8332, 8338 for ixcoin)',
help='connect to a bitcoind at this port over the RPC interface - used to get the current highest block via getwork (default: 8332 ixcoin: 8338 i0coin: 7332 litecoin: 9332)',
type=int, action='store', default=None, dest='bitcoind_rpc_port')
bitcoind_group.add_argument('--bitcoind-p2p-port', metavar='BITCOIND_P2P_PORT',
help='connect to a bitcoind at this port over the p2p interface - used to submit blocks and get the pubkey to generate to via an IP transaction (default: 8333 normally. 18333 for testnet)',
help='connect to a bitcoind at this port over the p2p interface - used to submit blocks and get the pubkey to generate to via an IP transaction (default: 8333 namecoin: 8334 ixcoin: 8337 i0coin: 7333 solidcoin: 7555 litecoin: 9333, +10000 for testnets)',
type=int, action='store', default=None, dest='bitcoind_p2p_port')

bitcoind_group.add_argument(metavar='BITCOIND_RPCUSER',
Expand Down

0 comments on commit 9b7cf5f

Please sign in to comment.