0

I'm writing a web application that will require subscription fees from users. I'd like to automate this process without relying heavily on 3rd party services (web-based wallets, etc).

Currently, this is how it is designed:

  • Web app connects to a websocket on the server using a JWT bearer token for authentication and requests an address.
  • The server calls the getnewaddress method to the RPC daemon and returns this address over the websocket
  • The wallet's pub (is priv necessary?) keys are stored in the webapp's database as well as the user that requested the address.
  • The websocket will provide periodic progress updates along with a refreshed JWT (tokens expire every 2 minutes) while waiting for the transaction. If the user disconnects, no harm done.

Once the transaction is completed, a curl command is triggered by walletnotify and submits this TXID to the web server, which ensures "confirmations" are > 0, and the "receive" address is used as the database query to determine which user added time to his/her subscription.

Questions:

  • Does getnewaddress generate a new wallet? Or am I free to receive as many as I'd like?
  • Running getbalance <account> shows the summation of all addresses listed in listaddressgroupings. Is this all usable from the same wallet?
  • How can I consolidate or remove addresses when they're no longer necessary? Do the BTC stay in the "account"?
  • 2
    Quick comment: generally it is not advisable to remove a bitcoin address/keypair from the wallet entirely (unless perhaps it is a BIP32 wallet and you have the seed and derivation saved). Keypairs are not very data intensive to store, the benefits of keeping them probably outweigh the risks of having someone reuse an old address, and then have the funds be unrecoverable because a keypair was deleted. – chytrik Mar 13 '18 at 23:52
1

getnewaddress will generate a new Bitcoin address for your existing wallet, Yes you can get as many as you like.

I would use getreceivedbyaddress which returns the total amount received by the specified address in transactions with the specified number of confirmations or listunspent to get all transactions for specific address with confirmations

AFAICT, You can't remove an address from your wallet using any RPC call, but by editing wallet.dat manually.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.