Example #1
0
    def __init__(self):
        super(FindTransactionsRequestFilter, self).__init__(
            {
                'addresses':
                (f.Array
                 | f.FilterRepeater(
                     f.Required
                     | AddressNoChecksum()
                     | f.Unicode(encoding='ascii', normalize=False))),
                'approvees':
                (f.Array
                 | f.FilterRepeater(
                     f.Required
                     | Trytes(result_type=TransactionHash)
                     | f.Unicode(encoding='ascii', normalize=False))),
                'bundles':
                (f.Array
                 | f.FilterRepeater(
                     f.Required
                     | Trytes(result_type=TransactionHash)
                     | f.Unicode(encoding='ascii', normalize=False))),
                'tags': (f.Array
                         | f.FilterRepeater(
                             f.Required
                             | Trytes(result_type=Tag)
                             | f.Unicode(encoding='ascii', normalize=False))),
            },

            # Technically, all of the parameters for this command are
            #   optional, so long as at least one of them is present and not
            #   empty.
            allow_missing_keys=True,
        )
Example #2
0
 def __init__(self):
     super(WereAddressesSpentFromRequestFilter, self).__init__({
         'addresses':
         f.Required | f.Array | f.FilterRepeater(
             f.Required | AddressNoChecksum()
             | f.Unicode(encoding='ascii', normalize=False), ),
     })
Example #3
0
 def __init__(self) -> None:
     super(GetBalancesRequestFilter, self).__init__(
         {
             'addresses':
             f.Required | f.Array | f.FilterRepeater(
                 f.Required | AddressNoChecksum()
                 | f.Unicode(encoding='ascii', normalize=False), ),
             'tips':
             StringifiedTrytesArray(TransactionHash),
         },
         allow_missing_keys={
             'tips',
         },
     )
Example #4
0
 def __init__(self):
     super(GetBalancesRequestFilter, self).__init__(
         {
             'addresses':
             f.Required | f.Array | f.FilterRepeater(
                 f.Required | AddressNoChecksum()
                 | f.Unicode(encoding='ascii', normalize=False), ),
             'threshold':
             f.Type(int) | f.Min(0) | f.Max(100) | f.Optional(default=100),
         },
         allow_missing_keys={
             'threshold',
         },
     )
Example #5
0
def check_for_payments(iota, t_hash, addr) -> Dict:
    payments = {}
    receiver_addr = AddressNoChecksum()._apply(TryteString(addr))
    t_bytes = bytes(t_hash)
    t_trytes = str(iota.get_trytes([t_bytes])["trytes"][0])
    transaction = Transaction.from_tryte_string(t_trytes)
    t_age = now() - from_timestamp(transaction.attachment_timestamp / 1000)
    if transaction.address == receiver_addr and t_age.in_minutes() < 60:
        logger.warning(
            f"[{from_timestamp(transaction.timestamp)}] Payment of {transaction.value}i found on receiving address {addr[:8]}..."
        )
        try:
            data = extract_json(transaction)
            username, topic, password = parse_payload(data)
            payments["username"] = username
            payments["topic"] = topic
            payments["password"] = password
            payments["expires_after"] = 10 * (transaction.value //
                                              VALUE_PER_TEN_SECONDS)
            payments["t_hash"] = transaction.hash
            payments["t_value"] = transaction.value
        except Exception as e:
            logger.exception(e)
    return payments