bip44 address generation

2

1

I am writing hd wallet following bip44.

After each transaction, should I create a brand new change address each time? Or can I use the same change address multiple times? What is the recommended practice here?

Cem Karay

Posted 2017-12-25T23:08:10.847

Reputation: 77

Answers

1

The recommended practice is to use any address for only one input and one output. Once you've done that, don't use it again.

To illustrate with examples:

  1. You receive 1 bitcoin to address A. You later send 1 bitcoin out. The next time you receive any bitcoin it should be with new address B.
  2. You receive 1 bitcoin to address B. You later send .5 bitcoin out. Transaction input should be 1 bitcoin from address B. Output should be .5 bitcoin to other person's receiving address and .5 bitcoin to your address C.
  3. Later, you receive 1 bitcoin. You should receive it with new address D. Your total wallet balance is 1.5 bitcoin, between addresses C and D.
  4. You spend .25 bitcoin. The transaction input should be .25 from address C and output should be .25 to other person's address and .25 to your address E. Address C is favored because it is the least number of inputs required to make the transaction. You now have 1.25 bitcoin between addresses D and E.
  5. You spend .15 bitcoin. Input is address E. Output is other's address and your address F. You now have 1.1 bitcoin between addresses D and F.
  6. You spend 1.05 bitcoin. Inputs are addresses D and F. Outputs are other's address and your address G. You now have .05 bitcoin in only address G.

frеdsbend

Posted 2017-12-25T23:08:10.847

Reputation: 1 608

I see. But this means I have to create a new change address with all transactions that needs a change address. How feasible is this? I mean I will have number of address that is almost equal to number of outbound transactions. – Cem Karay – 2018-01-21T09:41:38.360

@cemkaray All HD wallets already do it, so I'd say it's fully feasible. – frеdsbend – 2018-01-21T15:44:08.363