How to use the @iota/transaction.bundle 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 / persistence / src / persistence.ts View on Github external
({ type, value }): PersistenceAdapterBatch => {
                                            switch (type) {
                                                case PersistenceBatchTypes.deleteBundle:
                                                    return {
                                                        type: PersistenceAdapterBatchTypes.write,
                                                        key: tritsToBytes(bundle(value)),
                                                        value: tritsToBytes(value),
                                                    }
                                                case PersistenceBatchTypes.deleteCDA:
                                                    return {
                                                        type: PersistenceAdapterBatchTypes.write,
                                                        key: tritsToBytes(CDAddress(value)),
                                                        value: tritsToBytes(value),
                                                    }
                                            }
                                            /* istanbul ignore next */
                                            return undefined as any
                                        }
                                    )
github iotaledger / iota.js / packages / account / src / preset.ts View on Github external
getLatestInclusion(pastAttachmentHashes).tap(inclusionStates => {
                        if (inclusionStates.indexOf(true) > -1) {
                            return persistence.del(['0', tritsToTrytes(bundleHash(bundle))].join(':'))
                        }

                        return Promise.all(pastAttachmentHashes.map(h => getConsistency([h]))).tap(consistencyStates =>
                            consistencyStates.indexOf(true) > -1
                                ? setTimeout(() => bundles.write(bundle), delay)
                                : getTransactionsToApprove(depth, reference ? reference.hash : undefined)
                                      .tap(transactionsToApprove =>
                                          this.emit(Events.getTransactionsToApprove, {
                                              trytes: bundleTritsToBundleTrytes(bundle),
                                              transactionsToApprove,
                                          })
                                      )
                                      .then(
                                          ({
                                              trunkTransaction,
                                              branchTransaction,
github iotaledger / iota.js / packages / persistence / src / persistence.ts View on Github external
                        .then(() => state.delete(tritsToBytes(bundle(buffer))))
                        .tap(() => this.emit(PersistenceEvents.deleteBundle, buffer))
github iotaledger / iota.js / packages / multisig / src / multisig.ts View on Github external
public addSignature(bundle: Int8Array, inputAddress: string, keyTrits: Int8Array, callback: Callback) {
        const bundleHashTrits = bundleHash(bundle)
        const normalizedBundleHash = normalizedBundle(bundleHashTrits)
        let signatureIndex = 0

        for (const offset = 0; offset < bundle.length * TRANSACTION_LENGTH; offset + TRANSACTION_LENGTH) {
            if (tritsToTrytes(address(bundle)) === inputAddress && isNinesTrytes(signatureOrMessage(bundle))) {
                const signature = new Int8Array(keyTrits.length)

                for (let i = 0; i < keyTrits.length / FRAGMENT_LENGTH; i++) {
                    signature.set(
                        signatureFragment(
                            normalizedBundleHash.slice(
                                i * NORMALIZED_FRAGMENT_LENGTH,
                                (i + 1) * NORMALIZED_FRAGMENT_LENGTH
                            ),
                            keyTrits.slice(i * FRAGMENT_LENGTH, (i + 1) * FRAGMENT_LENGTH)
                        ),
github iotaledger / iota.js / packages / account / src / account.ts View on Github external
...state.withdrawals.map(withdrawal => {
                                    const trits = new Int8Array(withdrawal.length * TRANSACTION_LENGTH)
                                    for (let i = 0; i < withdrawal.length; i++) {
                                        trits.set(trytesToTrits(withdrawal[i]), i * TRANSACTION_LENGTH)
                                    }
                                    return {
                                        type: PersistenceBatchTypes.put,
                                        key: ['0', ':', tritsToTrytes(bundleHash(trits))].join(''),
                                        value: trits,
                                    }
                                }),
                            ] as PersistenceBatch)
github iotaledger / iota.js / packages / account / src / preset.ts View on Github external
.then(trytes => {
                                    const bundleTrits = bundleTrytesToBundleTrits(trytes)
                                    return persistence.put(
                                        ['0', tritsToTrytes(bundleHash(bundleTrits))].join(':'),
                                        bundleTrits
                                    )
                                })
                                .then(() => cda)
github iotaledger / iota.js / packages / account / src / preset.ts View on Github external
trytes =>
                            tritsToTrytes(bundleHash(bundle)) ===
                            trytes.slice(
                                BUNDLE_OFFSET / TRYTE_WIDTH,
                                BUNDLE_OFFSET / TRYTE_WIDTH + BUNDLE_LENGTH / TRYTE_WIDTH
                            )
                    )
github iotaledger / iota.js / packages / account / src / preset.ts View on Github external
.tap(trytes =>
                                        persistence.batch([
                                            ...inputs.map(
                                                (input): PersistencePutCommand => ({
                                                    type: PersistenceBatchTypes.put,
                                                    key: ['0', tritsToTrytes(input.address)].join(':'),
                                                    value: new Int8Array(1),
                                                })
                                            ),
                                            {
                                                type: PersistenceBatchTypes.put,
                                                key: [
                                                    '0',
                                                    tritsToTrytes(bundleHash(bundleTrytesToBundleTrits(trytes))),
                                                ].join(':'),
                                                value: bundleTrytesToBundleTrits(trytes),
                                            },
                                            {
                                                type: PersistenceBatchTypes.put,
                                                key: [SENT_TO_ADDRESS_PREFIX, noChecksum(cdaTransfer.address)].join(
                                                    ':'
                                                ),
                                                value: valueToTrits(cdaTransfer.timeoutAt),
                                            },
                                        ])
                                    )