1

I'm trying to understand the Bitcoin transaction creation process and how inputs and outputs work. From what I know, when a user creates a Bitcoin transaction, they typically select UTXOs (Unspent Transaction Outputs) as inputs to the transaction.

Given this, it seems that the amount of the transaction is implicitly determined by the UTXOs selected, since the sum of the inputs is what gets spent. In other words, the total amount of Bitcoin being sent would be based on the value of the UTXOs used in the inputs, while the user doesn't need to explicitly specify the amount.

Is that correct? Does the user really need to specify the amount at all, or is it entirely determined by the selected UTXOs? And if there's any difference, what is the role of specifying the amount in some wallet interfaces?

4 Answers 4

4

From the perspective of a transaction, there is no one "amount". A transaction has one or more inputs of certain amounts (determined by the transactions that created those UTXOs) and one or more outputs of certain amounts (determined in the transaction itself). The difference of the sum of input and output amounts is the transaction fee.

From the perspective of a wallet user, however, there usually is one specific "amount" that they want to send in a transaction, which becomes the amount in the output that goes to the recipient. After a desirable fee rate is determined, the wallet selects UTXOs to fund the transaction (see ). In most cases a combination of UTXOs with a perfectly matching amount will not be found, in which case a change output will be added that sends the remainder back to the sender (see ).

2

Alice has 2 UTXOs of 10.000 sats each.

She wants to pay Bob 15.000 sats.

The wallet will:

  • select both UTXOs as inputs (total 20.000 sats)
  • define 2 outputs:
    • 15.000 sats to Bob
    • 5.000 sats to Alice

The wallet needs to know the amount from Alice to know how to divide sats between outputs.

2

Reading this again after @amaclin’s answer, I realize that you might have indeed been asking about the input amounts rather than the output amounts. If so, you are correct. The input amounts are not explicitly specified in the transaction as they are specified by the prior transaction that created the UTXOs. A spending transaction only needs to specify which UTXOs it exactly spends, but the information about the output script and amount are already present in each node’s UTXO set.


If you were asking about output amounts, see my original answer below:

It depends on the type of transaction you are building.

If you are sweeping a wallet, consolidating into a single output or depositing several whole UTXOs to a service, you probably do not care about specifying the amount of the output. Rather, it is implicitly defined by the inputs and fees.

However, in my experience, most transactions are created to make one or multiple payments. When you make a payment transaction, you do want to send a specific amount to each receiver of the payment. Only the potential change output amount would then be determined by what remains from the inputs after deducting the payment amount and the fees.

1
Does the user really need to specify the amount at all

No. Transaction itself does not contain the amounts on inputs. But these values are used while creating ecdsa/schnorr signatures

Your Answer

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

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