We will be sunsetting Advisor during Jan, 2026 and will instead be providing information in Snyk Security DB.

You can begin to take advantage of Snyk Security DB today for a unified, package-centric experience.

How to use the @nimiq/core/dist/node.ExtendedTransaction function in @nimiq/core

To help you get started, we’ve selected a few @nimiq/core 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 hector-nimiq / nimeth-atomicswap / src / nim.js View on Github external
async function refundHTLC(address, recipient) {
  address = Nimiq.Address.fromString(address)
  recipient = Nimiq.Address.fromString(recipient)
  const account = await $.consensus.getAccount(address)
  const tx = new Nimiq.ExtendedTransaction(
    address, Nimiq.Account.Type.HTLC,
    recipient, Nimiq.Account.Type.BASIC,
    account.balance, 0,
    $.blockchain.height + 1,
    Nimiq.Transaction.Flag.NONE, new Uint8Array(0))
  const sig = Nimiq.Signature.create($.wallet.keyPair.privateKey, $.wallet.publicKey, tx.serializeContent())
  const sigProof = new Nimiq.SignatureProof($.wallet.publicKey, new Nimiq.MerklePath([]), sig)
  tx.proof = new Nimiq.SerialBuffer(1 + sigProof.serializedSize)
  tx.proof.writeUint8(Nimiq.HashedTimeLockedContract.ProofType.TIMEOUT_RESOLVE)
  sigProof.serialize(tx.proof)
  await waitForBlock(account.timeout)
  await sendTransaction(tx)
}
github hector-nimiq / nimeth-atomicswap / src / nim.js View on Github external
async function resolveHTLC(address, recipient, hashRoot, preImage) {
  address = Nimiq.Address.fromString(address)
  recipient = Nimiq.Address.fromString(recipient)
  const account = await $.consensus.getAccount(address)
  const tx = new Nimiq.ExtendedTransaction(
    address, Nimiq.Account.Type.HTLC,
    recipient, Nimiq.Account.Type.BASIC,
    account.balance, 0,
    $.blockchain.height + 1,
    Nimiq.Transaction.Flag.NONE, new Uint8Array(0))
  const sig = Nimiq.Signature.create($.wallet.keyPair.privateKey, $.wallet.publicKey, tx.serializeContent())
  const sigProof = new Nimiq.SignatureProof($.wallet.publicKey, new Nimiq.MerklePath([]), sig)
  tx.proof = new Nimiq.SerialBuffer(3 + 2 * Nimiq.Hash.SIZE.get(Nimiq.Hash.Algorithm.SHA256) + sigProof.serializedSize)
  tx.proof.writeUint8(Nimiq.HashedTimeLockedContract.ProofType.REGULAR_TRANSFER)
  tx.proof.writeUint8(Nimiq.Hash.Algorithm.SHA256)
  tx.proof.writeUint8(1)
  Nimiq.Hash.fromHex(hashRoot.slice(2)).serialize(tx.proof)
  Nimiq.Hash.fromHex(preImage.slice(2)).serialize(tx.proof)
  sigProof.serialize(tx.proof)
  await sendTransaction(tx)
}