Author

Topic: Electrum daemon/console: Get address from path (or private key) (Read 110 times)

legendary
Activity: 2268
Merit: 18587
Is this something I run in a Python console?
That's correct. I know this command works in the GUI console - I've not tested it personally in python (and I'm not at a machine in which I could test it personally for the time being), but I see no reason it wouldn't behave in the same way.

On a related note, now I have a different problem, that's how do I specify the "wallet_path" (or "electrum_path" and other config_options arguments through a CURL request? On the command line I could just do -w /path and it specifies the wallet path. But I'm not quite sure how I am supposed to specify this in this (example) request:
I'm not 100% sure about this, but try the following:

Code:
curl --data-binary '{"jsonrpc":"2.0","id":"curltext","method":"getbalance","params":{"config_options":{"subcommand":"load_wallet", "wallet_path":"/path/to/wallet", "password":"pass"}}}' http://username:[email protected]:7777
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
Code:
bitcoin.address_from_private_key("yourprivkeyhere")

This should do what you are looking for. You can prefix your private key with the usual Electrum prefixes (p2pkh:, p2wpkh-p2sh:, p2wpkh:) to generate a specific address type if needed. Private keys should be in WIF.

Is this something I run in a Python console? I'm building something with it using another language, where Python will not be available so I would like to at least be able to call this over CURL. (Maybe a mini-server that just runs this statement will do?)

Maybe I can just clone the master branch and add an Electrum command that runs this myself? (And maybe even merge it later). Seems like the most logical option right now.


On a related note, now I have a different problem, that's how do I specify the "wallet_path" (or "electrum_path" and other config_options arguments through a CURL request? On the command line I could just do -w /path and it specifies the wallet path. But I'm not quite sure how I am supposed to specify this in this (example) request:

Code:
# inside "params" maybe? But it's an empty list.
curl --data-binary '{"jsonrpc":"2.0","id":"curltext","method":"getbalance","params":[]}' http://username:[email protected]:7777

# and this one is with maps/objects/dicts (you get the idea)

curl --data-binary '{"jsonrpc":"2.0","id":"curltext","method":"listaddresses","params":{"funded":true}}' http://username:[email protected]:7777
legendary
Activity: 2268
Merit: 18587
Code:
bitcoin.address_from_private_key("yourprivkeyhere")

This should do what you are looking for. You can prefix your private key with the usual Electrum prefixes (p2pkh:, p2wpkh-p2sh:, p2wpkh:) to generate a specific address type if needed. Private keys should be in WIF.
legendary
Activity: 1568
Merit: 6660
bitcoincleanup.com / bitmixlist.org
Greetings fellow bitcoiners.

I need a way to query the Electrum daemon to return the address corresponding to a path, or a private key (because I can already obtain the private key corresponding to the path). Preferably I would like this to be done by an Electrum command so I can just make a single RPC call. But I didn't find any commands that perform this functionality.

This is all being done programmatically on a headless server so using the GUI wallet is not an option.
Jump to: