Easy way for remote transactions and wallet operations?

Salvador

New member
I want to set up a server that will receive http requests (using a simple protocol I define) and perform some simple bitcoin related operations, including import of a HD wallet and pushing transactions.

I wonder what is a good way to do it. I will use an NGINX web server to receive the requests and process them with PHP (I'm also comfortable with python, just for background).

As for the operations themselves, I thought about the following options:
- Run a full bitcoin node on the server and send JSON-RPC requests to bitcoind
- Run a full node + an electrum server and send the requests to the electrum server (with electrum dameon)
- Send them to electrum daemon. No full node / electrum server.
- Don't run anything locally (except the web server) - use a third party API, such as of blockchain.com. Problem is I didn't see an api that allows import / restore of a HD wallet.

I assume there are other options I didn't think. I will appreciate your input on this.
 

Juan

Member
including import of a HD wallet
Both Bitcoin Core and Electrum don't support multiple wallet usage at same time, additionally AFAIK there's no option to import HD wallet (whether it's seed/xprv or mnemonic).

I only can suggest you look for another Bitcoin full node client which have multiple wallet/wallet service feature such as Bitcore and Bcoin.
Unfortunately, both of them use JavaScript, but IMO they should have API/JSON-RPC which can be called from your server.
 

Kaiden

Member
Electrum can restore a HD wallet but indeed it's tricky to handle multiple wallets at the same time there.
Yes, but what i meant is there's no Electrum command to import HD wallet. You don't plan to import it manually, do you?
Another way is do it with a python library. I see that https://github.com/primal100/pybitcointools
is archived and not maintained any longer. Any good alternatives?
I don't know if it's good or not, but i'd recommend https://github.com/ofek/bit.

I tried it once and like it since it's very easy to use even for geeks like me.
 

Uriah

New member
Electrum can restore a HD wallet but indeed it's tricky to handle multiple wallets at the same time there.
Yes, but what i meant is there's no Electrum command to import HD wallet. You don't plan to import it manually, do you?
The "restore" command works in the console, command line and through an RPC call. It takes a text that can have various formats including a mnemonic word list or a master private key.

See lines 151-166 in https://github.com/spesmilo/electrum/blob/master/electrum/commands.py

With Curl:
curl --data-binary '{"id":"curltext","method":"restore","params":{"text":"word1 word2 word3...""}}' http://user:p[email protected]:7777

As for working with multiple wallets, that's a bit hacky but I figured out switching between them can be done by using the "setconfig" command. For example:

curl --data-binary '{"id":"curltext","method":"setconfig","params":{"key":"wallet_path","value":"path/to/wallet1"}}' http://user:p[email protected]:7777

switches to wallet1 file. It's then possible to work with any number of wallet files without restarting the electrum daemon (as I previously thought will be necessary).

I wish they'd publish a full reference for the RPC API, it is tricky to figure out what goes where.
I don't know if it's good or not, but i'd recommend https://github.com/ofek/bit.
Thanks a lot, I'll check that one as well.
 

Dennis

New member
Yes, but what i meant is there's no Electrum command to import HD wallet. You don't plan to import it manually, do you?
The "restore" command works in the console, command line and through an RPC call. It takes a text that can have various formats including a mnemonic word list or a master private key.

See lines 151-166 in https://github.com/spesmilo/electrum/blob/master/electrum/commands.py

With Curl:
curl --data-binary '{"id":"curltext","method":"restore","params":{"text":"word1 word2 word3...""}}' http://user:p[email protected]:7777

As for working with multiple wallets, that's a bit hacky but I figured out switching between them can be done by using the "setconfig" command. For example:

curl --data-binary '{"id":"curltext","method":"setconfig","params":{"key":"wallet_path","value":"path/to/wallet1"}}' http://user:p[email protected]:7777

switches to wallet1 file. It's then possible to work with any number of wallet files without restarting the electrum daemon (as I previously thought will be necessary).

I wish they'd publish a full reference for the RPC API, it is tricky to figure out what goes where.
I didn't know that's possible. There aren't any clear documentation about electrum's command, expect inline help (electrum help <command>).
I don't know if it's good or not, but i'd recommend https://github.com/ofek/bit.
Thanks a lot, I'll check that one as well.
You're welcome
Smiley
 
Top