def gen_received_payment(peer_address, squeak_hash, price_msat, settle_index): payment_hash = gen_random_hash() return ReceivedPayment( received_payment_id=None, created_time_ms=None, squeak_hash=squeak_hash, payment_hash=payment_hash, price_msat=price_msat, settle_index=settle_index, peer_address=peer_address, )
def message_to_received_payment( msg: squeak_admin_pb2.ReceivedPayment) -> ReceivedPayment: return ReceivedPayment( received_payment_id=(msg.received_payment_id if msg.received_payment_id > 0 else None), created_time_ms=(msg.time_ms if msg.time_ms > 0 else None), squeak_hash=bytes.fromhex(msg.squeak_hash), payment_hash=bytes.fromhex(msg.payment_hash), price_msat=msg.price_msat, settle_index=0, # TODO: This is not correct, fix later. peer_address=message_to_peer_address(msg.peer_address), )
def get_payment_stream(): # Yield the received payments. for invoice in invoice_stream.result_stream: payment_hash = invoice.r_hash settle_index = invoice.settle_index sent_offer = get_sent_offer_fn(payment_hash) if sent_offer is not None: yield ReceivedPayment( received_payment_id=None, created_time_ms=None, squeak_hash=sent_offer.squeak_hash, payment_hash=sent_offer.payment_hash, price_msat=sent_offer.price_msat, settle_index=settle_index, peer_address=sent_offer.peer_address, )
def received_payment( squeak_hash, payment_hash, price_msat, settle_index, peer_address, ): yield ReceivedPayment( received_payment_id=None, created_time_ms=None, squeak_hash=squeak_hash, payment_hash=payment_hash, price_msat=price_msat, settle_index=settle_index, peer_address=peer_address, )
def get_payment_stream(): # Yield the received payments. try: for invoice in invoice_stream.result_stream: if invoice.settled: payment_hash = invoice.r_hash settle_index = invoice.settle_index sent_offer = get_sent_offer_fn(payment_hash) yield ReceivedPayment( received_payment_id=None, created_time_ms=None, squeak_hash=sent_offer.squeak_hash, payment_hash=sent_offer.payment_hash, price_msat=sent_offer.price_msat, settle_index=settle_index, peer_address=sent_offer.peer_address, ) except grpc.RpcError as e: if e.code() != grpc.StatusCode.CANCELLED: raise InvoiceSubscriptionError()