cli.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:sporestack-python 作者: sporestack 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号