<p>There are several ways to accomplish this. First as chytrik stated above, not running your own node is dangerous, but in my opinion only if you plan on submitting transactions. When it comes to watching wallets, there are 2 ways. </p>

<ol>
<li>Active scanning. This method involves asking nodes/services what transactions exist for a particular address.</li>
<li>Passive triggering. This is usually accomplished by asking a third party to inform you that a deposit has been detected. </li>
</ol>

<p>In the case of 1, it can be costly to scan every address ever used especially when creating a new address for each transaction or scaling to a large user or wallet count. </p>

<p>In the case of 2, relying only on a third party can be tricky.</p>

<p>The most cost effective way to handle this is to do both. Use a third party for primary notifications. If you expect a transaction during a window of say 10 minutes, you can have your system process the request once the third party triggers, and you can perform a "manual check" from the node directly by asking for all transactions and parsing the results looking for the expected transaction. This will give you the fastest response and the lowest delay. You could even only make the node request once at the end of 10 minutes as a fall back "final check" before invalidating the transaction (common with bitcoin payment services). </p>

<p>If you're doing something longer term, then you can once again rely on a third party to trigger an immediate update. As a fall back scan once an hour/day/week depending on what the use case is. If it's an end user application allow them to trigger the scan (of course within reason so you don't get DoS'd by your own clients clicking 'rescan'). </p>

<p>This is the entire "trust but verify". No third party will have your keys. If you're an exchange you'll likely be scanning, but for a better user experience depending on the size of your customer base, scanning millions of wallets every 5 seconds just isn't feasible. You can also use multiple third parties as well. For an exchange these services won't be that expensive. </p>

<p>If intent on being the third party in these examples, then parse every block that arrives from the blockchain. Do what you need to do when you detect a deposit on one of your addresses. </p>

<p>Note: I formed this as a "large scale" response to the concept of exchanges. There are other things that can be done at small scale eg: a personal wallet and setting a node to watch an address. </p>

CC BY-SA 4.0
2019-01-03T07:49:50.990Z
I have a few thousand addresses, using a third party service to notify for received transactions to those addresses may not be possible because if my server is shut down for a few days, rescanning all the addresses may be costly (time and fee) or reach the third party's limit. 

Seem like parsing blocks (from my own node or a third party) is the easier way to archive this.
Luong Nguyen
CC BY-SA 4.0
2019-01-03T20:25:17.920Z
That's fair enough. It depends on how responsive you want it. If you can/will plan to be offline for long periods, then it won't matter if you have to submit 10,000 requests to the node. An exchange really doesn't plan on being "down" for a few days.  People also won't tolerate waiting for their deposit to be delayed that long. My overall point is, thousands of wallets, if you want to scan every 5 seconds for updates to all of them, that may be a problem. At some combination of qty and frequency you will overwhelm the node. Suggesting you keep scalability in mind when designing your solution.
cleanmarker
CC BY-SA 4.0
2019-01-04T02:28:37.797Z
I think I found the solution, I add all the addresses to a wallet of an SPV application. The SPV app will be responsible for monitoring my addresses, updating received transactions no matter how long my server is down, thanks a lot for your help.
Luong Nguyen
CC BY-SA 4.0
2019-01-04T18:02:36.417Z
Sure thing! Since again, the context is "exchanges" and you're talking SPV now, this is a good read: https://medium.com/@jonaldfyookball/why-every-bitcoin-user-should-understand-spv-security-520d1d45e0b9 -- Be aware that this article is from the standpoint of a single user. Not an exchange. Also be aware of any limitations on the number of addresses your SPV may be able to handle.
cleanmarker
CC BY-SA 4.0
2019-01-03T07:17:06.390Z
2019-01-03T07:17:06.390Z
cleanmarker
<p>They're running full-node implementation. </p>

<blockquote>
  <p>how do they detect deposit transactions when their services are not
  running?</p>
</blockquote>

<p>It's blockchain, all data available for anyone, they able to fetch data from blockchain anytime.</p>

<blockquote>
  <p>do they fetch blocks at every height to scan for deposits to avoid any
  missing?</p>
</blockquote>

<p>There is a couple ways to get address deposits:</p>

<ol>
<li>You can check the balance of particular address every N seconds.</li>
<li>You can parse a block and check if there are transactions related to particular address.</li>
</ol>

CC BY-SA 4.0
2019-01-03T07:14:37.567Z
2019-01-03T07:14:37.567Z
Roman Kiselenko
<p>If they use transaction/wallet listener, how do they detect deposit transactions when their services are not running, do they fetch blocks at every height to scan for deposits to avoid any missing?
Thanks,</p>

CC BY-SA 4.0
2019-01-03T03:41:25.463Z
Any exchange that isn't running their own nodes in order to watch transactions is just a robbery waiting to happen. If you're handling large amount of BTC/whatever else, you should hopefully understand the massive danger inherent in trusting a 3rd party to provide information to you.
chytrik
CC BY-SA 4.0
2019-01-03T03:47:37.517Z
If they run a full node or an SPV node, how do they avoid missing any deposit transaction, I'd like to know how it works to implement a similar solution.
Luong Nguyen
<exchanges>
How do exchange sites know all user deposit transactions?
Luong Nguyen
# How do exchange sites know all user deposit transactions?

(Asked by: username_0 on 2019-01-03)

If they use transaction/wallet listener, how do they detect deposit transactions when their services are not running, do they fetch blocks at every height to scan for deposits to avoid any missing?
Thanks,

**Tags:** exchanges

> **Comments:**
> **username_1**: Any exchange that isn't running their own nodes in order to watch transactions is just a robbery waiting to happen. If you're handling large amount of BTC/whatever else, you should hopefully understand the massive danger inherent in trusting a 3rd party to provide information to you.  
> **username_0**: If they run a full node or an SPV node, how do they avoid missing any deposit transaction, I'd like to know how it works to implement a similar solution.  

---

## 2 answers

### Answer by username_2 on 2019-01-03. Score: 1 | Accepted answer

There are several ways to accomplish this. First as username_1 stated above, not running your own node is dangerous, but in my opinion only if you plan on submitting transactions. When it comes to watching wallets, there are 2 ways.

1. Active scanning. This method involves asking nodes/services what transactions exist for a particular address.
2. Passive triggering. This is usually accomplished by asking a third party to inform you that a deposit has been detected.

In the case of 1, it can be costly to scan every address ever used especially when creating a new address for each transaction or scaling to a large user or wallet count.

In the case of 2, relying only on a third party can be tricky.

The most cost effective way to handle this is to do both. Use a third party for primary notifications. If you expect a transaction during a window of say 10 minutes, you can have your system process the request once the third party triggers, and you can perform a "manual check" from the node directly by asking for all transactions and parsing the results looking for the expected transaction. This will give you the fastest response and the lowest delay. You could even only make the node request once at the end of 10 minutes as a fall back "final check" before invalidating the transaction (common with bitcoin payment services).

If you're doing something longer term, then you can once again rely on a third party to trigger an immediate update. As a fall back scan once an hour/day/week depending on what the use case is. If it's an end user application allow them to trigger the scan (of course within reason so you don't get DoS'd by your own clients clicking 'rescan').

This is the entire "trust but verify". No third party will have your keys. If you're an exchange you'll likely be scanning, but for a better user experience depending on the size of your customer base, scanning millions of wallets every 5 seconds just isn't feasible. You can also use multiple third parties as well. For an exchange these services won't be that expensive.

If intent on being the third party in these examples, then parse every block that arrives from the blockchain. Do what you need to do when you detect a deposit on one of your addresses.

Note: I formed this as a "large scale" response to the concept of exchanges. There are other things that can be done at small scale eg: a personal wallet and setting a node to watch an address.

> **Comments:**
> **username_0**: I have a few thousand addresses, using a third party service to notify for received transactions to those addresses may not be possible because if my server is shut down for a few days, rescanning all the addresses may be costly (time and fee) or reach the third party's limit.   Seem like parsing blocks (from my own node or a third party) is the easier way to archive this.  
> **username_2**: That's fair enough. It depends on how responsive you want it. If you can/will plan to be offline for long periods, then it won't matter if you have to submit 10,000 requests to the node. An exchange really doesn't plan on being "down" for a few days.  People also won't tolerate waiting for their deposit to be delayed that long. My overall point is, thousands of wallets, if you want to scan every 5 seconds for updates to all of them, that may be a problem. At some combination of qty and frequency you will overwhelm the node. Suggesting you keep scalability in mind when designing your solution.  
> **username_0**: I think I found the solution, I add all the addresses to a wallet of an SPV application. The SPV app will be responsible for monitoring my addresses, updating received transactions no matter how long my server is down, thanks a lot for your help.  
> **username_2**: Sure thing! Since again, the context is "exchanges" and you're talking SPV now, this is a good read: https://medium.com/@jonaldfyookball/why-every-bitcoin-user-should-understand-spv-security-520d1d45e0b9 -- Be aware that this article is from the standpoint of a single user. Not an exchange. Also be aware of any limitations on the number of addresses your SPV may be able to handle.  

---

### Answer by username_3 on 2019-01-03. Score: 2

They're running full-node implementation.

> how do they detect deposit transactions when their services are not
> running?

It's blockchain, all data available for anyone, they able to fetch data from blockchain anytime.

> do they fetch blocks at every height to scan for deposits to avoid any
> missing?

There is a couple ways to get address deposits:

1. You can check the balance of particular address every N seconds.
2. You can parse a block and check if there are transactions related to particular address.


---

