Exemplo n.º 1
0
 def _create_payment_command(self,
                             account_id: str,
                             cmd: offchain.PaymentCommand,
                             validate: bool = False) -> None:
     self.app.store.create(
         PaymentCommand,
         before_create=lambda _: cmd.validate(None) if validate else None,
         account_id=account_id,
         is_sender=cmd.is_sender(),
         reference_id=cmd.reference_id(),
         is_inbound=cmd.is_inbound(),
         cid=cmd.id(),
         payment_object=asdict(cmd.payment),
     )
Exemplo n.º 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),
     )