0

A quote from satoshi on the bitcointalk server, May 26 2010:

I'm also recommending this approach for the implementation of web apps. I just posted some sample code showing a suggested way of implementing this.

Does anyone have a reference to this code?

Can anyone write a succinct description of the approach?

2
  • 2
    Wasn't this just referring to showing a new receiving address every time a payment is received? Commented Dec 9, 2021 at 15:45
  • 1
    @RedGrittyBrick I believe so. Commented Dec 9, 2021 at 16:29

1 Answer 1

5

I believe the post they were referring to is this one, posted 24 minutes prior, where they say:

The idea is that if you give the username whenever you call getnewaddress, you can get the user's total received across all their addresses using the "bylabel" functions. You can freely change their address without worrying about tracking all their old addresses.

A good way to automate changing the user's receiving address: just before displaying their current address, check if it has been used to receive anything, if it has then replace it with a new one:

// Get a new address whenever the current one has received anything
if (strAddr == "" || getreceivedbyaddress(strAddr) > 0)
   strAddr = getnewaddress(strUsername); // Label the address with username
Display(strAddr); // Display their current receiving address

I think the description and code are self-explanatory: check if the address has been used, and if so, generate a new one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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