How can I create the input of raw transaction through the previous UTXO hash and the unspent index in bitcoinj？ I want to create a raw transaction’s input and output, and sign it then broadcast to testnet. Now I know how to create the output, but I want to refer the transaction that I can input the UTXO hash and the unspent index, then add the input to this raw transaction.
here's how to create an unsigned raw transaction in typescript with one input and one output.

import * as bitcoin from 'bitcoinjs-lib'

const reverseHexBytes = (hex: string) =&gt; {
  const buff = Buffer.from(hex, 'hex')
  return buff.reverse().toString('hex')
}

const fixedPoint = (num: number): number =&gt; {
  return parseFloat(num.toFixed(8))
}

const outputAmount = 100
const inputTxHash = 'tx-hash-goes-here'
const index = 5
const fee = 0.001
const numOutputs = 1
const outputAddress = 'address-to-send-to-goes-here'

// input
const txInputs = '01'
const txHash = reverseHexBytes(inputTxHash)
const outputIndex = '0' + txIndex.toString() + '000000'
const script = ''
const sequence = 'ffffffff'
let tx = txVersion + txInputs + txHash + outputIndex + script + sequence
// output
const countHex = numOutputs.toString(16)
const countByte = (countHex.length === 1) ? '0' + countHex : countHex
tx += countByte
const amount = fixedPoint(outputAmount - fee)
const outputAmount = Math.floor(amount * (10**8))
let outputAmountHex = outputAmount.toString(16)
while (outputAmountHex.length &lt; 16) {
  outputAmountHex = '0' + outputAmountHex
}
const outputAmountBytes = reverseHexBytes(outputAmountHex)
tx += outputAmountBytes
const pubkey = bitcoin.address.fromBase58Check(outputAddress).hash.toString('hex')
tx += '1976a914' + pubkey + '88ac'
// lock time
tx += '00000000'


check out the protocol documentation for more specific information: https://en.bitcoin.it/wiki/Protocol_documentation#tx

note: i copied and edited from something i've implemented previously, so if there's a mistake just let me know and i'll update it.