def GetListUnclaimed(self, request, context): payments = [] for channel_id in payments_unclaimed: nonce = payments_unclaimed[channel_id]["nonce"] amount = payments_unclaimed[channel_id]["amount"] payment = control_service_pb2.PaymentReply( channel_id = web3.Web3.toBytes(channel_id), channel_nonce = web3.Web3.toBytes(nonce), signed_amount = web3.Web3.toBytes(amount)) payments.append(payment) return control_service_pb2.PaymentsListReply(payments = payments)
def GetListInProgress(self, request, context): remove_already_claimed_payments() payments = [] for channel_id in payments_in_progress: p = payments_in_progress[channel_id] payment = control_service_pb2.PaymentReply( channel_id = web3.Web3.toBytes(channel_id), channel_nonce = web3.Web3.toBytes(p["nonce"]), signed_amount = web3.Web3.toBytes(p["amount"]), signature = p["signature"]) payments.append(payment) return control_service_pb2.PaymentsListReply(payments = payments)
def StartClaim(self, request, context): remove_already_claimed_payments() channel_id = int.from_bytes(request.channel_id, byteorder='big') if (channel_id not in payments_unclaimed): raise Exception("channel_id not in payments_unclaimed") p = payments_unclaimed[channel_id] nonce = p["nonce"] amount = p["amount"] signature = p["signature"] payments_in_progress[channel_id] = p payments_unclaimed[channel_id] = {"nonce" : nonce + 1, "amount" : 0, "signature" : bytes(0)} return control_service_pb2.PaymentReply( channel_id = web3.Web3.toBytes(channel_id), channel_nonce = web3.Web3.toBytes(nonce), signed_amount = web3.Web3.toBytes(amount), signature = signature)