From 9f3a3bd4d7c0215ae55967358754e5e1c0b5db5f Mon Sep 17 00:00:00 2001 From: Antoni Spaanderman <56turtle56@gmail.com> Date: Sun, 6 Feb 2022 12:41:37 +0100 Subject: [PATCH] also detect uncompressed pubkeys + fix errors --- .../address-labels/address-labels.component.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/components/address-labels/address-labels.component.ts b/frontend/src/app/components/address-labels/address-labels.component.ts index 3ec2d079b..75bbe7cba 100644 --- a/frontend/src/app/components/address-labels/address-labels.component.ts +++ b/frontend/src/app/components/address-labels/address-labels.component.ts @@ -73,8 +73,11 @@ export class AddressLabelsComponent implements OnInit { } detectMultisig(script: string) { + if (!script) { + return; + } const ops = script.split(' '); - if (ops.pop() != 'OP_CHECKMULTISIG') { + if (ops.length < 3 || ops.pop() != 'OP_CHECKMULTISIG') { return; } const opN = ops.pop(); @@ -82,12 +85,15 @@ export class AddressLabelsComponent implements OnInit { return; } const n = parseInt(opN.match(/[0-9]+/)[0]); + if (ops.length < n * 2 + 1) { + return; + } // pop n public keys for (var i = 0; i < n; i++) { - if (ops.pop().length != 66) { + if (!/^0((2|3)\w{64}|4\w{128})$/.test(ops.pop())) { return; } - if (ops.pop() != 'OP_PUSHBYTES_33') { + if (!/^OP_PUSHBYTES_(33|65)$/.test(ops.pop())) { return; } }