Skip to content

Commit

Permalink
refactor: fix signer-key ensure
Browse files Browse the repository at this point in the history
  • Loading branch information
janniks committed Jan 24, 2024
1 parent 64326b1 commit ed8427b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/stacking/src/utils.ts
Expand Up @@ -352,7 +352,7 @@ export function ensureLegacyBtcAddressForPox1({

/**
* @internal
* Throws unless a signerKey is given for >= PoX-4 or missing before.
* Throws if signerKey is given for <= PoX-3 or signerKey is missing otherwise.
*/
export function ensureSignerKeyReadiness({
contract,
Expand All @@ -361,9 +361,11 @@ export function ensureSignerKeyReadiness({
contract: string;
signerKey?: string;
}) {
if (/\.pox(-[2-3])?$/.test(contract)) {
if (!signerKey) return;
if (signerKey && /\.pox(-[2-3])?$/.test(contract)) {
throw new Error('PoX-1, PoX-2 and PoX-3 do not accept a signer-key (buff 33)');
}
throw new Error('PoX-4 requires a signer-key (buff 33) to stack');

if (!signerKey) {
throw new Error('PoX-4 or later requires a signer-key (buff 33) to stack');
}
}

0 comments on commit ed8427b

Please sign in to comment.