How can the wallet identify public addresses are linked to a private address

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.

Patrick W. McMahon

Posted 2019-10-30T00:58:00.590

Reputation: 361

Answers

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.

Raghav Sood

Posted 2019-10-30T00:58:00.590

Reputation: 10 897

can any wallet identify that wallets transactions or can only that wallet do this?Patrick W. McMahon 2019-10-30T01:09:07.093

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 2019-10-30T01:26:24.183

So there's no way of having a private address that other wallets can confirm a transaction came from it?Patrick W. McMahon 2019-10-30T01:27:52.273

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 momentRaghav Sood 2019-10-30T01:31:36.310

What if you had a special new transaction and the wallets needed to only accept it as valid if the sender was from a set address without knowing the private address; is this possible?Patrick W. McMahon 2019-10-30T01:33:31.900

That's not how bitcoin works - you cannot chose when to accept Bitcoin. You could build a wallet that hides transactions that come from addresses you don't want, but you cannot prevent the transactions from actually taking placeRaghav Sood 2019-10-30T01:39:56.837

What if you added new types of transactions that could only be valid from set sender addressesPatrick W. McMahon 2019-10-30T01:41:37.800

2Sure, 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 2019-10-30T01:43:17.563

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).

chytrik

Posted 2019-10-30T00:58:00.590

Reputation: 10 276

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 2019-10-30T09:42:40.127

1No, 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 2019-10-30T09:49:37.810

0

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

They are unequivocal.

D L

Posted 2019-10-30T00:58:00.590

Reputation: 478