Skip to content

Commit

Permalink
fix: utxo size calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
kvhnuke committed Sep 25, 2023
1 parent 6f2b6c9 commit bbb55d5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ const updateUTXOs = async () => {
2,
(network.value as BitcoinNetwork).networkInfo.paymentType
);
setTransactionFees(Math.ceil(txSize.txVBytes));
setTransactionFees(Math.ceil(txSize));
});
};
Expand Down
6 changes: 3 additions & 3 deletions packages/extension/src/providers/bitcoin/ui/libs/tx-size.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ const calculateSize = (
txVBytes +
(inputWitnessSize * input_count * 3) / 4;
const txWeight = txVBytes * 4;

return {
txVBytes,
txBytes,
Expand All @@ -239,14 +238,14 @@ const calculateSizeBasedOnType = (
numInputs: number,
numOutputs: number,
type: PaymentType
) => {
): number => {
const output: calcOutputType = {};
if (type === PaymentType.P2PKH) {
output.p2pkh_output_count = numOutputs;
} else {
output.p2wpkh_output_count = numOutputs;
}
return calculateSize(
const size = calculateSize(
{
input_script:
type === PaymentType.P2PKH
Expand All @@ -256,5 +255,6 @@ const calculateSizeBasedOnType = (
},
output
);
return type === PaymentType.P2PKH ? size.txBytes : size.txVBytes;
};
export { InputScriptType, calculateSize, calculateSizeBasedOnType };
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ const updateUTXOs = async () => {
2,
(props.network as BitcoinNetwork).networkInfo.paymentType
);
setTransactionFees(Math.ceil(txSize.txVBytes));
setTransactionFees(Math.ceil(txSize));
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const getBitcoinGasVals = async (
);
return getGasCostValues(
network as BitcoinNetwork,
Math.ceil(txSize.txVBytes),
Math.ceil(txSize),
price.toString(),
network.decimals,
network.currencyName
Expand Down

21 comments on commit bbb55d5

@github-actions
Copy link

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

@BROSUCHEK
Copy link

@BROSUCHEK BROSUCHEK commented on bbb55d5 Sep 25, 2023 via email

Choose a reason for hiding this comment

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

Please sign in to comment.