This is a very complicated question. bcoin already has a built-in wallet that can do all of these operations for you. There is a well-documented RESTful HTTP API you can read through here: http://bcoin.io/api-docs/ to get an idea of what’s available. You can also write your own wallet application using the bcoin object classes directly.
Very broadly however, here’s some tips that might interest you:
-
Enable Address indexing. This is a feature that is not currently available in bitcoind yet (so far I think only indexing by transaction ID is supported). This is switched on with
indexAddress: true
inbcoin.conf
or--index-address
on the command line. The address index will enable you to request the transactions associated with a specific address: http://bcoin.io/api-docs/#get-tx-by-address -
You will want to process that transaction data and maybe cross-check the UTXO set (so you know what has been spent already) with the API call http://bcoin.io/api-docs/#get-coin-by-outpoint
-
Check out the
MTX
andCoin
objects to construct a transaction from the UTXO you recover. We have several guides on transaction handling, maybe read through this: http://bcoin.io/guides/working-with-txs.html -
Signing transactions with private keys: I’m not sure how your application will work but it sounds like the users will have to sign the TX themselves?
I recomend you read through the bcoin API docs and the guides (and of course, the codebase!). And just focus on the default wallet process for coin selection, transaction composition, signing, and private key handling.