2

So I realize that the Bitcoin transaction I make has information such as my wallet number, the amount of BTC being sent, and the recipient wallet number, and this whole message is encrypted using my own private key. And that this message can be decrypted with a public key.

Now, how do all the other nodes who need to verify my message 1) Know that this message is actually from me? When did I ever send them my public key?

2)J Know that I actually have enough funds to cover the transaction?

1

1) Nodes need not to know its your message, nodes are ok as long as your message is in correct format and satisfying the conditions.

2) When you broadcast transaction, your wallet will provide previous unspent transaction reference in the input section. Nodes will verify if those are really unspent and if the amount in output section is less than the total amount in the referenced input transactions.

1

1] Your public key is your identity on blockchain. No one can know whether the message was actually sent by whom? What they can know is that the message was sent by the owner of a particular public Key. You can sign the message using your private key, which can later be decrypted by the public key. Only a true owner of the public key can sign the message hence it proves that the message was indeed send by you. You can read about Digital Signature to understand better.

2] In the transaction, you are spending money by referring to a previous Tx.

Every full Bitcoin node maintains a database of which unspent outputs are left. When verifying a transaction, all its inputs are fetched from the database. If one is missing, validation fails. Among the data retrieved is the value of those unspent outputs, and their script (od address), which define the conditions under which the output can be spent. This information is necessary to validate whether the spending transaction has the correct signatures and does not create more bitcoin than it consumes.

0

Here are (overly) simplified answers:

  1. You signed your transaction with your (secret) private key, so that others can verify that signature using your public key which is in the transaction.
  2. Nodes verify that the coins you want to spend were previously sent to you.

And here are more details...

Most transactions (all those that transfer bitcoin -- that is, not those that create bitcoins) consist of a list of inputs and a list of outputs. The inputs refer to (unspent) outputs from previous transactions, and together constitute the whole value that is transferred. In addition to the amount for this particular output, each output specifies the conditions under which the output can be spent. The simplest condition is 'you own the address specified in the output'. Given that an address is the hash of a public key, what this condition actually means is that you know the private key for a public key that hashes to the given address.

In order to allow the nodes to check this condition, each input in a transaction is accompanied with the public key that hashes to the address to which this input was sent, and a signature of a simplified view of the transaction. This signature is created using the private key corresponding to this public key. The verifying node can build this same simplified view, and use the public key to verify that the signature is valid. This validates that you 'own' the address to which the coins were previously sent.

In order to be valid, a transaction must have enough inputs to cover all the outputs, and these inputs must refer to unspent outputs. That is, outputs from previous transactions that never appeared as input in any other transaction.

Note that nothing is encrypted, here. Everybody can see the source and destination addresses, as well as the amounts.

You will find more details in https://en.bitcoin.it/wiki/Transaction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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