Skip to content

Commit 7dffbe0

Browse files
authored
Merge pull request #92 from ChainSafe/irubido/pcztHexValidate
pczt hex validation
2 parents 91e29f4 + df453bf commit 7dffbe0

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

packages/snap/snap.manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"url": "https://github.com/ChainSafe/WebZjs.git"
88
},
99
"source": {
10-
"shasum": "iAfsbWYVP8O3rjK7Dp2FCpaoaeVaN7y5znqpVZ2c1nw=",
10+
"shasum": "kF01k16izYSjCweSFMJBg0hcaJq89Ngegf17gcSt+Tg=",
1111
"location": {
1212
"npm": {
1313
"filePath": "dist/bundle.js",

packages/snap/src/rpc/signPczt.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export async function signPczt({ pcztHexTring, signDetails }: SignPcztParams, or
2525
<Text>Amount: {signDetails.amount}</Text>
2626
<Divider />
2727
<Text>PCZT hex to sign</Text>
28-
<Copyable value={pcztHexTring}/>
28+
<Copyable value={pcztHexTring} />
2929
</Box>
3030
),
3131
},
@@ -40,7 +40,11 @@ export async function signPczt({ pcztHexTring, signDetails }: SignPcztParams, or
4040
// Generate the UnifiedSpendingKey and obtain the Viewing Key
4141
const spendingKey = new UnifiedSpendingKey('main', seed, 0);
4242
const seedFp = new SeedFingerprint(seed);
43-
43+
44+
if (!/^[0-9a-fA-F]+$/.test(pcztHexTring)) {
45+
throw new Error('pcztHexTring must be valid hex');
46+
}
47+
4448
const pcztBuffer = Buffer.from(pcztHexTring, 'hex');
4549

4650

0 commit comments

Comments
 (0)