def handle_payment(uuid, address, satoshis, wallet_command, currency):
"""
Payment handling routine for spawn and topup.
"""
if wallet_command is not None:
full_wallet_command = '{} {} {} >&2'.format(wallet_command,
address,
satoshis)
if os.system(full_wallet_command) != 0:
raise
return True
amount = "{0:.8f}".format(satoshis *
0.00000001)
if currency == 'btc':
uri = 'bitcoin:{}?amount={}'.format(address, amount)
elif currency == 'bch':
uri = 'bitcoincash:{}?amount={}'.format(address, amount)
else:
raise ValueError('Currency must be one of: btc, bch')
premessage = '''UUID: {}
Bitcoin URI: {}
Pay with Bitcoin *within an hour*. QR code will change every so often but the
current and previous QR codes are both valid for about an hour. The faster you
make payment, the better. Pay *exactly* the specified amount. No more, no less.
Resize your terminal and try again if QR code above is not readable.
Press ctrl+c to abort.'''
message = premessage.format(uuid, uri)
qr = pyqrcode.create(uri)
stderr(qr.terminal(module_color='black',
background='white',
quiet_zone=1))
stderr(message)
评论列表
文章目录