File tree 2 files changed +14
-5
lines changed
2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import {
21
21
isUtxoP2PKH ,
22
22
TransactionDetails ,
23
23
Unlocker ,
24
+ SignatureAlgorithm ,
24
25
} from './interfaces.js' ;
25
26
import {
26
27
createInputScript ,
@@ -336,10 +337,18 @@ export class Transaction {
336
337
}
337
338
}
338
339
339
- // Replace all SignatureTemplate with 65-length placeholder Uint8Arrays
340
- const placeholderArgs = this . encodedFunctionArgs . map ( ( arg ) => (
341
- arg instanceof SignatureTemplate ? placeholder ( 65 ) : arg
342
- ) ) ;
340
+ // Replace all SignatureTemplate with placeholder Uint8Arrays
341
+ const placeholderArgs = this . encodedFunctionArgs . map ( ( arg ) => {
342
+ if ( ! ( arg instanceof SignatureTemplate ) ) return arg ;
343
+
344
+ // Schnorr signatures are *always* 65 bytes: 64 for signature + 1 byte for hashtype.
345
+ if ( arg . getSignatureAlgorithm ( ) === SignatureAlgorithm . SCHNORR ) return placeholder ( 65 ) ;
346
+
347
+ // ECDSA signatures are at least 71 bytes: 64 bytes for signature + 1 byte for hashtype + 6 bytes for encoding
348
+ // overhead. But it may have up to 2 extra bytes for padding, so we overestimate by 2 bytes.
349
+ // (see https://transactionfee.info/charts/bitcoin-script-ecdsa-length/)
350
+ return placeholder ( 73 ) ;
351
+ } ) ;
343
352
344
353
// Create a placeholder preimage of the correct size
345
354
const placeholderPreimage = this . abiFunction . covenant
Original file line number Diff line number Diff line change 1
1
// Code taken and adapted from https://github.com/bitcoinjs/bip68
2
- // If we make signficant changes to this code, we should also take and adapt the tests from that repository.
2
+ // If we make significant changes to this code, we should also take and adapt the tests from that repository.
3
3
4
4
// see https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki#compatibility
5
5
You can’t perform that action at this time.
0 commit comments