Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: coinstrader777 on April 29, 2020, 10:47:17 AM



Title: Need idea for FASTER Balance & transaction update
Post by: coinstrader777 on April 29, 2020, 10:47:17 AM
Hello All,
  I was working on some crypto platform. Say the platform has 1000 users with unique & single wallet address for each user.
  Any time they can deposit to their address & start using the platform. I will do a cron API Call to blockcypher API &  pass each address to get their balance, & update to DB.  But it is fragile, as the user grows up, it difficult & slow to update balance & the cron eventually DIES.
  Is there any better way 2 update balance & transaction to the platform DB. 





Title: Re: Need idea for FASTER Balance & transaction update
Post by: mocacinno on April 29, 2020, 10:51:45 AM
Hello All,
  I was working on some crypto platform. Say the platform has 1000 users with unique & single wallet address for each user.
  Any time they can deposit to their address & start using the platform. I will do a cron API Call to blockcypher API &  pass each address to get their balance, & update to DB.  But it is fragile, as the user grows up, it difficult & slow to update balance & the cron eventually DIES.
  Is there any better way 2 update balance & transaction to the platform DB.  





If you're planning to have more than a handfull of active users, i'd defenately start by running your own bitcoind instead of using blockcypher's api.

When configuring the bitcoin daemon, use notifyers as a hook to your update script, that way your database will stay up-to-date.

I'd probably use a combination of -walletnotify and -blocknotify, and maybe poll the mempool from within the user's account overview page for incoming, unconfirmed transactions.
Make sure you either have a watch-only wallet, or make sure your hotwallet is properly locked.


Title: Re: Need idea for FASTER Balance & transaction update
Post by: coinstrader777 on April 29, 2020, 01:48:09 PM
Hello All,
  I was working on some crypto platform. Say the platform has 1000 users with unique & single wallet address for each user.
  Any time they can deposit to their address & start using the platform. I will do a cron API Call to blockcypher API &  pass each address to get their balance, & update to DB.  But it is fragile, as the user grows up, it difficult & slow to update balance & the cron eventually DIES.
  Is there any better way 2 update balance & transaction to the platform DB.  


If you're planning to have more than a handfull of active users, i'd defenately start by running your own bitcoind instead of using blockcypher's api.

When configuring the bitcoin daemon, use notifyers as a hook to your update script, that way your database will stay up-to-date.

I'd probably use a combination of -walletnotify and -blocknotify, and maybe poll the mempool from within the user's account overview page for incoming, unconfirmed transactions.
Make sure you either have a watch-only wallet, or make sure your hotwallet is properly locked.

Hi.,
 I was using bitcoind with getbalance(x) method. which was ridiculous. but as per your suggestion -walletnotify will return only wallet balance i think. i need for individual address. I will definitely do check out this stuff & back.. 
Thanks a lot... :)
 


Title: Re: Need idea for FASTER Balance & transaction update
Post by: mocacinno on April 29, 2020, 01:54:03 PM
--snip--

Hi.,
 I was using bitcoind with getbalance(x) method. which was ridiculous. but as per your suggestion -walletnotify will return only wallet balance i think. i need for individual address. I will definitely do check out this stuff & back..  
Thanks a lot... :)
  

Yeah, if you wanted the balance of an address, the getreceivedbyaddress or listreceivedbyaddress calls would have been a logical choice (you'd still need some extra calls to find/query the funding transactions tough). listtransactions would also be fitting your usecase.  If you're looking for "fresh" deposits, you could also use listunspent (altough as soon as you spend those unspent outputs, they'll no longer be listed, so it might not be a good idear to use this call).

You'll need a decent script to keep track of which transactions were already credited to a user's account and which ones need to be credited tough...

getbalance does not give you any details, so if you're tracking deposits from multiple users, this call does not suffice


Title: Re: Need idea for FASTER Balance & transaction update
Post by: cryptoworld99 on May 04, 2020, 01:51:25 AM
Hi,


Depending on your programming language, you can log each address generated into your database then

bitcoin-cli listunspent 0 99999 "address" - this should return the address balance.

example: 0.0384758


Hope this helps :)



Title: Re: Need idea for FASTER Balance & transaction update
Post by: cfbtcman on June 27, 2020, 02:29:13 AM
Hello All,
  I was working on some crypto platform. Say the platform has 1000 users with unique & single wallet address for each user.
  Any time they can deposit to their address & start using the platform. I will do a cron API Call to blockcypher API &  pass each address to get their balance, & update to DB.  But it is fragile, as the user grows up, it difficult & slow to update balance & the cron eventually DIES.
  Is there any better way 2 update balance & transaction to the platform DB.  





If you're planning to have more than a handfull of active users, i'd defenately start by running your own bitcoind instead of using blockcypher's api.

When configuring the bitcoin daemon, use notifyers as a hook to your update script, that way your database will stay up-to-date.

I'd probably use a combination of -walletnotify and -blocknotify, and maybe poll the mempool from within the user's account overview page for incoming, unconfirmed transactions.
Make sure you either have a watch-only wallet, or make sure your hotwallet is properly locked.

Im doing something like that and im insisting in blockcypher API but im having a lot of problems discovering syntax of the commands, i cant found it in Blockcypher website and i start to think maybe some optiions id like to use are not possible or im making mistakes.

Someone have the curl syntax to send from one address to one wallet?

I see this example:

{inputs:[{"wallet_name":"alice", "wallet_token":"YOURTOKEN"}], value: 5000000}

But this is example to use as inputs and id like to use a wallet for outputs, i tried a lot of combinations without success, someone can help?


Title: Re: Need idea for FASTER Balance & transaction update
Post by: slancer on June 28, 2020, 06:35:19 AM
Hello All,
  I was working on some crypto platform. Say the platform has 1000 users with unique & single wallet address for each user.
  Any time they can deposit to their address & start using the platform. I will do a cron API Call to blockcypher API &  pass each address to get their balance, & update to DB.  But it is fragile, as the user grows up, it difficult & slow to update balance & the cron eventually DIES.
  Is there any better way 2 update balance & transaction to the platform DB. 
we did this method in our site: instead of using unique address for each user, generate addresses for each deposit and tell users to send payment only one time to each address and change address after a successful payment. this way you do not need to check balance of all addresses every time. you just check one when they deposit and then show summary of all addresses balance from db.


Title: Re: Need idea for FASTER Balance & transaction update
Post by: ranochigo on June 28, 2020, 07:08:01 AM
Someone have the curl syntax to send from one address to one wallet?

I see this example:

{inputs:[{"wallet_name":"alice", "wallet_token":"YOURTOKEN"}], value: 5000000}

But this is example to use as inputs and id like to use a wallet for outputs, i tried a lot of combinations without success, someone can help?
Hmm, CMMIW but I don't think you can send the coins to a specific wallet instead of an address. Wallet tokens are not meant to be exposed and they don't have off-chain transactions this could easily expose the keys that is contained within the wallet.

we did this method in our site: instead of using unique address for each user, generate addresses for each deposit and tell users to send payment only one time to each address and change address after a successful payment. this way you do not need to check balance of all addresses every time. you just check one when they deposit and then show summary of all addresses balance from db.
Most people won't read what you put on the site and just assume that the addresses are reusable. You'll have a bigger headache trying to transfer out the funds that were accidentally sent to old addresses than to just monitor all the addresses that was generated in the first place.