Building transaction using Cardano Serialization Lib

Hi!

I am trying to generate a simple cardano transaction using Cardano Serialization Lib that simply sends some ADA. I want to sign the transaction using web3 wallet like Nami and verify that signature.

I have an issue with the verification part, however the first step is to ensure my transaction is absolutely correct. I would really appreciate if anyone with expertise could check if there are any obvious errors or mistakes with my functions below. FYI: input transaction hash is randomly chosen.

export function generateTxForSigning(sendAddressBech32: string, receiveAddressBech32: string) {
const txBuilderCfg = csl.TransactionBuilderConfigBuilder.new()
.fee_algo(
csl.LinearFee.new(
csl.BigNum.from_str(“44”),
csl.BigNum.from_str(“155381”)
)
)
.coins_per_utxo_byte(csl.BigNum.from_str(“4310”))
.pool_deposit(csl.BigNum.from_str(“500000000”))
.key_deposit(csl.BigNum.from_str(“2000000”))
.max_value_size(5000)
.max_tx_size(16384)
.prefer_pure_change(true)
.build();

const txBuilder = csl.TransactionBuilder.new(txBuilderCfg);

// INPUT
const sendAddress = csl.Address.from_bech32(sendAddressBech32);
const baseAddress = csl.BaseAddress.from_address(sendAddress);
if (!baseAddress) {
return;
}

const pubKeyHash = baseAddress.payment_cred().to_keyhash();
if (!pubKeyHash) {
return;
}

const txInputHash = “ff8145628286711636d13c34bc07a8a8eb62b2f1aad954cf172c2abd5b1e6d30”
const txInputIndex = 3;

txBuilder.add_key_input(
pubKeyHash,
csl.TransactionInput.new(
csl.TransactionHash.from_hex(txInputHash),
txInputIndex
),
csl.Value.new(csl.BigNum.from_str(“161826921”))
);

// OUTPUT
const receiveAddress = csl.Address.from_bech32(receiveAddressBech32);
txBuilder.add_output(
csl.TransactionOutput.new(
receiveAddress,
csl.Value.new(csl.BigNum.from_str(“159826921”))
)
);

// TIME TO LIVE
const ttl = getCardanoSlot() + 5 * 60; //5 minutes
txBuilder.set_ttl_bignum(csl.BigNum.from_str(ttl.toString()));

// MIN FEE CALC
txBuilder.add_change_if_needed(sendAddress);

// CREATE TRANSACTION
const transaction = csl.Transaction.new(
txBuilder.build()
csl.TransactionWitnessSet.new()
undefined
);

// RETURN FOR WALLET SIGNING
return transaction.to_hex();
}

export function getCardanoSlot() {
const nowUnixTimestamp = new Date().getTime();
const startShelleyUnixTimestamp = nowUnixTimestamp - 1596491091;
return startShelleyUnixTimestamp + 4924800;
}