0

On block explorers such as blockchain.com, each unconfirmed transaction has a desired feerate set by the wallet such as 58.000 sat/B. This is not to be confused with the actual final fee calculation.

My question is how do they obtain/calculate the feerate desired by the users wallet that submitted the transaction?

Is this possible via the bitcoin JSON RPC api?

From what I understand, getrawtransaction() does not provide any details of the feerate set by the sender. Moreover, you can also get the feerate set by a user by getting their wallet details. If so, how is the wallet feerate set calculated if there are two inputs to the transaction?

1 Answer 1

1

The fee rate is not related to the confirmation status of the transaction.

As far as the bitcoin protocol is concerned, fee rate is simply transaction fee (in sats)/transaction size (in bytes). So for a 100 byte transaction, paying 10000 satoshis as a fee, the fee rate is 10000/1000, or 10 sats/byte.

Currently, you have two possible fee rates: Segwit and non-segwit.

The Fee Rate/weight unit, instead of fee rate/byte, measure is intended to provide a consistent view of fee rates, regardless of whether a transaction has segwit inputs or not.

The calculation remains the same - weight units/total fee gives you the fee rate per weight unit, with a non-segwit byte counting as 4 weight units, and a segwit byte counting as 1 (this is a simplification, full details are outside the scope of fee rates).

To calculate this using Bitcoin Core, simply get the transaction details via RPC. A decoded response contains a weight field, which you then divide by the total fees paid to determine the fee rate per weight unit.

If a transaction has multiple inputs from distinct wallets, the fee is still paid at a transaction level - to determine how much of a fee was "paid" by a particular input, you'd need to determine who received the outputs, and where the change went. Once you know the output break up, you can attempt to distribute the total fee among the participants.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.