Skip to content

Commit

Permalink
fix: stacks signature logic
Browse files Browse the repository at this point in the history
  • Loading branch information
zone117x committed Feb 21, 2024
1 parent 7966530 commit b0a8c8e
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions stacking/stacking.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const accounts = process.env.STACKING_KEYS.split(',').map(privKey => {
const pubKey = getPublicKeyFromPrivate(privKey);
const stxAddress = getAddressFromPrivateKey(privKey, TransactionVersion.Testnet);
const signerPrivKey = makeRandomPrivKey();
const signerPubKey = getPublicKeyFromPrivate(signerPrivKey);
const signerPubKey = getPublicKeyFromPrivate(signerPrivKey.data);
return {
privKey, pubKey, stxAddress,
btcAddr: publicKeyToBtcAddress(pubKey),
Expand Down Expand Up @@ -51,13 +51,14 @@ async function run() {
return;
}

const signerSignature = account.client.signPoxSignature({
const sigArgs = {
topic: 'stack-stx',
rewardCycle: poxInfo.current_cycle.id,
poxAddress,
period: cycles,
rewardCycle: poxInfo.reward_cycle_id,
poxAddress: account.btcAddr,
period: stackingCycles,
signerPrivateKey: account.signerPrivKey,
});
};
const signerSignature = account.client.signPoxSignature(sigArgs);
const stackingArgs = {
poxAddress: account.btcAddr,
privateKey: account.privKey,
Expand All @@ -68,7 +69,7 @@ async function run() {
signerKey: account.signerPubKey,
signerSignature,
};
console.log('Stacking with args:', { addr: account.stxAddress, ...stackingArgs, ...signerSignature });
console.log('Stacking with args:', { addr: account.stxAddress, ...stackingArgs, ...sigArgs });
const stackResult = await account.client.stack(stackingArgs);
console.log('Stacking tx result', stackResult);
await new Promise(resolve => setTimeout(resolve, postTxWait * 1000));
Expand Down

0 comments on commit b0a8c8e

Please sign in to comment.