diff --git a/src/lib/converter/input/tapScriptSig.d.ts b/src/lib/converter/input/tapScriptSig.d.ts index 85b8c80..28884a9 100644 --- a/src/lib/converter/input/tapScriptSig.d.ts +++ b/src/lib/converter/input/tapScriptSig.d.ts @@ -1,6 +1,6 @@ import { KeyValue, TapScriptSig } from '../../interfaces'; export declare function decode(keyVal: KeyValue): TapScriptSig; export declare function encode(tSig: TapScriptSig): KeyValue; -export declare const expected = "{ pubkey: Buffer; signature: Buffer; }"; +export declare const expected = "{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }"; export declare function check(data: any): data is TapScriptSig; export declare function canAddToArray(array: TapScriptSig[], item: TapScriptSig, dupeSet: Set): boolean; diff --git a/src/lib/converter/input/tapScriptSig.js b/src/lib/converter/input/tapScriptSig.js index 4e71761..7180d32 100644 --- a/src/lib/converter/input/tapScriptSig.js +++ b/src/lib/converter/input/tapScriptSig.js @@ -37,7 +37,7 @@ function encode(tSig) { }; } exports.encode = encode; -exports.expected = '{ pubkey: Buffer; signature: Buffer; }'; +exports.expected = '{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }'; function check(data) { return ( Buffer.isBuffer(data.pubkey) && @@ -50,9 +50,14 @@ function check(data) { } exports.check = check; function canAddToArray(array, item, dupeSet) { - const dupeString = item.pubkey.toString('hex'); + const dupeString = + item.pubkey.toString('hex') + item.leafHash.toString('hex'); if (dupeSet.has(dupeString)) return false; dupeSet.add(dupeString); - return array.filter(v => v.pubkey.equals(item.pubkey)).length === 0; + return ( + array.filter( + v => v.pubkey.equals(item.pubkey) && v.leafHash.equals(item.leafHash), + ).length === 0 + ); } exports.canAddToArray = canAddToArray; diff --git a/ts_src/lib/converter/input/tapScriptSig.ts b/ts_src/lib/converter/input/tapScriptSig.ts index 6c437a7..4c02989 100644 --- a/ts_src/lib/converter/input/tapScriptSig.ts +++ b/ts_src/lib/converter/input/tapScriptSig.ts @@ -37,7 +37,8 @@ export function encode(tSig: TapScriptSig): KeyValue { }; } -export const expected = '{ pubkey: Buffer; signature: Buffer; }'; +export const expected = + '{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }'; export function check(data: any): data is TapScriptSig { return ( Buffer.isBuffer(data.pubkey) && @@ -54,8 +55,13 @@ export function canAddToArray( item: TapScriptSig, dupeSet: Set, ): boolean { - const dupeString = item.pubkey.toString('hex'); + const dupeString = + item.pubkey.toString('hex') + item.leafHash.toString('hex'); if (dupeSet.has(dupeString)) return false; dupeSet.add(dupeString); - return array.filter(v => v.pubkey.equals(item.pubkey)).length === 0; + return ( + array.filter( + v => v.pubkey.equals(item.pubkey) && v.leafHash.equals(item.leafHash), + ).length === 0 + ); }