Skip to content

Commit

Permalink
Renamed UTXO value sum variable
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszslabon committed Sep 27, 2023
1 parent d021ddc commit ddc92db
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions typescript/src/deposit-sweep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,15 @@ export async function assembleDepositSweepTransaction(
)

// Calculate the value of transaction's output. Note that the value of fee
// needs to be subtracted from the sum.
let totalInputValue = BigNumber.from(0)
// needs to be subtracted from the sum of UTXO values.
let outputValue = BigNumber.from(0)
if (mainUtxo) {
totalInputValue = totalInputValue.add(mainUtxo.value)
outputValue = outputValue.add(mainUtxo.value)
}
for (const utxo of utxos) {
totalInputValue = totalInputValue.add(utxo.value)
outputValue = outputValue.add(utxo.value)
}
totalInputValue = totalInputValue.sub(fee)
outputValue = outputValue.sub(fee)

// Create the transaction.
const transaction = new Transaction()
Expand All @@ -190,7 +190,7 @@ export async function assembleDepositSweepTransaction(

// Add transaction output.
const scriptPubKey = address.toOutputScript(walletAddress, network)
transaction.addOutput(scriptPubKey, totalInputValue.toNumber())
transaction.addOutput(scriptPubKey, outputValue.toNumber())

// Sign the main UTXO input if there is main UTXO.
if (mainUtxo) {
Expand Down

0 comments on commit ddc92db

Please sign in to comment.