Skip to content

Commit 0455a2f

Browse files
authored
Merge pull request #505 from 1200wd/release-7.9
Release 7.9
2 parents 7398ae3 + 977f300 commit 0455a2f

5 files changed

Lines changed: 32 additions & 29 deletions

File tree

bitcoinlib/services/bcoin.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,17 @@ def gettransactions(self, address, after_txid='', limit=MAX_TRANSACTIONS):
149149
def getrawtransaction(self, txid):
150150
return self.compose_request('tx', txid)['hex']
151151

152-
def sendrawtransaction(self, rawtx):
153-
res = self.compose_request('broadcast', variables={'tx': rawtx}, method='post')
154-
txid = ''
155-
if 'success' in res and res['success']:
156-
t = Transaction.parse_hex(rawtx, network=self.network)
157-
txid = t.txid
158-
return {
159-
'txid': txid,
160-
'response_dict': res
161-
}
152+
# Gives a false success response for invalid transactions!
153+
# def sendrawtransaction(self, rawtx):
154+
# res = self.compose_request('broadcast', variables={'tx': rawtx}, method='post')
155+
# txid = ''
156+
# if 'success' in res and res['success']:
157+
# t = Transaction.parse_hex(rawtx, network=self.network)
158+
# txid = t.txid
159+
# return {
160+
# 'txid': txid,
161+
# 'response_dict': res
162+
# }
162163

163164
def estimatefee(self, blocks):
164165
if blocks > 15:

bitcoinlib/services/electrumx.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ async def main(host, port, method, parameters):
6868
await session.send_request('server.version', ["Bitcoinlib", ELECTRUMX_PROTOCOL_VERSION])
6969
return await session.send_request(method, parameters)
7070

71-
loop = asyncio.get_event_loop()
72-
return loop.run_until_complete(main(host, port, method, parameters))
71+
return asyncio.run(main(host, port, method, parameters))
7372
else:
7473
content = {
7574
"method": method,

bitcoinlib/services/services.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -383,14 +383,12 @@ def gettransactions(self, address, after_txid='', limit=MAX_TRANSACTIONS):
383383
qry_after_txid = bytes.fromhex(txs_cache[-1:][0].txid)
384384

385385
# Get (extra) transactions from service providers
386-
txs = []
387-
if not (db_addr and db_addr.last_block and db_addr.last_block >= self.blockcount()) or not caching_enabled:
388-
txs = self._provider_execute('gettransactions', address, qry_after_txid.hex(), limit)
389-
if txs is False:
390-
raise ServiceError("Error when retrieving transactions from service provider")
391-
for tx in txs:
392-
if tx.date and not tx.date.tzinfo:
393-
tx.date = tx.date.replace(tzinfo=timezone.utc)
386+
txs = self._provider_execute('gettransactions', address, qry_after_txid.hex(), limit)
387+
if txs is False:
388+
raise ServiceError("Error when retrieving transactions from service provider")
389+
for tx in txs:
390+
if tx.date and not tx.date.tzinfo:
391+
tx.date = tx.date.replace(tzinfo=timezone.utc)
394392

395393
# Store transactions and address in cache
396394
# - disable cache if comparing providers or if after_txid is used and no cache is available

bitcoinlib/wallets.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,7 +2057,7 @@ def scan(self, scan_gap_limit=5, account_id=None, change=None, rescan_used=False
20572057
# Rescan used addresses
20582058
if rescan_used:
20592059
for key in self.keys_addresses(account_id=account_id, change=change, network=network, used=True):
2060-
self.scan_key(key.id)
2060+
self.scan_key(key.key_id)
20612061

20622062
# Update already known transactions with known block height
20632063
self.transactions_update_confirmations()
@@ -3449,12 +3449,17 @@ def utxo_last(self, address):
34493449
34503450
:return str:
34513451
"""
3452-
to = self.session.query(
3453-
DbTransaction.txid, DbTransaction.confirmations). \
3454-
join(DbTransactionOutput).join(DbKey). \
3455-
filter(DbKey.address == address, DbTransaction.wallet_id == self.wallet_id,
3456-
DbTransactionOutput.spent.is_(False)). \
3457-
order_by(DbTransaction.confirmations).first()
3452+
query = self.session.query(
3453+
DbTransaction.txid, DbTransaction.confirmations
3454+
).join(DbTransactionOutput).join(DbKey).filter(
3455+
DbKey.address == address,
3456+
DbTransaction.wallet_id == self.wallet_id,
3457+
DbTransactionOutput.spent.is_(False)
3458+
)
3459+
if self.ignore_dust:
3460+
query = query.filter(DbTransactionOutput.value >= self.network.dust_amount)
3461+
3462+
to = query.order_by(DbTransaction.confirmations).first()
34583463
return '' if not to else to[0].hex()
34593464

34603465
def transactions_update_confirmations(self):
@@ -3766,7 +3771,7 @@ def transactions_export(self, account_id=None, network=None, include_new=False,
37663771

37673772
# Loop through all transaction inputs and outputs
37683773
for tei in te:
3769-
# Create string with list of inputs addresses for incoming transactions, and outputs addresses
3774+
# Create string with a list of inputs addresses for incoming transactions, and outputs addresses
37703775
# for outgoing txs
37713776
addr_list_in = tei[3] if isinstance(tei[3], list) else [tei[3]]
37723777
addr_list_out = tei[4] if isinstance(tei[4], list) else [tei[4]]

tests/test_wallets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2902,7 +2902,7 @@ def test_wallet_readonly_create_and_import(self):
29022902
self.assertGreaterEqual(w.balance(), 4532991)
29032903
self.assertRaisesRegex(WalletError, "No unspent", w.send_to, '1ApcyGtcX4DUmfGqPBPY1bvKEh2irLqnhp', 50000)
29042904
self.assertEqual(w.utxo_last('13A1W4jLPP75pzvn2qJ5KyyqG3qPSpb9jM'),
2905-
'1b590ccbdeb5659772c69e8aee4bc7eeafec7573ddb1254b97a512f56162fd9c')
2905+
'22965c151d850b5c7d98561e5432459141b1321a299cdcac1764f540eef56451')
29062906

29072907
def test_wallet_address_import_public_key(self):
29082908
wif = 'xpub661MyMwAqRbcFCwFkcko75u2VEinbG1u5U4nq8AFJq4AbLPEvwcmhZGgGcnDcEBpcfAFEP8vVhbJJvX1ieGWdoaa5AnHfyB' \

0 commit comments

Comments
 (0)