1
0

python3 updates

This commit is contained in:
ThomasV
2017-08-13 12:00:33 +02:00
parent d8e37644d3
commit e02687bcf2
6 changed files with 25 additions and 31 deletions

View File

@@ -255,7 +255,7 @@ class CoinChooserRandom(CoinChooserBase):
# And now some random ones
attempts = min(100, (len(buckets) - 1) * 10 + 1)
permutation = range(len(buckets))
permutation = list(range(len(buckets)))
for i in range(attempts):
# Get a random permutation of the buckets, and
# incrementally combine buckets until sufficient

View File

@@ -937,7 +937,7 @@ class Network(util.DaemonThread):
self.notify('interfaces')
def maintain_requests(self):
for interface in self.interfaces.values():
for interface in list(self.interfaces.values()):
if interface.request and time.time() - interface.request_time > 20:
interface.print_error("blockchain request timed out")
self.connection_down(interface.server)

View File

@@ -267,20 +267,16 @@ class PaymentRequest:
return self.outputs[:]
def send_ack(self, raw_tx, refund_addr):
pay_det = self.details
if not self.details.payment_url:
return False, "no url"
paymnt = pb2.Payment()
paymnt.merchant_data = pay_det.merchant_data
paymnt.transactions.append(raw_tx)
paymnt.transactions.append(bfh(raw_tx))
ref_out = paymnt.refund_to.add()
ref_out.script = transaction.Transaction.pay_script(TYPE_ADDRESS, refund_addr)
paymnt.memo = "Paid using Electrum"
pm = paymnt.SerializeToString()
payurl = urllib_parse.urlparse(pay_det.payment_url)
try:
r = requests.post(payurl.geturl(), data=pm, headers=ACK_HEADERS, verify=ca_path)
@@ -291,16 +287,13 @@ class PaymentRequest:
except Exception as e:
print(e)
return False, "Payment Message/PaymentACK Failed"
if r.status_code >= 500:
return False, r.reason
try:
paymntack = pb2.PaymentACK()
paymntack.ParseFromString(r.content)
except Exception:
return False, "PaymentACK could not be processed. Payment was sent; please manually verify that payment was received."
print("PaymentACK message received: %s" % paymntack.memo)
return True, paymntack.memo
@@ -495,7 +488,7 @@ class InvoiceStore(object):
l = {}
for k, pr in self.invoices.items():
l[k] = {
'hex': bh2u(pr),
'hex': bh2u(pr.raw),
'requestor': pr.requestor,
'txid': pr.tx
}

View File

@@ -508,7 +508,7 @@ class DeviceMgr(ThreadJob, PrintError):
usage_page = d['usage_page']
id_ = d['serial_number']
if len(id_) == 0:
id_ = d['path']
id_ = str(d['path'])
id_ += str(interface_number) + str(usage_page)
devices.append(Device(d['path'], interface_number,
id_, product_key, usage_page))