File tree Expand file tree Collapse file tree 2 files changed +22
-14
lines changed Expand file tree Collapse file tree 2 files changed +22
-14
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,13 @@ function stacksEqual(a, b) {
1616 } ) ;
1717}
1818function chunkHasUncompressedPubkey ( chunk ) {
19- if ( Buffer . isBuffer ( chunk ) && chunk . length === 65 ) {
20- if ( ecc . isPoint ( chunk ) ) return true ;
21- else return false ;
19+ if (
20+ Buffer . isBuffer ( chunk ) &&
21+ chunk . length === 65 &&
22+ chunk [ 0 ] === 0x04 &&
23+ ecc . isPoint ( chunk )
24+ ) {
25+ return true ;
2226 } else {
2327 return false ;
2428 }
@@ -60,9 +64,6 @@ function p2wsh(a, opts) {
6064 const _rchunks = lazy . value ( ( ) => {
6165 return bscript . decompile ( a . redeem . input ) ;
6266 } ) ;
63- const _rochunks = lazy . value ( ( ) => {
64- return bscript . decompile ( a . redeem . output ) ;
65- } ) ;
6667 let network = a . network ;
6768 if ( ! network ) {
6869 network = ( a . redeem && a . redeem . network ) || networks_1 . bitcoin ;
@@ -180,7 +181,10 @@ function p2wsh(a, opts) {
180181 throw new TypeError ( 'Witness and redeem.witness mismatch' ) ;
181182 if (
182183 ( a . redeem . input && _rchunks ( ) . some ( chunkHasUncompressedPubkey ) ) ||
183- ( a . redeem . output && _rochunks ( ) . some ( chunkHasUncompressedPubkey ) )
184+ ( a . redeem . output &&
185+ ( bscript . decompile ( a . redeem . output ) || [ ] ) . some (
186+ chunkHasUncompressedPubkey ,
187+ ) )
184188 ) {
185189 throw new TypeError (
186190 'redeem.input or redeem.output contains uncompressed pubkey' ,
Original file line number Diff line number Diff line change @@ -20,9 +20,13 @@ function stacksEqual(a: Buffer[], b: Buffer[]): boolean {
2020}
2121
2222function chunkHasUncompressedPubkey ( chunk : StackElement ) : boolean {
23- if ( Buffer . isBuffer ( chunk ) && chunk . length === 65 ) {
24- if ( ecc . isPoint ( chunk ) ) return true ;
25- else return false ;
23+ if (
24+ Buffer . isBuffer ( chunk ) &&
25+ chunk . length === 65 &&
26+ chunk [ 0 ] === 0x04 &&
27+ ecc . isPoint ( chunk )
28+ ) {
29+ return true ;
2630 } else {
2731 return false ;
2832 }
@@ -69,9 +73,6 @@ export function p2wsh(a: Payment, opts?: PaymentOpts): Payment {
6973 const _rchunks = lazy . value ( ( ) => {
7074 return bscript . decompile ( a . redeem ! . input ! ) ;
7175 } ) as StackFunction ;
72- const _rochunks = lazy . value ( ( ) => {
73- return bscript . decompile ( a . redeem ! . output ! ) ;
74- } ) as StackFunction ;
7576
7677 let network = a . network ;
7778 if ( ! network ) {
@@ -202,7 +203,10 @@ export function p2wsh(a: Payment, opts?: PaymentOpts): Payment {
202203 throw new TypeError ( 'Witness and redeem.witness mismatch' ) ;
203204 if (
204205 ( a . redeem . input && _rchunks ( ) . some ( chunkHasUncompressedPubkey ) ) ||
205- ( a . redeem . output && _rochunks ( ) . some ( chunkHasUncompressedPubkey ) )
206+ ( a . redeem . output &&
207+ ( bscript . decompile ( a . redeem . output ) || [ ] ) . some (
208+ chunkHasUncompressedPubkey ,
209+ ) )
206210 ) {
207211 throw new TypeError (
208212 'redeem.input or redeem.output contains uncompressed pubkey' ,
You can’t perform that action at this time.
0 commit comments