How to use the bitcoinjs-lib.TransactionBuilder.fromTransaction function in bitcoinjs-lib

To help you get started, we’ve selected a few bitcoinjs-lib 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 blockstack / blockstack.js / src / operations / txbuild.ts View on Github external
.then(([utxos, feeRate, preorderSkeleton]) => {
        const txB = TransactionBuilder.fromTransaction(preorderSkeleton, network.layer1)
        txB.setVersion(1)

        const changeIndex = 1 // preorder skeleton always creates a change output at index = 1
        const signingTxB = fundTransaction(txB, preorderAddress, utxos, feeRate, 0, changeIndex)

        return signInputs(signingTxB, paymentKey)
      })
      .then(signingTxB => returnTransactionHex(signingTxB, buildIncomplete))
github blockstack / blockstack.js / src / operations / txbuild.ts View on Github external
.then(([utxos, feeRate]) => {
        const txB = TransactionBuilder.fromTransaction(nameImportTX, network.layer1)
        const signingTxB = fundTransaction(txB, importerAddress, utxos, feeRate, 0)
        return signInputs(signingTxB, importerKey)
      })
  )
github blockstack / blockstack.js / src / operations / txbuild.ts View on Github external
]).then(([senderUTXOs, btcUTXOs, feeRate, tokenTransferTX]) => {
        const txB = TransactionBuilder.fromTransaction(tokenTransferTX, network.layer1)

        if (separateFunder) {
          const payerInput = addOwnerInput(senderUTXOs, senderAddress, txB)
          const signingTxB = fundTransaction(txB, btcAddress, btcUTXOs, feeRate, payerInput.value)
          return signInputs(signingTxB, btcKey,
                            [{ index: payerInput.index, signer: senderKey }])
        } else {
          const signingTxB = fundTransaction(txB, senderAddress, senderUTXOs, feeRate, 0)
          return signInputs(signingTxB, senderKey)
        }
      })
    })
github blockstack / blockstack.js / src / operations / txbuild.ts View on Github external
.then(([ownerAddress, paymentAddress]) => {
      const revokeTX = makeRevokeSkeleton(fullyQualifiedName)
      const txPromise = TransactionBuilder.fromTransaction(revokeTX, network.layer1)
      txPromise.setVersion(1)


      return Promise.all([txPromise, network.getUTXOs(paymentAddress),
                          network.getUTXOs(ownerAddress), network.getFeeRate()])
        .then(([txB, payerUtxos, ownerUtxos, feeRate]) => {
          const ownerInput = addOwnerInput(ownerUtxos, ownerAddress, txB)
          const signingTxB = fundTransaction(txB, paymentAddress, payerUtxos, feeRate,
                                             ownerInput.value)
          return signInputs(signingTxB, paymentKey, [{ index: ownerInput.index, signer: ownerKey }])
        })
    })
    .then(signingTxB => returnTransactionHex(signingTxB, buildIncomplete))
github blockstack / blockstack.js / src / operations / txbuild.ts View on Github external
.then((tx) => {
          const txB = TransactionBuilder.fromTransaction(tx, network.layer1)
          txB.setVersion(1)
          return txB
        })
github blockstack / blockstack.js / src / operations / txbuild.ts View on Github external
.then(([utxos, feeRate]) => {
        const txB = TransactionBuilder.fromTransaction(announceTX, network.layer1)
        const signingTxB = fundTransaction(txB, senderAddress, utxos, feeRate, 0)
        return signInputs(signingTxB, senderKey)
      })
  )
github blockstack / blockstack.js / src / operations / txbuild.ts View on Github external
.then(([utxos, feeRate]) => {
        const txB = TransactionBuilder
          .fromTransaction(namespaceRevealTX, network.layer1)
        txB.setVersion(1)
        const signingTxB = fundTransaction(txB, preorderAddress, utxos, feeRate, 0)

        return signInputs(signingTxB, paymentKey)
      })
  )
github blockstack / blockstack.js / src / operations / txbuild.ts View on Github external
.then(([utxos, feeRate]) => {
        const txB = TransactionBuilder.fromTransaction(namespaceReadyTX, network.layer1)
        txB.setVersion(1)
        const signingTxB = fundTransaction(txB, revealAddress, utxos, feeRate, 0)
        return signInputs(signingTxB, revealKey)
      })
  )
github blockstack / blockstack.js / src / operations / txbuild.ts View on Github external
.then((updateTX) => {
          const txB = TransactionBuilder.fromTransaction(updateTX, network.layer1)
          txB.setVersion(1)
          return txB
        })
github blockstack / blockstack.js / src / operations / txbuild.ts View on Github external
buildIncomplete: boolean = false
) {
  const network = config.network
  if (!valueHash && !!zonefile) {
    valueHash = hash160(Buffer.from(zonefile)).toString('hex')
  } else if (!!valueHash && valueHash.length !== 40) {
    return Promise.reject(
      new Error(`Invalid zonefile hash ${valueHash}`)
    )
  }

  const registerSkeleton = makeRegisterSkeleton(
    fullyQualifiedName, registerAddress, valueHash
  )

  const txB = TransactionBuilder.fromTransaction(registerSkeleton, network.layer1)
  txB.setVersion(1)

  const paymentKey = getTransactionSigner(paymentKeyIn)

  return paymentKey.getAddress().then(
    paymentAddress => Promise.all([network.getUTXOs(paymentAddress), network.getFeeRate()])
      .then(([utxos, feeRate]) => {
        const signingTxB = fundTransaction(txB, paymentAddress, utxos, feeRate, 0)

        return signInputs(signingTxB, paymentKey)
      })
  )
    .then(signingTxB => returnTransactionHex(signingTxB, buildIncomplete))
}