Attempting to create a bitcoin based mostly webapp in python which takes BTC deposits. How would I take advantage of pybitcointools to implement this?
You are principally heading in the right direction.
The best technique to construct a consumer deposit system is to easily have a one to many
user->deal with mapping.
By default, when a consumer deposits BTC to an deal with, you mechanically generate a brand new deal with for them. Nonetheless, you do not delete the earlier deal with, or the truth that it’s linked to that consumer.
This manner, even when a consumer sends BTC to an older deal with, you’ll be able to obtain it for them.
Moreover, the way you course of withdrawals depends upon what sort of system you might be constructing. Whether it is merely an easy pockets system, then the method you described of sending the BTC out when the consumer asks from the consumer’s deal with can be positive.
In case you are constructing a platform the place the consumer exchanges BTC for items, companies, or different cash, after which makes withdrawals based mostly on their remaining steadiness, you might need to take into account a sizzling/chilly pockets system.
In such a system, when customers deposit cash, you present no assure that the identical cash can be used to course of their withdrawals. You both use all customers’ cash to course of every others withdrawals, otherwise you transfer them right into a handful of addresses, and course of all withdrawals from their.