Skip to content

Commit

Permalink
[Fix/stacks] transaction broadcast API error (#9137)
Browse files Browse the repository at this point in the history
* fix(stx): broadcast failure due to wrong fee

* chore: changeset
  • Loading branch information
lawRathod authored Feb 7, 2025
1 parent 6524dcf commit 50767e7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/small-hornets-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ledgerhq/coin-stacks": patch
---

Fix transaction broadcast
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { StacksMainnet } from "@stacks/network";
import {
UnsignedTokenTransferOptions,
estimateTransaction,
estimateTransactionByteLength,
makeUnsignedSTXTokenTransfer,
} from "@stacks/transactions";
import BigNumber from "bignumber.js";
Expand Down Expand Up @@ -43,7 +44,7 @@ export const estimateMaxSpendable: AccountBridge<Transaction>["estimateMaxSpenda

const tx = await makeUnsignedSTXTokenTransfer(options);

const [feeEst] = await estimateTransaction(tx.payload);
const [feeEst] = await estimateTransaction(tx.payload, estimateTransactionByteLength(tx));

const diff = spendableBalance.minus(new BigNumber(feeEst.fee));
return diff.gte(0) ? diff : new BigNumber(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
TransactionVersion,
UnsignedTokenTransferOptions,
estimateTransaction,
estimateTransactionByteLength,
makeUnsignedSTXTokenTransfer,
} from "@stacks/transactions";
import BigNumber from "bignumber.js";
Expand Down Expand Up @@ -48,7 +49,7 @@ export const prepareTransaction: AccountBridge<Transaction>["prepareTransaction"
: AddressVersion.TestnetSingleSig;
const senderAddress = c32address(addressVersion, tx.auth.spendingCondition!.signer);

const [fee] = await estimateTransaction(tx.payload);
const [fee] = await estimateTransaction(tx.payload, estimateTransactionByteLength(tx));

patch.fee = new BigNumber(fee.fee);
patch.nonce = await findNextNonce(senderAddress, pendingOperations);
Expand Down

2 comments on commit 50767e7

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Bot] Testing with 'Nitrogen' ($0.00) ⏲ 1524ms

What is the bot and how does it work? Everything is documented here!

1 critical spec errors

Spec Stacks failed!

Error: speculos process failure. vnc_server: readall: connection closed

Details of the 0 mutations

Spec Stacks (failed)


Details of the 1 uncovered mutations

Spec Stacks (1)

  • Send 50%~:
Portfolio ($0.00) – Details of the 1 currencies
Spec (accounts) State Remaining Runs (est) funds?
Stacks (0) 0 ops , 🤷‍♂️ ``

Performance ⏲ 1524ms

Time spent for each spec: (total across mutations)

Spec (accounts) preload scan re-sync tx status sign op broadcast test destination test
TOTAL N/A N/A N/A N/A N/A N/A N/A N/A
Stacks (0) N/A N/A N/A N/A N/A N/A N/A N/A

What is the bot and how does it work? Everything is documented here!

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Bot] Testing with 'Nitrogen' ($0.00) ⏲ 1429ms

What is the bot and how does it work? Everything is documented here!

1 critical spec errors

Spec Stacks failed!

Error: speculos process failure. vnc_server: readall: connection closed

Details of the 0 mutations

Spec Stacks (failed)


Details of the 1 uncovered mutations

Spec Stacks (1)

  • Send 50%~:
Portfolio ($0.00) – Details of the 1 currencies
Spec (accounts) State Remaining Runs (est) funds?
Stacks (0) 0 ops , 🤷‍♂️ ``

Performance ⏲ 1429ms

Time spent for each spec: (total across mutations)

Spec (accounts) preload scan re-sync tx status sign op broadcast test destination test
TOTAL N/A N/A N/A N/A N/A N/A N/A N/A
Stacks (0) N/A N/A N/A N/A N/A N/A N/A N/A

What is the bot and how does it work? Everything is documented here!

Please sign in to comment.