Skip to content
This repository was archived by the owner on Mar 26, 2025. It is now read-only.

Commit d16f9a5

Browse files
committed
Merge branch 'develop'
2 parents 8e2bab5 + 139a902 commit d16f9a5

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

pybitcoin/services/bitcoind.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from .blockchain_client import BlockchainClient
1919

20+
2021
def create_bitcoind_service_proxy(
2122
rpc_username, rpc_password, server='127.0.0.1', port=8332, use_https=False):
2223
""" create a bitcoind service proxy
@@ -26,6 +27,7 @@ def create_bitcoind_service_proxy(
2627
server, port)
2728
return AuthServiceProxy(uri)
2829

30+
2931
class BitcoindClient(BlockchainClient):
3032
def __init__(self, rpc_username, rpc_password, use_https=False,
3133
server='127.0.0.1', port=8332, version_byte=0):
@@ -35,6 +37,7 @@ def __init__(self, rpc_username, rpc_password, use_https=False,
3537
rpc_password, use_https=use_https, server=server, port=port)
3638
self.version_byte = version_byte
3739

40+
3841
def format_unspents(unspents):
3942
return [{
4043
"transaction_hash": s["txid"],
@@ -46,6 +49,7 @@ def format_unspents(unspents):
4649
for s in unspents
4750
]
4851

52+
4953
def get_unspents(address, blockchain_client):
5054
""" Get the spendable transaction outputs, also known as UTXOs or
5155
unspent transaction outputs.
@@ -63,17 +67,12 @@ def get_unspents(address, blockchain_client):
6367
else:
6468
raise Exception('A BitcoindClient object is required')
6569

66-
all_unspents = bitcoind.listunspent()
67-
68-
unspents = []
69-
for u in all_unspents:
70-
if 'address' not in u:
71-
u['address'] = script_hex_to_address(u['scriptPubKey'],
72-
version_byte=version_byte)
73-
if 'spendable' in u and u['spendable'] is False:
74-
continue
75-
if u['address'] == address:
76-
unspents.append(u)
70+
addresses = []
71+
addresses.append(str(address))
72+
min_confirmations = 0
73+
max_confirmation = 2000000000 # just a very large number for max
74+
unspents = bitcoind.listunspent(min_confirmations, max_confirmation,
75+
addresses)
7776

7877
return format_unspents(unspents)
7978

@@ -94,6 +93,6 @@ def broadcast_transaction(hex_tx, blockchain_client):
9493
raise Exception('Invalid HTTP status code from bitcoind.')
9594

9695
if len(resp) > 0:
97-
return {'transaction_hash': resp, 'success': True}
96+
return {'tx_hash': resp, 'success': True}
9897
else:
9998
raise Exception('Invalid response from bitcoind.')

pybitcoin/transactions/network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def sign_all_unsigned_inputs(hex_privkey, unsigned_tx_hex):
194194
Returns: signed hex transaction
195195
"""
196196
inputs, outputs, locktime, version = deserialize_transaction(unsigned_tx_hex)
197-
197+
tx_hex = unsigned_tx_hex
198198
for index in xrange(0, len(inputs)):
199199
if len(inputs[index]['script_sig']) == 0:
200200

pybitcoin/transactions/outputs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def calculate_change_amount(inputs, send_amount, fee):
1717
change_amount = total_amount_in - send_amount - fee
1818
# check to ensure the change amount is a non-negative value and return it
1919
if change_amount < 0:
20-
raise Exception('Not enough inputs for transaction.')
20+
raise ValueError('Not enough inputs for transaction (total: %s, to spend: %s, fee: %s).' % (total_amount_in, send_amount, fee))
2121
return change_amount
2222

2323
def make_pay_to_address_outputs(to_address, send_amount, inputs, change_address,

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ commontools==0.1.0
44
utilitybelt>=0.2.1
55
python-bitcoinrpc==0.1
66
keychain>=0.1.4
7-
bitcoin>=1.1.39
7+
bitcoin>=1.1.42

setup.py

100644100755
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python
12
"""
23
pybitcoin
34
==============
@@ -8,7 +9,7 @@
89

910
setup(
1011
name='pybitcoin',
11-
version='0.9.8',
12+
version='0.9.9',
1213
url='https://github.com/blockstack/pybitcoin',
1314
license='MIT',
1415
author='Blockstack Developers',
@@ -21,10 +22,10 @@
2122
'requests>=2.4.3',
2223
'ecdsa>=0.13',
2324
'commontools==0.1.0',
24-
'utilitybelt>=0.2.1',
25+
'utilitybelt>=0.2.6',
2526
'python-bitcoinrpc==0.1',
2627
'keychain>=0.1.4',
27-
'bitcoin>=1.1.39'
28+
'bitcoin>=1.1.42'
2829
],
2930
classifiers=[
3031
'Intended Audience :: Developers',

0 commit comments

Comments
 (0)