Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: glascake on September 02, 2021, 10:46:15 PM



Title: Help me understand pkey + “spending twice”
Post by: glascake on September 02, 2021, 10:46:15 PM
Just to clarify:
I will refer to an address as pKey.

I have this scenario:

Bob sends money to Tim
txIn ——txOut
pKey1->pKey2
0.5———>0.5
Now Tim sends his cash to Hannah
txIn ——txOut
pKey2->pKey3
0.5———>0.5

But Tim receives again money from Bob (to the same address)
txIn ——txOut
pKey4->pKey2
0.5———>0.5
Can he now spend 0.5 btc with pKey2 as input?




Second question more important one. (That’s the reason I’m asking the first one, so I can understand better)
Let’s say I have a address, on this address I received 0.1 btc daily.
Now I am using electrums sweep to transfer the funds to my real wallet. Will I be able to do indefinitely, meaning keep receiving 0.1btc/day on this one address and then using electrums sweep to transfer the funds once a week to my wallet?






Title: Re: Help me understand pkey + “spending twice”
Post by: achow101 on September 02, 2021, 10:58:35 PM
Yes, to both. Addresses do not expire. There is no consensus rule that prevents address reuse. It is only recommended to not reuse addresses for privacy reasons.


Title: Re: Help me understand pkey + “spending twice”
Post by: glascake on September 02, 2021, 11:18:04 PM
Thank you for the clarification:)


Title: Re: Help me understand pkey + “spending twice”
Post by: PrimeNumber7 on September 03, 2021, 04:44:54 AM
When you receive bitcoin to an address/public key, in order to spend that bitcoin, you need to use a private key associated with that specific address to spend that specific output. When you sign a transaction that spends your bitcoin, you are signing that you are spending a specific output to a specific transaction.

For example, if you receive a transaction to address bc1abc123...3 that is the 3rd output to txid 34def...45, you must use the private key associated bc1abc123...3 that signs that you are spending the 3rd output to txid 34def...45.


Title: Re: Help me understand pkey + “spending twice”
Post by: glascake on September 03, 2021, 09:23:19 AM
When you receive bitcoin to an address/public key, in order to spend that bitcoin, you need to use a private key associated with that specific address to spend that specific output. When you sign a transaction that spends your bitcoin, you are signing that you are spending a specific output to a specific transaction.

For example, if you receive a transaction to address bc1abc123...3 that is the 3rd output to txid 34def...45, you must use the private key associated bc1abc123...3 that signs that you are spending the 3rd output to txid 34def...45.

Thanks for explaining the obvious, but that was not the question. :D
The question was refering to receiving on a address (public+private key pair) which already has been used as output.


Title: Re: Help me understand pkey + “spending twice”
Post by: odolvlobo on September 08, 2021, 12:56:38 PM
Now I am using electrums sweep to transfer the funds to my real wallet. Will I be able to do indefinitely, meaning keep receiving 0.1btc/day on this one address and then using electrums sweep to transfer the funds once a week to my wallet?

Rather than "sweeping" the private key periodically, it would probably be more convenient to create another electrum wallet using that private key.

1. Select "Create new wallet" or "New/Restore".
2. Name the new wallet.
3. Select "Import Bitcoin addresses or private keys".


Title: Re: Help me understand pkey + “spending twice”
Post by: glascake on September 09, 2021, 03:19:50 PM
Rather than "sweeping" the private key periodically, it would probably be more convenient to create another electrum wallet using that private key.
1. Select "Create new wallet" or "New/Restore".
2. Name the new wallet.
3. Select "Import Bitcoin addresses or private keys".

thats a good idea, but if i want to send the bitcoin i still would have to pay the "high" transactoin fee


Title: Re: Help me understand pkey + “spending twice”
Post by: odolvlobo on September 09, 2021, 05:29:31 PM
Rather than "sweeping" the private key periodically, it would probably be more convenient to create another electrum wallet using that private key.
1. Select "Create new wallet" or "New/Restore".
2. Name the new wallet.
3. Select "Import Bitcoin addresses or private keys".

thats a good idea, but if i want to send the bitcoin i still would have to pay the "high" transactoin fee

It's potentially one less fee:

Code:
imported private key wallet ⟶ payee

instead of

Code:
private key ⟶ wallet ⟶ payee