Skip to content

Commit 4752fd4

Browse files
Merge pull request #5343 from BitGo/BTC-0.fix-createExternalInternalPair
fix(abstract-utxo): fix createExternalInternalPair
2 parents f391687 + 10a48c3 commit 4752fd4

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

modules/abstract-utxo/src/descriptor/createWallet/createDescriptors.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,20 @@ function createExternalInternalPair(
1919
if (userKey.isNeutered()) {
2020
throw new Error('User key must be private');
2121
}
22-
return [
23-
createNamedDescriptorWithSignature(
24-
builder.name + '/external',
25-
getDescriptorFromBuilder({ ...builder, path: '0/*' }),
26-
userKey
27-
),
28-
createNamedDescriptorWithSignature(
29-
builder.name + '/internal',
30-
getDescriptorFromBuilder({ ...builder, path: '1/*' }),
31-
userKey
32-
),
33-
];
22+
const external = createNamedDescriptorWithSignature(
23+
builder.name + '/external',
24+
getDescriptorFromBuilder({ ...builder, path: '0/*' }),
25+
userKey
26+
);
27+
const internal = createNamedDescriptorWithSignature(
28+
builder.name + '/internal',
29+
getDescriptorFromBuilder({ ...builder, path: '1/*' }),
30+
userKey
31+
);
32+
if (external.value === internal.value) {
33+
throw new Error('External and internal descriptors must be different. Make to use the path in descriptor.');
34+
}
35+
return [external, internal];
3436
}
3537

3638
/**

0 commit comments

Comments
 (0)