Skip to content

Commit

Permalink
Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszslabon committed Sep 20, 2023
1 parent 53a4bbb commit 7d3f496
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions typescript/src/deposit-sweep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ export async function assembleDepositSweepTransactionBitcoinJsLib(
const walletKeyRing = createKeyRing(walletPrivateKey, witness)
const walletAddress = walletKeyRing.getAddress("string")

const ecPairApi = ECPairFactory(tinysecp);
const ecPairApi = ECPairFactory(tinysecp)

Check failure on line 291 in typescript/src/deposit-sweep.ts

View workflow job for this annotation

GitHub Actions / typescript-format

A function with a name starting with an uppercase letter should only be used as a constructor
// TODO: Pass appropriate network type (testnet vs mainnet).
const ecPair = ecPairApi.fromWIF(walletPrivateKey, networks.testnet)

Expand All @@ -310,7 +310,7 @@ export async function assembleDepositSweepTransactionBitcoinJsLib(
if (mainUtxo) {
transaction.addInput(
mainUtxo.transactionHash.reverse().toBuffer(),
mainUtxo.outputIndex,
mainUtxo.outputIndex
)
}
for (const utxo of utxos) {
Expand Down Expand Up @@ -403,14 +403,21 @@ function findPreviousOutput(
utxos: (UnspentTransactionOutput & RawTransaction)[],
mainUtxo?: UnspentTransactionOutput & RawTransaction
) {
if (mainUtxo &&
if (
mainUtxo &&
mainUtxo.transactionHash.equals(inputHash) &&
mainUtxo.outputIndex === inputIndex) {
return Transaction.fromHex(mainUtxo.transactionHex).outs[mainUtxo.outputIndex]
mainUtxo.outputIndex === inputIndex
) {
return Transaction.fromHex(mainUtxo.transactionHex).outs[
mainUtxo.outputIndex
]
}

for (const utxo of utxos) {
if (utxo.transactionHash.equals(inputHash) && utxo.outputIndex === inputIndex) {
if (
utxo.transactionHash.equals(inputHash) &&
utxo.outputIndex === inputIndex
) {
return Transaction.fromHex(utxo.transactionHex).outs[utxo.outputIndex]
}
}
Expand Down Expand Up @@ -559,7 +566,7 @@ async function signP2WSHDepositInputBitcoinJsLib(
ecPair: ECPairInterface
) {
const { walletPublicKey, depositScript, previousOutputValue } =
await prepareInputSignDataBitcoinIsLib(deposit, ecPair)
await prepareInputSignDataBitcoinIsLib(deposit, ecPair)

const sigHashType = Transaction.SIGHASH_ALL

Expand Down Expand Up @@ -590,9 +597,7 @@ async function prepareInputSignDataBitcoinIsLib(
}> {
const walletPublicKey = ecPair.publicKey.toString("hex")

if (
computeHash160(walletPublicKey) != deposit.walletPublicKeyHash
) {
if (computeHash160(walletPublicKey) != deposit.walletPublicKeyHash) {
throw new Error(
"Wallet public key does not correspond to wallet private key"
)
Expand Down

0 comments on commit 7d3f496

Please sign in to comment.