Files
stacks-puppet-node/blockstore/coinkit.patch
Jude Nelson 47ecd65c37 In-progress refactoring: using virtualchain with a state engine.
* lib --> lib.old (depricating old name and storage operations)
* lib: new state-engine name operations logic, with virtualchain
* remove dead code
* add patch for coinkit
* remove dependencies on coinkit (in the new lib/)
Much more to do--will eventually remove lib.old, and will migrate
some of this code over to blockstore-client.
2015-08-04 02:25:39 -04:00

130 lines
6.7 KiB
Diff

diff -r -u build/lib.linux-x86_64-2.7/coinkit/formatcheck.py /usr/local/lib/python2.7/dist-packages/coinkit-0.7.8-py2.7.egg/coinkit/formatcheck.py
--- build/lib.linux-x86_64-2.7/coinkit/formatcheck.py 2015-03-06 17:18:55.000000000 +0000
+++ /usr/local/lib/python2.7/dist-packages/coinkit-0.7.8-py2.7.egg/coinkit/formatcheck.py 2015-07-26 20:49:07.671300855 +0000
@@ -19,7 +19,7 @@
return (isinstance(val, str) and len(val) == 64 and is_hex(val))
def is_wif_pk(val):
- return (len(val) >= 51 and len(val) <= 51 and is_b58check(val))
+ return (len(val) >= 51 and len(val) <= 52 and is_b58check(val))
def is_b58check_address(val):
return is_b58check(val)
diff -r -u build/lib.linux-x86_64-2.7/coinkit/privatekey.py /usr/local/lib/python2.7/dist-packages/coinkit-0.7.8-py2.7.egg/coinkit/privatekey.py
--- build/lib.linux-x86_64-2.7/coinkit/privatekey.py 2015-03-06 17:18:55.000000000 +0000
+++ /usr/local/lib/python2.7/dist-packages/coinkit-0.7.8-py2.7.egg/coinkit/privatekey.py 2015-07-27 06:27:05.595300855 +0000
@@ -11,7 +11,7 @@
from binascii import hexlify, unhexlify
from ecdsa.keys import SigningKey
from utilitybelt import is_int, dev_random_entropy, dev_urandom_entropy
-from pybitcointools import compress
+from pybitcointools import compress, encode_privkey
from .errors import _errors
from .formatcheck import *
@@ -88,10 +88,16 @@
def to_bin(self):
return self._ecdsa_private_key.to_string()
- def to_hex(self):
+ def to_hex(self, compressed=False):
+ if compressed:
+ return encode_privkey( self.to_bin(), 'hex_compressed' )
+
return hexlify(self.to_bin())
- def to_wif(self):
+ def to_wif(self, compressed=False):
+ if compressed:
+ return encode_privkey( self.to_bin(), 'wif_compressed' )
+
return b58check_encode(self.to_bin(),
version_byte=self.wif_version_byte())
diff -r -u build/lib.linux-x86_64-2.7/coinkit/publickey.py /usr/local/lib/python2.7/dist-packages/coinkit-0.7.8-py2.7.egg/coinkit/publickey.py
--- build/lib.linux-x86_64-2.7/coinkit/publickey.py 2015-03-06 17:25:45.000000000 +0000
+++ /usr/local/lib/python2.7/dist-packages/coinkit-0.7.8-py2.7.egg/coinkit/publickey.py 2015-07-26 22:02:41.871300855 +0000
@@ -144,7 +144,10 @@
def hash160(self):
return hexlify(self.bin_hash160())
- def address(self):
+ def address(self, compressed=None ):
+ if compressed:
+ return bin_hash160_to_address( get_bin_hash160( compress(self.to_bin()) ), version_byte=self._version_byte )
+
return bin_hash160_to_address(self.bin_hash160(),
version_byte=self._version_byte)
diff -r -u build/lib.linux-x86_64-2.7/coinkit/services/chain_com.py /usr/local/lib/python2.7/dist-packages/coinkit-0.7.8-py2.7.egg/coinkit/services/chain_com.py
--- build/lib.linux-x86_64-2.7/coinkit/services/chain_com.py 2015-03-06 17:18:55.000000000 +0000
+++ /usr/local/lib/python2.7/dist-packages/coinkit-0.7.8-py2.7.egg/coinkit/services/chain_com.py 2015-07-26 22:22:10.431300855 +0000
@@ -67,7 +67,7 @@
raise Exception('ChainComClient object must have auth credentials.')
url = CHAIN_API_BASE_URL + '/bitcoin/transactions'
- payload = json.dumps({ 'hex': hex_tx })
+ payload = json.dumps({ 'signed_hex': hex_tx })
r = requests.put(url, data=payload, auth=auth)
try:
@@ -79,5 +79,5 @@
data['success'] = True
return data
else:
- raise Exception('Tx hash missing from chain.com response: ' + str(data))
+ raise Exception('Tx hash missing from chain.com response: ' + str(data) + "\noriginal: %s" % str(payload))
diff -r -u build/lib.linux-x86_64-2.7/coinkit/transactions/network.py /usr/local/lib/python2.7/dist-packages/coinkit-0.7.8-py2.7.egg/coinkit/transactions/network.py
--- build/lib.linux-x86_64-2.7/coinkit/transactions/network.py 2015-03-06 17:18:55.000000000 +0000
+++ /usr/local/lib/python2.7/dist-packages/coinkit-0.7.8-py2.7.egg/coinkit/transactions/network.py 2015-07-27 06:30:57.991300855 +0000
@@ -64,7 +64,8 @@
def analyze_private_key(private_key, blockchain_client):
private_key_obj = get_private_key_obj(private_key)
# determine the address associated with the supplied private key
- from_address = private_key_obj.public_key().address()
+ # from_address = private_key_obj.public_key().address()
+ from_address = private_key_obj.public_key().address( compressed=True )
# get the unspent outputs corresponding to the given address
inputs = get_unspents(from_address, blockchain_client)
# return the inputs
@@ -87,7 +88,7 @@
# serialize the transaction
unsigned_tx = serialize_transaction(inputs, outputs)
# sign the unsigned transaction with the private key
- signed_tx = sign_transaction(unsigned_tx, 0, private_key_obj.to_hex())
+ signed_tx = sign_transaction(unsigned_tx, 0, private_key_obj.to_hex(compressed=True))
# return the signed tx
return signed_tx
@@ -108,7 +109,7 @@
# serialize the transaction
unsigned_tx = serialize_transaction(inputs, outputs)
# sign the unsigned transaction with the private key
- signed_tx = sign_transaction(unsigned_tx, 0, private_key_obj.to_hex())
+ signed_tx = sign_transaction(unsigned_tx, 0, private_key_obj.to_hex(compressed=True))
# return the signed tx
return signed_tx
@@ -146,7 +147,7 @@
# serialize the transaction
unsigned_tx = serialize_transaction(inputs, outputs)
# sign the unsigned transaction with the private key
- signed_tx = sign_transaction(unsigned_tx, 0, private_key_obj.to_hex())
+ signed_tx = sign_transaction(unsigned_tx, 0, private_key_obj.to_hex(compressed=True))
# dispatch the signed transction to the network
response = broadcast_transaction(signed_tx, blockchain_client)
# return the response
diff -r -u build/lib.linux-x86_64-2.7/coinkit/transactions/outputs.py /usr/local/lib/python2.7/dist-packages/coinkit-0.7.8-py2.7.egg/coinkit/transactions/outputs.py
--- build/lib.linux-x86_64-2.7/coinkit/transactions/outputs.py 2015-03-06 17:18:55.000000000 +0000
+++ /usr/local/lib/python2.7/dist-packages/coinkit-0.7.8-py2.7.egg/coinkit/transactions/outputs.py 2015-07-26 21:21:50.423300855 +0000
@@ -17,7 +17,7 @@
change_amount = total_amount_in - send_amount - fee
# check to ensure the change amount is a non-negative value and return it
if change_amount < 0:
- raise Exception('Not enough inputs for transaction.')
+ raise Exception('Not enough inputs for transaction (inputs: %s, send_amount: %s, fee: %s).' % (inputs, send_amount, fee))
return change_amount
def make_pay_to_address_outputs(to_address, send_amount, inputs, change_address,