How to use the @arkecosystem/crypto.Transaction.deserialize function in @arkecosystem/crypto

To help you get started, we’ve selected a few @arkecosystem/crypto 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 ArkEcosystem / core / packages / core-database-sequelize / lib / spv.js View on Github external
async __buildDelegates () {
    // Register...
    const transactions = await this.query
      .select('sender_public_key', 'serialized')
      .from('transactions')
      .where('type', TRANSACTION_TYPES.DELEGATE_REGISTRATION)
      .all()

    for (let i = 0; i < transactions.length; i++) {
      const wallet = this.walletManager.findByPublicKey(transactions[i].senderPublicKey)
      wallet.username = Transaction.deserialize(transactions[i].serialized.toString('hex')).asset.delegate.username

      this.walletManager.reindex(wallet)
    }

    // Rate...
    const delegates = await this.query
      .select('public_key', 'vote_balance', 'missed_blocks')
      .from('wallets')
      .whereIn('public_key', transactions.map(transaction => transaction.senderPublicKey))
      .orderBy({
        'vote_balance': 'DESC',
        'public_key': 'ASC'
      })
      .all()

    // Forged Blocks...
github ArkEcosystem / core / packages / core-p2p / lib / server / versions / internal / handlers.js View on Github external
async handler (request, h) {
    const transaction = new Transaction(Transaction.deserialize(request.payload.transaction))
    const result = await container.resolvePlugin('database').verifyTransaction(transaction)

    return { success: result }
  }
}
github ArkEcosystem / core / packages / core-database-sequelize / lib / connection.js View on Github external
    block.transactions = transactions.map(({ serialized }) => Transaction.deserialize(serialized.toString('hex')))
github ArkEcosystem / core / packages / core-p2p / lib / server / versions / peer / handlers / transactions.js View on Github external
const transactions = rows.map(row => {
      const transaction = Transaction.deserialize(
        row.serialized.toString('hex'),
      )
      transaction.blockId = row.block_id
      transaction.senderId = crypto.getAddress(transaction.senderPublicKey)
      return transaction
    })
github ArkEcosystem / core / packages / core-p2p / lib / server / versions / internal / handlers / transactions.js View on Github external
async handler(request, h) {
    const transaction = new Transaction(
      Transaction.deserialize(request.payload.transaction),
    )

    return {
      data: {
        valid: await app
          .resolvePlugin('database')
          .verifyTransaction(transaction),
      },
    }
  },
  options: {
github wownmedia / cryptology_tbw / lib / utils / trueblockweight.js View on Github external
__deserializeTransaction (transaction) {
    try {
      const buffer = Buffer.from(transaction, 'hex')
      const serialized = Buffer.from(buffer).toString('hex')
      const data = Transaction.deserialize(serialized)

      return data
    } catch (error) {
      logger.error(`Deserializing transaction: ${error.message}`)
      return null
    }
  }
github ArkEcosystem / core / packages / core-database-sequelize / lib / connection.js View on Github external
transactions = transactions.map(tx => {
        const data = Transaction.deserialize(tx.serialized.toString('hex'))
        data.blockId = tx.blockId
        return data
      })
    }
github ArkEcosystem / core / packages / core-graphql / lib / helpers / unserialize-transactions.js View on Github external
const deserialize = (buffer) => {
    const serialized = Buffer.from(buffer).toString('hex')
    return Transaction.deserialize(serialized)
  }
github ArkEcosystem / core / packages / core-database-sequelize / lib / spv.js View on Github external
data.forEach(row => {
      const wallet = this.walletManager.findByPublicKey(row.senderPublicKey)

      if (!wallet.multisignature) {
        wallet.multisignature = Transaction.deserialize(row.serialized.toString('hex')).asset.multisignature
      }
    })
  }