perone / protocoin Goto Github PK
View Code? Open in Web Editor NEWA pure Python Bitcoin protocol implementation
Home Page: http://protocoin.readthedocs.org/
License: BSD 4-Clause "Original" or "Old" License
A pure Python Bitcoin protocol implementation
Home Page: http://protocoin.readthedocs.org/
License: BSD 4-Clause "Original" or "Old" License
Add an example using Gevent to connect into multiple Bitcoin nodes.
import hashlib
import sys
sys.path.append('../protocoin')
from protocoin import keys
def brainwallet(num_bytes):
hashobj = hashlib.sha256("my super secret password seed")
return hashobj.digest()
priv_key = keys.BitcoinPrivateKey(entropy=brainwallet)
pub_key = priv_key.generate_public_key() #This line gives an AssertionError
....
Traceback (most recent call last):
File "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensio
ns\Microsoft\Python Tools for Visual Studio\2.0\visualstudio_py_util.py", line 7
6, in exec_file
exec(code_obj, global_variables)
File "C:\git\myBlockChain\brainWalletTest\brainWalletTest.py", line 12, in <mo
dule>
pub_key = priv_key.generate_public_key()
File "../protocoin\protocoin\keys.py", line 180, in generate_public_key
return BitcoinPublicKey.from_private_key(self.private_key)
File "../protocoin\protocoin\keys.py", line 32, in from_private_key
return klass(hexkey)
File "../protocoin\protocoin\keys.py", line 20, in __init__
curve=ecdsa.SECP256k1)
File "C:\Anaconda\lib\site-packages\ecdsa\keys.py", line 36, in from_string
(len(string), curve.verifying_key_length)
AssertionError: (63, 64)
Press any key to continue . . .
There is a bug with some clients happening at random times while deserializing message hader, it seems to be something related to the magic number
File "node1.py", line 68, in _run
client.loop()
File "protocoin/clients.py", line 92, in loop
message_header, message = self.receive_message()
File "protocoin/clients.py", line 45, in receive_message
message_header = message_header_serial.deserialize(self.stream)
File "protocoin/serializers.py", line 73, in deserialize
value = field_obj.deserialize(stream)
File "protocoin/fields.py", line 99, in deserialize
return struct.unpack(self.datatype, data)[0]
error: unpack requires a string argument of length 4
Today there is no way to receive the header and message data if a message checksum was invalid, a way to solve this is to add a call to a handle_invalid_checksum()
method when a checksum is invalid.
It is not enough to simply specify the port, it seems that due to a different magic in the message header, testnet doesn't accept connection and throws the following error:
PROCESSMESSAGE: INVALID MESSAGESTART
Perhaps add a default argument to BitcoinClient and BitcoinBasicClient?
Hello,
in clients.py in the class BitcoinBasicClient is this class function:
def close_stream(self):
"""This method will close the socket stream."""
sel.socket.close()
Obviously this should be self.socket.close() and not sel.socket.close().
The error I got was this one:
('Message sent:', 'version')
Traceback (most recent call last):
File "./receive_test.py", line 33, in
main()
File "./receive_test.py", line 28, in main
client.close_stream()
File "/usr/local/lib/python2.7/dist-packages/protocoin-0.2-py2.7.egg/protocoin/clients.py", line 20, in close_stream
sel.socket.close()
NameError: global name 'sel' is not defined
Kind regards
M
Add example on how to handle serialization to disk of the received messages.
Sorry, non an issue but cannot find any way to contact the maintainer. I wonder if protocoin is suitable to build a altcoin just for experimentation purposes, example adding new features like key/value storing in transaction or other stuff not part of Bitcoin protocol. Thank you.
Implement the GetAddr message.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.