bip70 PRs: use aiohttp instead of requests. use proxy. small fixes.
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
import binascii
|
||||
import os, sys, re, json
|
||||
from collections import defaultdict
|
||||
from typing import NamedTuple, Union, TYPE_CHECKING, Tuple, Optional
|
||||
from typing import NamedTuple, Union, TYPE_CHECKING, Tuple, Optional, Callable
|
||||
from datetime import datetime
|
||||
import decimal
|
||||
from decimal import Decimal
|
||||
@@ -693,7 +693,7 @@ def block_explorer_URL(config: 'SimpleConfig', kind: str, item: str) -> Optional
|
||||
#_ud = re.compile('%([0-9a-hA-H]{2})', re.MULTILINE)
|
||||
#urldecode = lambda x: _ud.sub(lambda m: chr(int(m.group(1), 16)), x)
|
||||
|
||||
def parse_URI(uri, on_pr=None):
|
||||
def parse_URI(uri: str, on_pr: Callable=None) -> dict:
|
||||
from . import bitcoin
|
||||
from .bitcoin import COIN
|
||||
|
||||
@@ -746,18 +746,17 @@ def parse_URI(uri, on_pr=None):
|
||||
sig = out.get('sig')
|
||||
name = out.get('name')
|
||||
if on_pr and (r or (name and sig)):
|
||||
def get_payment_request_thread():
|
||||
async def get_payment_request():
|
||||
from . import paymentrequest as pr
|
||||
if name and sig:
|
||||
s = pr.serialize_request(out).SerializeToString()
|
||||
request = pr.PaymentRequest(s)
|
||||
else:
|
||||
request = pr.get_payment_request(r)
|
||||
request = await pr.get_payment_request(r)
|
||||
if on_pr:
|
||||
on_pr(request)
|
||||
t = threading.Thread(target=get_payment_request_thread)
|
||||
t.setDaemon(True)
|
||||
t.start()
|
||||
loop = asyncio.get_event_loop()
|
||||
asyncio.run_coroutine_threadsafe(get_payment_request(), loop)
|
||||
|
||||
return out
|
||||
|
||||
|
||||
Reference in New Issue
Block a user