Skip to content

Commit

Permalink
Verify Bitcoin redeemer script
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszslabon committed Oct 25, 2023
1 parent 103a22d commit bb14497
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion 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 @@ -58,7 +59,14 @@ export class RedemptionsService {
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 bb14497

Please sign in to comment.