electrum icon indicating copy to clipboard operation
electrum copied to clipboard

How to pass the `password` argument to password set wallet through JSONRPC API?

Open Jinsung-L opened this issue 9 years ago • 7 comments

I created password set wallet. Started electrum deamon with command electrum daemon start Then loaded the wallet electrum daemon load_wallet It had been successfully loaded.

I want to use payto command. So I tested it out on console. electrum payto ADDRESS AMOUNT --fee FEE --password PASSWORD And it worked. Returning the result of

{
    "complete": true, 
    "final": true, 
    "hex": "HEX...."
}

But when I try this though JSONRPC...

requests.post("http://localhost:7777", json={
    "id": "asdf",
    "method": "payto",
    "params": {
        "amount": 0.01,
        "destination": "ADDRESS",
        "tx_fee": 0.01,
        "password": "PASSWORD"
    }
})

I get this

{"error": {"message": "Server error:   File \\"/Users/jinsung/Desktop/AlecPay/electrum/lib/python2.7/site-packages/electrum/commands.py\\", line 83, in func_wrapper | TypeError: payto() got an unexpected keyword argument \'password\'", "code": -32603}, "jsonrpc": "2.0", "id": "asdf"}

And if I send the request without the password argument, I get this

{"error": {"message": "Server error:   File \\"/Users/jinsung/Desktop/AlecPay/electrum/lib/python2.7/site-packages/electrum/bitcoin.py\\", line 769, in deserialize_xkey | TypeError: object of type \'NoneType\' has no len()", "code": -32603}, "jsonrpc": "2.0", "id": "asdf"}

Question: Can you use password set wallet on electrum deamon through json-rpc? If so, how?

FYI, I'm using the daemon with -P --testnet options. But I think it doesn't matter.

Jinsung-L avatar May 10 '17 14:05 Jinsung-L

that is not possible with the current design. I'll try to fix that before the next release.

ecdsa avatar May 14 '17 07:05 ecdsa

@ecdsa : any ETA on next release ?

bsbits avatar May 29 '17 18:05 bsbits

The same problem

patrikden avatar Jun 22 '17 08:06 patrikden

I really would like to be able to create a wallet or restore a wallet from the command line by also passing a password (or blank password) through to electrum

LRonHubs avatar Nov 02 '17 00:11 LRonHubs

Hello! I try send bitcoin from JSONRPC API:

curl --data-binary '{"jsonrpc":"2.0","id":"curltext","method":"payto", "params":["mhurdcChDVEd6PzN4uSqXBUiH5Tinbdi2j", "0.0001"]}' http://user:[email protected]:7777

But, I get error:

`{"result": {"error": "Password required"}, "id": "curltext", "jsonrpc": "2.0"}`

Yes, my wallet use password. I enter it at start:

(core) antsa0110@pc:~/Documents/projects/test/core$ electrum daemon start --testnet
starting daemon (PID 12375)
(core) antsa0110@pc:~/Documents/projects/test/core$ electrum daemon load_wallet -w /home/antsa0110/.electrum/testnet/wallets/testnet_electrum_wallet --testnet
Password:
true
(core) antsa0110@pc:~/Documents/projects/test/core$ electrum daemon status --testnet
{
    "auto_connect": true,
    "blockchain_height": 1782018,
    "connected": true,
    "current_wallet": "/home/antsa0110/.electrum/testnet/wallets/testnet_electrum_wallet",
    "fee_per_kb": 1000,
    "path": "/home/antsa0110/.electrum/testnet",
    "server": "testnet.qtornado.com",
    "server_height": 1782018,
    "spv_nodes": 5,
    "version": "3.3.8",
    "wallets": {
        "/home/antsa0110/.electrum/testnet/wallets/testnet_electrum_wallet": true
    }
}

How to pass the password argument to password set wallet through JSONRPC API?

antsa0110 avatar Aug 01 '20 01:08 antsa0110

I found solution:

curl --data-binary '{"jsonrpc":"2.0","id":"curltext","method":"payto", "params": {'amount': '0.0001', 'destination': 'mx5yUVPjJuWWnKYBLLftFHv8X6JB6XhnmY', 'password': '123'}}' http://user:[email protected]:7777

params is dict, not list...

antsa0110 avatar Aug 19 '20 10:08 antsa0110

@antsa0110 related: https://github.com/spesmilo/electrum/issues/6221

SomberNight avatar Aug 27 '20 16:08 SomberNight