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) {
16
16
} ) ;
17
17
}
18
18
function 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 ;
22
26
} else {
23
27
return false ;
24
28
}
@@ -60,9 +64,6 @@ function p2wsh(a, opts) {
60
64
const _rchunks = lazy . value ( ( ) => {
61
65
return bscript . decompile ( a . redeem . input ) ;
62
66
} ) ;
63
- const _rochunks = lazy . value ( ( ) => {
64
- return bscript . decompile ( a . redeem . output ) ;
65
- } ) ;
66
67
let network = a . network ;
67
68
if ( ! network ) {
68
69
network = ( a . redeem && a . redeem . network ) || networks_1 . bitcoin ;
@@ -180,7 +181,10 @@ function p2wsh(a, opts) {
180
181
throw new TypeError ( 'Witness and redeem.witness mismatch' ) ;
181
182
if (
182
183
( 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
+ ) )
184
188
) {
185
189
throw new TypeError (
186
190
'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 {
20
20
}
21
21
22
22
function 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 ;
26
30
} else {
27
31
return false ;
28
32
}
@@ -69,9 +73,6 @@ export function p2wsh(a: Payment, opts?: PaymentOpts): Payment {
69
73
const _rchunks = lazy . value ( ( ) => {
70
74
return bscript . decompile ( a . redeem ! . input ! ) ;
71
75
} ) as StackFunction ;
72
- const _rochunks = lazy . value ( ( ) => {
73
- return bscript . decompile ( a . redeem ! . output ! ) ;
74
- } ) as StackFunction ;
75
76
76
77
let network = a . network ;
77
78
if ( ! network ) {
@@ -202,7 +203,10 @@ export function p2wsh(a: Payment, opts?: PaymentOpts): Payment {
202
203
throw new TypeError ( 'Witness and redeem.witness mismatch' ) ;
203
204
if (
204
205
( 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
+ ) )
206
210
) {
207
211
throw new TypeError (
208
212
'redeem.input or redeem.output contains uncompressed pubkey' ,
You can’t perform that action at this time.
0 commit comments