<p>I believe the post they were referring to is <a href="https://bitcointalk.org/index.php?topic=157.0" rel="noreferrer">this one</a>, posted 24 minutes prior, where they say:</p>
<blockquote>
<p>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 &quot;bylabel&quot; functions.  You can freely change their address without worrying about tracking all their old addresses.</p>
<p>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:</p>
</blockquote>
<pre><code>// Get a new address whenever the current one has received anything
if (strAddr == &quot;&quot; || getreceivedbyaddress(strAddr) &gt; 0)
   strAddr = getnewaddress(strUsername); // Label the address with username
Display(strAddr); // Display their current receiving address
</code></pre>
<p>I think the description and code are self-explanatory: check if the address has been used, and if so, generate a new one.</p>

CC BY-SA 4.0
2021-12-10T03:38:46.513Z
2021-12-10T03:38:46.513Z
meshcollider
<p>A <a href="https://bitcointalk.org/index.php?topic=154.msg1254#msg1254" rel="nofollow noreferrer">quote from satoshi on the bitcointalk server</a>, May 26 2010:</p>
<blockquote>
<p>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.</p>
</blockquote>
<p>Does anyone have a reference to this code?</p>
<p>Can anyone write a succinct description of the approach?</p>

CC BY-SA 4.0
2021-12-09T15:45:53.510Z
Wasn't this just referring to showing a new receiving address every time a payment is received?
RedGrittyBrick
CC BY-SA 4.0
2021-12-09T16:29:25.893Z
@RedGrittyBrick I believe so.
Pieter Wuille
<satoshi-nakamoto><bitcointalk><webapp>
What was Satoshi's approach/sample code for implementation of web apps?
Lee
# What was Satoshi's approach/sample code for implementation of web apps?

(Asked by: username_0 on 2021-12-09)

A [quote from satoshi on the bitcointalk server](https://bitcointalk.org/index.php?topic=154.msg1254#msg1254), 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?

**Tags:** satoshi-nakamoto, bitcointalk, webapp

> **Comments:**
> **username_1**: Wasn't this just referring to showing a new receiving address every time a payment is received?  
> **username_2**: @username_1 I believe so.  

---

## 1 answers

### Answer by username_3 on 2021-12-10. Score: 5 | Accepted answer

I believe the post they were referring to is [this one](https://bitcointalk.org/index.php?topic=157.0), 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.


---

