Skip to content

Commit

Permalink
Renamed output script variable
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszslabon committed Sep 27, 2023
1 parent 98b622a commit e5c6ea2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions typescript/src/deposit-sweep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ export async function submitDepositSweepProof(
* P2WPKH UTXO.
* @param keyPair - A Signer object containing the public key and private key
* pair.
* @param prevOutScript - A Buffer containing the previous output script of the
* @param outputScript - A Buffer containing the previous output script of the
* UTXO.
* @param bitcoinNetwork - The Bitcoin network type.
* @returns A boolean indicating whether the derived address from the UTXO's
Expand All @@ -515,7 +515,7 @@ export async function submitDepositSweepProof(
*/
export function ownsUtxo(
keyPair: Signer,
prevOutScript: Buffer,
outputScript: Buffer,
bitcoinNetwork: BitcoinNetwork
): boolean {
const network = toBitcoinJsLibNetwork(bitcoinNetwork)
Expand All @@ -526,19 +526,19 @@ export function ownsUtxo(
const p2wpkhAddress =
payments.p2wpkh({ pubkey: keyPair.publicKey, network }).address || ""

// Try to extract an address from the provided prevOutScript.
// Try to extract an address from the provided output script.
let addressFromOutput = ""
try {
addressFromOutput =
payments.p2pkh({ output: prevOutScript, network }).address || ""
payments.p2pkh({ output: outputScript, network }).address || ""
} catch (e) {
// If not P2PKH, try P2WPKH.
try {
addressFromOutput =
payments.p2wpkh({ output: prevOutScript, network }).address || ""
payments.p2wpkh({ output: outputScript, network }).address || ""
} catch (err) {
// If neither p2pkh nor p2wpkh address can be derived, assume the previous
// output script comes from a different UTXO type or is corrupted.
// If neither p2pkh nor p2wpkh address can be derived, assume the output
// script comes from a different UTXO type or is corrupted.
return false
}
}
Expand Down

0 comments on commit e5c6ea2

Please sign in to comment.