8000 Novacoin by ststuck · Pull Request #331 · p2pool/p2pool · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Novacoin #331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 24 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Requirements:
-------------------------
Generic:
* Bitcoin >=0.8.5
* Novacoin >=0.4.4.6
* Python >=2.6
* Twisted >=10.0.0
* python-argparse (for Python =2.6)
Expand All @@ -20,39 +20,8 @@ Windows:

Running P2Pool:
-------------------------
To use P2Pool, you must be running your own local bitcoind. For standard
configurations, using P2Pool should be as simple as:

python run_p2pool.py

Then run your miner program, connecting to 127.0.0.1 on port 9332 with any
username and password.

If you are behind a NAT, you should enable TCP port forwarding on your
router. Forward port 9333 to the host running P2Pool.

Run for additional options.

python run_p2pool.py --help

Donations towards further development:
-------------------------
1HNeqi3pJRNvXybNX4FKzZgYJsdTSqJTbk

Official wiki :
-------------------------
https://en.bitcoin.it/wiki/P2Pool

Alternate web front end :
-------------------------
* https://github.com/hardcpp/P2PoolExtendedFrontEnd

Notes for Litecoin:
=========================
Requirements:
-------------------------
In order to run P2Pool with the Litecoin network, you would need to build and install the
ltc_scrypt module that includes the scrypt proof of work code that Litecoin uses for hashes.
In order to run P2Pool with the Novacoin network, you would need to build and install the
ltc_scrypt module that includes the scrypt proof of work code that Novacoin uses for hashes.

Linux:

Expand All @@ -77,27 +46,33 @@ In bash type this:
SET VS90COMNTOOLS=%VS100COMNTOOLS% # For visual c++ 2010
cd litecoin_scrypt
C:\Python27\python.exe setup.py build --compile=mingw32 install

If you run into an error with unrecognized command line option '-mno-cygwin', see this:
http://stackoverflow.com/questions/6034390/compiling-with-cython-and-mingw-produces-gcc-error-unrecognized-command-line-o

Running P2Pool:
-------------------------
Run P2Pool with the "--net litecoin" option.
Run your miner program, connecting to 127.0.0.1 on port 9327.
Forward port 9338 to the host running P2Pool.
To use P2Pool, you must be running your own local bitcoind. For standard
configurations, using P2Pool should be as simple as:

python run_p2pool.py

Litecoin's use of ports 9332 and 9332 conflicts with P2Pool running on
the Bitcoin network. To avoid problems, add these lines to litecoin.conf
and restart litecoind:
Then run your miner program, connecting to 127.0.0.1 on port 8336 with any
username and password.

rpcport=10332
port=10333
If you are behind a NAT, you should enable TCP port forwarding on your
router. Forward port 8777 to the host running P2Pool.

Sponsors:
Run for additional options.

python run_p2pool.py --help

Donations towards further development:
-------------------------
4MRHGnDQVwgC2nacnEieJrrv97RNYZBm6i

Thanks to:
* The Bitcoin Foundation for its generous support of P2Pool
* The Litecoin Project for its generous donations to P2Pool
Official wiki :
-------------------------
https://en.bitcoin.it/wiki/P2Pool

Alternate web front end :
-------------------------
* https://github.com/hardcpp/P2PoolExtendedFrontEnd
17 changes: 15 additions & 2 deletions p2pool/bitcoin/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ def hash256(data):
return pack.IntType(256).unpack(hashlib.sha256(hashlib.sha256(data).digest()).digest())

def hash160(data):
if data == '04ffd03de44a6e11b9917f3a29f9443283d9871c9d743ef30d5eddcd37094b64d1b3d8090496b53256786bf5c82932ec23c3b74d9f05a6f95a8b5529352656664b'.decode('hex'):
return 0x384f570ccc88ac2e7e00b026d1690a3fca63dd0 # hack for people who don't have openssl - this is the only value that p2pool ever hashes
return pack.IntType(160).unpack(hashlib.new('ripemd160', hashlib.sha256(data).digest()).digest())

def scrypt(data):
return pack.IntType(256).unpack(__import__('ltc_scrypt').getPoWHash(data))

class ChecksummedType(pack.Type):
def __init__(self, inner, checksum_func=lambda data: hashlib.sha256(hashlib.sha256(data).digest()).digest()[:4]):
self.inner = inner
Expand Down Expand Up @@ -93,6 +94,7 @@ def write(self, file, item):

tx_type = pack.ComposedType([
('version', pack.IntType(32)),
('timestamp', pack.IntType(32)), # txn timestamp
('tx_ins', pack.ListType(pack.ComposedType([
('previous_output', pack.PossiblyNoneType(dict(hash=0, index=2**32 - 1), pack.ComposedType([
('hash', pack.IntType(256)),
Expand Down Expand Up @@ -131,6 +133,7 @@ def write(self, file, item):
block_type = pack.ComposedType([
('header', block_header_type),
('txs', pack.ListType(tx_type)),
('signature', pack.VarStrType()), # header signature field
])

# merged mining
Expand Down Expand Up @@ -262,6 +265,16 @@ def address_to_pubkey_hash(address, net):
raise ValueError('address not for this net!')
return x['pubkey_hash']

def address_to_script(address, net):
x = human_address_type.unpack(base58_decode(address))

print x['pubkey_hash']

if x['version'] != net.ADDRESS_VERSION:
raise ValueError(& 8000 #39;address not for this net!')
return '\x76\xa9' + ('\x14' + pack.IntType(160).pack(x['pubkey_hash'])) + '\x88\xac'


# transactions

def pubkey_to_script2(pubkey):
Expand Down
22 changes: 14 additions & 8 deletions p2pool/bitcoin/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,27 @@ def go():
print >>sys.stderr, 'Error: Bitcoin version too old! Upgrade to v0.5 or newer!'
raise deferral.RetrySilentlyException()
packed_transactions = [(x['data'] if isinstance(x, dict) else x).decode('hex') for x in work['transactions']]

transactions=map(bitcoin_data.tx_type.unpack, packed_transactions)
transaction_hashes=map(bitcoin_data.hash256, packed_transactions)
txn_timestamp = 0
for tx in transactions:
if tx.timestamp > txn_timestamp:
txn_timestamp = tx.timestamp

if 'height' not in work:
work['height'] = (yield bitcoind.rpc_getblock(work['previousblockhash']))['height'] + 1
elif p2pool.DEBUG:
assert work['height'] == (yield bitcoind.rpc_getblock(work['previousblockhash']))['height'] + 1
defer.returnValue(dict(
version=work['version'],
previous_block=int(work['previousblockhash'], 16),
transactions=map(bitcoin_data.tx_type.unpack, packed_transactions),
transaction_hashes=map(bitcoin_data.hash256, packed_transactions),
transactions=transactions,
transaction_hashes=transaction_hashes,
transaction_fees=[x.get('fee', None) if isinstance(x, dict) else None for x in work['transactions']],
subsidy=work['coinbasevalue'],
time=work['time'] if 'time' in work else work['curtime'],
txn_timestamp=txn_timestamp,
bits=bitcoin_data.FloatingIntegerType().unpack(work['bits'].decode('hex')[::-1]) if isinstance(work['bits'], (str, unicode)) else bitcoin_data.FloatingInteger(work['bits']),
coinbaseflags=work['coinbaseflags'].decode('hex') if 'coinbaseflags' in work else ''.join(x.decode('hex') for x in work['coinbaseaux'].itervalues()) if 'coinbaseaux' in work else '',
height=work['height'],
Expand All @@ -62,23 +71,20 @@ def go():
@deferral.retry('Error submitting primary block: (will retry)', 10, 10)
def submit_block_p2p(block, factory, net):
if factory.conn.value is None:
print >>sys.stderr, 'No bitcoind connection when block submittal attempted! %s%064x' % (net.PARENT.BLOCK_EXPLORER_URL_PREFIX, bitcoin_data.hash256(bitcoin_data.block_header_type.pack(block['header'])))
print >>sys.stderr, 'No bitcoind connection when block submittal attempted! %s%064x' % (net.PARENT.BLOCK_EXPLORER_URL_PREFIX, bitcoin_data.scrypt(bitcoin_data.block_header_type.pack(block['header'])))
raise deferral.RetrySilentlyException()
factory.conn.value.send_block(block=block)

@deferral.retry('Error submitting block: (will retry)', 10, 10)
@defer.inlineCallbacks
def submit_block_rpc(block, ignore_failure, bitcoind, bitcoind_work, net):
if bitcoind_work.value['use_getblocktemplate']:
try:
result = yield bitcoind.rpc_submitblock(bitcoin_data.block_type.pack(block).encode('hex'))
except jsonrpc.Error_for_code(-32601): # Method not found, for older litecoin versions
result = yield bitcoind.rpc_getblocktemplate(dict(mode='submit', data=bitcoin_data.block_type.pack(block).encode('hex')))
result = yield bitcoind.rpc_submitblock(bitcoin_data.block_type.pack(block).encode('hex'))
success = result is None
else:
result = yield bitcoind.rpc_getmemorypool(bitcoin_data.block_type.pack(block).encode('hex'))
success = result
success_expected = net.PARENT.POW_FUNC(bitcoin_data.block_header_type.pack(block['header'])) <= block['header']['bits'].target
success_expected = bitcoin_data.scrypt(bitcoin_data.block_header_type.pack(block['header'])) <= block['header']['bits'].target
if (not success and success_expected and not ignore_failure) or (success and not success_expected):
print >>sys.stderr, 'Block submittal result: %s (%r) Expected: %s' % (success, result, success_expected)

Expand Down
Loading
0