iota/transaction/base.py
def from_tryte_string(cls, trytes, hash_=None):
        # type: (TrytesCompatible, Optional[TransactionHash]) -> Transaction
        """
        Creates a Transaction object from a sequence of trytes.

        :param trytes:
            Raw trytes.  Should be exactly 2673 trytes long.

        :param hash_:
            The transaction hash, if available.

            If not provided, it will be computed from the transaction
            trytes.
        """
        tryte_string = TransactionTrytes(trytes)

        if not hash_:
            hash_trits = [0] * HASH_LENGTH  # type: MutableSequence[int]

            sponge = Curl()
            sponge.absorb(tryte_string.as_trits())
            sponge.squeeze(hash_trits)

            hash_ = TransactionHash.from_trits(hash_trits)

        return cls(
            hash_=hash_,
            signature_message_fragment=Fragment(tryte_string[0:2187]),
            address=Address(tryte_string[2187:2268]),
            value=int_from_trits(tryte_string[2268:2295].as_trits()),
            legacy_tag=Tag(tryte_string[2295:2322]),
            timestamp=int_from_trits(tryte_string[2322:2331].as_trits()),
            current_index=int_from_trits(tryte_string[2331:2340].as_trits()),
            last_index=int_from_trits(tryte_string[2340:2349].as_trits()),
            bundle_hash=BundleHash(tryte_string[2349:2430]),
            trunk_transaction_hash=TransactionHash(tryte_string[2430:2511]),
            branch_transaction_hash=TransactionHash(tryte_string[2511:2592]),
            tag=Tag(tryte_string[2592:2619]),

            attachment_timestamp=int_from_trits(
                tryte_string[2619:2628].as_trits()),

            attachment_timestamp_lower_bound=int_from_trits(
                tryte_string[2628:2637].as_trits()),

            attachment_timestamp_upper_bound=int_from_trits(
                tryte_string[2637:2646].as_trits()),

            nonce=Nonce(tryte_string[2646:2673]),
        )
def from_tryte_string(cls, trytes, hash_=None):
        # type: (TrytesCompatible, Optional[TransactionHash]) -> Transaction
        tryte_string = TransactionTrytes(trytes)

        if not hash_:
            hash_trits = [0] * HASH_LENGTH  # type: MutableSequence[int]

            sponge = Curl()
            sponge.absorb(tryte_string.as_trits())
            sponge.squeeze(hash_trits)

            hash_ = TransactionHash.from_trits(hash_trits)

        return cls(
            hash_=hash_,
            signature_message_fragment=Fragment(tryte_string[0:2187]),
            address=Address(tryte_string[2187:2268]),
            value=int_from_trits(tryte_string[2268:2295].as_trits()),
            legacy_tag=Tag(tryte_string[2295:2322]),
            timestamp=int_from_trits(tryte_string[2322:2331].as_trits()),
            current_index=int_from_trits(tryte_string[2331:2340].as_trits()),
            last_index=int_from_trits(tryte_string[2340:2349].as_trits()),
            bundle_hash=BundleHash(tryte_string[2349:2430]),
            trunk_transaction_hash=TransactionHash(tryte_string[2430:2511]),
            branch_transaction_hash=TransactionHash(tryte_string[2511:2592]),
            tag=Tag(tryte_string[2592:2619]),

            attachment_timestamp=int_from_trits(
                tryte_string[2619:2628].as_trits()),

            attachment_timestamp_lower_bound=int_from_trits(
                tryte_string[2628:2637].as_trits()),

            attachment_timestamp_upper_bound=int_from_trits(
                tryte_string[2637:2646].as_trits()),

            nonce=Nonce(tryte_string[2646:2673]),
        )
def from_tryte_string ( cls , trytes , hash_ = None ) : # type: (TrytesCompatible, Optional[TransactionHash]) -> Transaction tryte_string = TransactionTrytes ( trytes ) if not hash_ : hash_trits = [ 0 ] * HASH_LENGTH # type: MutableSequence[int] sponge = Curl ( ) sponge . absorb ( tryte_string . as_trits ( ) ) sponge . squeeze ( hash_trits ) hash_ = TransactionHash . from_trits ( hash_trits ) return cls ( hash_ = hash_ , signature_message_fragment = Fragment ( tryte_string [ 0 : 2187 ] ) , address = Address ( tryte_string [ 2187 : 2268 ] ) , value = int_from_trits ( tryte_string [ 2268 : 2295 ] . as_trits ( ) ) , legacy_tag = Tag ( tryte_string [ 2295 : 2322 ] ) , timestamp = int_from_trits ( tryte_string [ 2322 : 2331 ] . as_trits ( ) ) , current_index = int_from_trits ( tryte_string [ 2331 : 2340 ] . as_trits ( ) ) , last_index = int_from_trits ( tryte_string [ 2340 : 2349 ] . as_trits ( ) ) , bundle_hash = BundleHash ( tryte_string [ 2349 : 2430 ] ) , trunk_transaction_hash = TransactionHash ( tryte_string [ 2430 : 2511 ] ) , branch_transaction_hash = TransactionHash ( tryte_string [ 2511 : 2592 ] ) , tag = Tag ( tryte_string [ 2592 : 2619 ] ) , attachment_timestamp = int_from_trits ( tryte_string [ 2619 : 2628 ] . as_trits ( ) ) , attachment_timestamp_lower_bound = int_from_trits ( tryte_string [ 2628 : 2637 ] . as_trits ( ) ) , attachment_timestamp_upper_bound = int_from_trits ( tryte_string [ 2637 : 2646 ] . as_trits ( ) ) , nonce = Nonce ( tryte_string [ 2646 : 2673 ] ) , )
Creates a Transaction object from a sequence of trytes.

        :param trytes:
            Raw trytes.  Should be exactly 2673 trytes long.

        :param hash_:
            The transaction hash, if available.

            If not provided, it will be computed from the transaction
            trytes.
Creates a Transaction object from a sequence of trytes .