示例#1
0
def _command_transaction_status(
        command: offchain.PaymentCommand,
        default: TransactionStatus) -> TransactionStatus:
    if command.is_both_ready():
        return TransactionStatus.OFF_CHAIN_READY
    elif command.is_abort():
        return TransactionStatus.CANCELED
    return default
示例#2
0
 def _update_payment_command(self,
                             cmd: PaymentCommand,
                             offchain_cmd: offchain.PaymentCommand,
                             validate: bool = False) -> None:
     prior = cmd.to_offchain_command()
     self.app.store.update(
         cmd,
         before_update=lambda _: offchain_cmd.validate(prior)
         if validate else None,
         cid=offchain_cmd.id(),
         is_inbound=offchain_cmd.is_inbound(),
         is_abort=offchain_cmd.is_abort(),
         is_ready=offchain_cmd.is_both_ready(),
         payment_object=asdict(offchain_cmd.payment),
     )