0

As the wallet can generate many public addresses from a private address. How does the wallet know that any transaction from or to the wallet is for that private wallet if the in and out can be any number of public addresses.

2

While exact implementations between wallets might differ, the general approach is usually similar to the following:

  1. A wallet generates a private key (or a set of keys) based on an HD wallet, or just individual random keys
  2. The public keys for private keys generated in 1. are calculated, and used to create the desired address scripts (p2pkh, p2sh (wrapped segwit/multisig), p2wpkh, p2wsh).
  3. The wallet stores the private key, along with a mapping to which address script uses that key.
  4. The wallet constantly scans the mempool and new blocks for outputs that send Bitcoin to the address scripts calculated in 2. When it discovers such an output, it adds the coins to the wallet balance and informs the user.

There are implementation specific variations on this (for example, an HD wallet may not store individual private keys, and store a mapping of the derivation path from the root key and the address script instead).

For an actual example, let's say our wallet has the private key for the address 1F1tAaz5x1HUXrCNLbtMDqcw6o5GNn4xqX. The HASH160 for the public key of this address is 99bc78ba577a95a11f1a344d4d2ae55f2f857b98, and the locking script is 76a91499bc78ba577a95a11f1a344d4d2ae55f2f857b9888ac. This locking script is what appears in the actual bitcoin transaction that sends coins to this address.

The wallet will store the private key, and make a note that the private key corresponds to that locking script. It will then scan the bitcoin blockchain for transactions which have an output that matches that locking script.

  • can any wallet identify that wallets transactions or can only that wallet do this? – Patrick W. McMahon Oct 30 at 1:09
  • Everyone can see the locking scripts, but determining which locking scripts all belong to the same wallet is non-trivial and is the subject of research. Entire companies exist around trying to figure that out. – Raghav Sood Oct 30 at 1:26
  • So there's no way of having a private address that other wallets can confirm a transaction came from it? – Patrick W. McMahon Oct 30 at 1:27
  • Bitcoin has no concept of a private address. The origin and destination of a transaction is always visible. At best, you could attempt to make sure that no one can link a Bitcoin address to you as a person, but that is difficult, and links can be discovered years in the future as new methods are found even if you succeed for the moment – Raghav Sood Oct 30 at 1:31
  • 2
    Sure, but that requires a fork of the Bitcoin blockchain, and you'd be hard pressed to get the community to agree to such a drastic measure. – Raghav Sood Oct 30 at 1:43
0

As the wallet can generate many public addresses from a private address.

I'm assuming by 'private address', you actually mean 'private key'.

Each private key effectively maps to one Bitcoin address, so for each new address your wallet creates, it will also first create a private key that the address is derived from. If your wallet is a hierarchical deterministic wallet, then it will have a 'master seed', but this seed is then used to derive subsequent private keys (and their corresponding public keys and addresses).

A wallet can watch the network for transactions that create UTXOs which are spendable by a key the wallet controls. How exactly this is accomplished can vary depending on the wallet architecture (full-node vs light wallet, etc).

  • Is there a way for all wallets on the network to determine a let's say special new type of transaction came from a verified list of wallets that are permitted by the network to make a special transaction while invalidating this transaction if coming from wallets not on the list. And at the same time no wallets knowing the private keys of these wallets on the list? – Patrick W. McMahon Oct 30 at 9:42
  • 1
    No, your comment doesn't accurately reflect the way the bitcoin network functions. There is no way to restrict who can send money to a certain address. – chytrik Oct 30 at 9:49
0

Public address is a 20Byte data. Private key is a 32Byte data.

They are unequivocal.

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.