1919 */
2020
2121import * as bitcoin from 'bitcoinjs-lib' ;
22+ < < < << << HEAD
2223import * as secp256k1 from 'tiny - secp256k1 ';
24+ === === =
25+ > >>> >>> feat / multisig - escrow
2326import type { ChainAdapter } from './interface' ;
2427import type {
2528 MultisigChain ,
@@ -242,14 +245,26 @@ export class BtcMultisigAdapter implements ChainAdapter {
242245 ) : Promise < boolean > {
243246 try {
244247 const pubkeyBuf = parsePubkey ( signerPubkey ) ;
248+ < < < << << HEAD
245249 const txHash = txData . tx_hash_to_sign as string | undefined ;
246250
247251 // Check that the pubkey is one of the expected participants when provided.
252+ === === =
253+ const sigBuf = Buffer . from ( signature , 'hex' ) ;
254+
255+ // Verify the hash matches the pubkey and signature
256+ // In production, this would verify the actual PSBT input signature
257+ const witnessScript = txData . witness_script as string ;
258+ if ( ! witnessScript ) return false ;
259+
260+ // Check that the pubkey is one of the multisig participants
261+ >>> > >>> feat / multisig - escrow
248262 const pubkeys = txData . pubkeys as string [ ] | undefined ;
249263 if ( pubkeys && ! pubkeys . includes ( signerPubkey ) ) {
250264 return false ;
251265 }
252266
267+ << < < < << HEAD
253268 // tx_hash_to_sign is required for cryptographic verification.
254269 // Fail closed when missing/malformed.
255270 if ( ! txHash | | txHash . length ! == 64 ) {
@@ -274,6 +289,10 @@ export class BtcMultisigAdapter implements ChainAdapter {
274289 if ( sigBuf . length !== 64 ) return false ;
275290 return secp256k1 . verify ( msgHash , pubkeyBuf , sigBuf ) ;
276291 }
292+ === = ===
293+ // Basic signature format validation (DER-encoded or Schnorr)
294+ return sigBuf . length >= 64 && pubkeyBuf . length >= 33 ;
295+ >>> > >>> feat / multisig - escrow
277296 } catch {
278297 return false ;
279298 }
@@ -293,7 +312,11 @@ export class BtcMultisigAdapter implements ChainAdapter {
293312 }
294313
295314 if ( signatures . length < 2 ) {
315+ << < < < << HEAD
296316 return { tx_hash : '', success: false, broadcasted: false };
317+ === === =
318+ return { tx_hash : '' , success : false } ;
319+ >>> > >>> feat / multisig - escrow
297320 }
298321
299322 // In production:
@@ -311,7 +334,10 @@ export class BtcMultisigAdapter implements ChainAdapter {
311334 return {
312335 tx_hash : txid ,
313336 success : true ,
337+ << < < < << HEAD
314338 broadcasted : false ,
339+ === = ===
340+ > >>> > >> feat / multisig - escrow
315341 } ;
316342 }
317343}
0 commit comments