How to use the @iota/transaction.transactionHash function in @iota/transaction

To help you get started, we’ve selected a few @iota/transaction examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github iotaledger / iota.js / packages / transaction-converter / src / index.ts View on Github external
export const asTransactionObject = (trytes: Trytes, hash?: Hash): Transaction => {
    if (!isTrytesOfExactLength(trytes, TRANSACTION_LENGTH / TRYTE_WIDTH)) {
        throw new Error(errors.INVALID_TRYTES)
    }

    for (let i = 2279; i < 2295; i++) {
        if (trytes.charAt(i) !== '9') {
            throw new Error(errors.INVALID_TRYTES)
        }
    }

    const trits = trytesToTrits(trytes)

    return {
        hash: hash || tritsToTrytes(transactionHash(trits)),
        signatureMessageFragment: trytes.slice(
            SIGNATURE_OR_MESSAGE_OFFSET / TRYTE_WIDTH,
            SIGNATURE_OR_MESSAGE_LENGTH / TRYTE_WIDTH
        ),
        address: trytes.slice(ADDRESS_OFFSET / TRYTE_WIDTH, (ADDRESS_OFFSET + ADDRESS_LENGTH) / TRYTE_WIDTH),
        value: value(trits.slice(VALUE_OFFSET, VALUE_OFFSET + VALUE_LENGTH)),
        obsoleteTag: trytes.slice(
            OBSOLETE_TAG_OFFSET / TRYTE_WIDTH,
            (OBSOLETE_TAG_OFFSET + OBSOLETE_TAG_LENGTH) / TRYTE_WIDTH
        ),
        timestamp: value(trits.slice(ISSUANCE_TIMESTAMP_OFFSET, ISSUANCE_TIMESTAMP_OFFSET + ISSUANCE_TIMESTAMP_LENGTH)),
        currentIndex: value(trits.slice(CURRENT_INDEX_OFFSET, CURRENT_INDEX_OFFSET + CURRENT_INDEX_LENGTH)),
        lastIndex: value(trits.slice(LAST_INDEX_OFFSET, LAST_INDEX_OFFSET + LAST_INDEX_LENGTH)),
        bundle: trytes.slice(BUNDLE_OFFSET / TRYTE_WIDTH, (BUNDLE_OFFSET + BUNDLE_LENGTH) / TRYTE_WIDTH),
        trunkTransaction: trytes.slice(
            TRUNK_TRANSACTION_OFFSET / TRYTE_WIDTH,
github iotaledger / iota.js / packages / account / src / preset.ts View on Github external
                    pastAttachments.map(trytes => tritsToTrytes(transactionHash(trytesToTrits(trytes))))
                )
github iotaledger / iota.js / packages / pearl-diver-react-native / src / index.ts View on Github external
(nonce: Trytes) => {
                const transactionTrytes = asTransactionTrytes({ ...transaction, nonce })
                return search(
                    [...transactions, transactionTrytes],
                    tritsToTrytes(transactionHash(trytesToTrits(transactionTrytes)))
                )
            }
        )