def pay_user(to_user_name, to_address, amount):
"""
Uses a BitTransferRequests to do an off chain payment.
"""
headers = {BitTransferRequests.HTTP_BITCOIN_PRICE: amount,
BitTransferRequests.HTTP_BITCOIN_ADDRESS: to_address,
BitTransferRequests.HTTP_BITCOIN_USERNAME: to_user_name}
response = MockRequest()
setattr(response, 'headers', headers)
setattr(response, 'url', 'http://10.244.119.122:11116')
logger.debug("Making 402 payment request with headers: {}".format(response))
req = requests.make_402_payment(response, amount)
logger.debug("Have the payment: {}".format(req))
transfer = BitTransfer(wallet, username=to_user_name)
logger.debug("Have the transfer: {}".format(transfer))
return transfer.redeem_payment(amount, req)
评论列表
文章目录