예제 #1
0
 def purchase_data(self) -> Purchase:
     if self.is_purchase_data:
         if not isinstance(self.script.values['data'], Purchase):
             self.script.values['data'] = Purchase.from_bytes(
                 self.script.values['data'])
         return self.script.values['data']
     raise ValueError('Output does not have purchase data.')
예제 #2
0
 def purchase(cls, claim_id: str, amount: int, merchant_address: bytes,
              funding_accounts: List['Account'], change_account: 'Account'):
     ledger, _ = cls.ensure_all_have_same_ledger_and_wallet(
         funding_accounts, change_account)
     payment = Output.pay_pubkey_hash(
         amount, ledger.address_to_hash160(merchant_address))
     data = Output.add_purchase_data(Purchase(claim_id))
     return cls.create([], [payment, data], funding_accounts,
                       change_account)
예제 #3
0
 def is_purchase_data(self) -> bool:
     return self.script.is_return_data and (
         isinstance(self.script.values['data'], Purchase) or
         Purchase.has_start_byte(self.script.values['data'])
     )