Skip to content

Commit 0ebac8c

Browse files
committed
Add all signature lengths in SIG and DATASIG length checks
1 parent 4d10da6 commit 0ebac8c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/cashscript/src/Argument.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,17 @@ export function encodeFunctionArgument(argument: FunctionArgument, typeStr: stri
5959
throw Error(`Value for type ${type} should be a Uint8Array or hex string`);
6060
}
6161

62-
// Redefine SIG as a bytes65 (Schnorr) or bytes70, bytes71, bytes72 (ECDSA)
62+
// Redefine SIG as a bytes65 (Schnorr) or bytes71, bytes72, bytes73 (ECDSA)
6363
if (type === PrimitiveType.SIG && argument.byteLength !== 0) {
64-
if (![65, 70, 71, 72].includes(argument.byteLength)) {
64+
if (![65, 71, 72, 73].includes(argument.byteLength)) {
6565
throw new TypeError(`bytes${argument.byteLength}`, type);
6666
}
6767
type = new BytesType(argument.byteLength);
6868
}
6969

70-
// Redefine DATASIG as a bytes64 (Schnorr) or bytes70 (ECDSA) so it is included in the size checks below
70+
// Redefine DATASIG as a bytes64 (Schnorr) or bytes70, bytes71, bytes72 (ECDSA) so it is included in the size checks below
7171
if (type === PrimitiveType.DATASIG && argument.byteLength !== 0) {
72-
if (![64, 70].includes(argument.byteLength)) {
72+
if (![64, 70, 71, 72].includes(argument.byteLength)) {
7373
throw new TypeError(`bytes${argument.byteLength}`, type);
7474
}
7575
type = new BytesType(argument.byteLength);

packages/cashscript/test/e2e/HodlVault.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ describe('HodlVault', () => {
170170

171171
// sig: proper length but malformed
172172
await expect(new TransactionBuilder({ provider })
173-
.addInputs(utxos, hodlVault.unlock.spend(placeholder(70), oracleSig, message))
173+
.addInputs(utxos, hodlVault.unlock.spend(placeholder(71), oracleSig, message))
174174
.addOutput({ to: to, amount: amount })
175175
.addOutput({ to: to, amount: changeAmount })
176176
.setLocktime(100_000)

0 commit comments

Comments
 (0)