Confirmed Deposit Credits
EasyStreams · Coinbase
A deposit service watches the blockchain and receives events in order. Each event is a list [kind, tx_id, asset, amount, confirmations]:
kind == "seen": a report about transactiontx_id. The firstseenfor atx_idregisters it with thatassetandamount. A laterseenfor an already registered transaction is treated exactly like anupdate.kind == "update": a new confirmation count for a registered transaction. Itsassetandamountfields just repeat the original values and should be ignored. Anupdatefor a transaction that has not been registered yet is ignored entirely.
thresholds maps each asset to the number of confirmations it needs. A registered transaction is credited the first time any event for it reports confirmations >= thresholds[asset]. Each transaction is credited at most once, even if later reports drop below or go above the threshold.
Return the credits as [tx_id, asset, amount] lists (using the registered asset and amount), in the order they were credited.
Example 1
- Input:
- events = [["seen", "t1", "BTC", 2, 1], ["seen", "t2", "ETH", 10, 12], ["update", "t1", "BTC", 2, 2], ["update", "t1", "BTC", 2, 3], ["update", "t1", "BTC", 2, 4]], thresholds = {"BTC": 3, "ETH": 12}
- Output:
- [["t2", "ETH", 10], ["t1", "BTC", 2]]
- Explanation
- t2 arrives already at ETH's threshold of 12 and is credited immediately. t1 starts at 1 confirmation and is credited when an update reports 3; the later update at 4 does not credit it again.
Example 2
- Input:
- events = [["update", "t9", "BTC", 1, 5], ["seen", "t9", "BTC", 1, 1]], thresholds = {"BTC": 3}
- Output:
- []
- Explanation
- The update arrives before t9 has been seen, so it is ignored. After the
seenevent t9 has only 1 confirmation, so nothing is credited.
Example 3
- Input:
- events = [["seen", "a", "SOL", 7, 0], ["seen", "a", "SOL", 7, 2]], thresholds = {"SOL": 0}
- Output:
- [["a", "SOL", 7]]
- Explanation
- SOL needs 0 confirmations, so
ais credited on its first report. The repeatedseenacts like an update and does not credit it twice.
Constraints
0 <= events.length <= 10^5kindis"seen"or"update"- Every asset in
eventsis a key ofthresholds 0 <= confirmations, thresholds[asset] <= 10001 <= amount <= 10^9