Skip to content

Commit

Permalink
Verify Bitcoin redeemer output script
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszslabon committed Oct 25, 2023
1 parent 103a22d commit 3d85b25
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions typescript/src/services/redemptions/redemptions-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
BitcoinAddressConverter,
BitcoinClient,
BitcoinNetwork,
BitcoinScriptUtils,
BitcoinTxOutput,
BitcoinUtxo,
} from "../../lib/bitcoin"
Expand Down Expand Up @@ -57,8 +58,14 @@ export class RedemptionsService {
bitcoinRedeemerAddress,
bitcoinNetwork
)

// TODO: Validate the given script is supported for redemption.
if (
!BitcoinScriptUtils.isP2PKHScript(redeemerOutputScript) &&
!BitcoinScriptUtils.isP2WPKHScript(redeemerOutputScript) &&
!BitcoinScriptUtils.isP2SHScript(redeemerOutputScript) &&
!BitcoinScriptUtils.isP2WSHScript(redeemerOutputScript)
) {
throw new Error("Redeemer output script must be of standard type")
}

const { walletPublicKey, mainUtxo } = await this.findWalletForRedemption(
redeemerOutputScript,
Expand Down

0 comments on commit 3d85b25

Please sign in to comment.