gmynis (OP)
Newbie
Offline
Activity: 3
Merit: 1
|
 |
March 25, 2025, 02:30:30 PM |
|
<?php $rpcuser = '...'; $rpcpassword = '...'; $rpchost = "127.0.0.1"; $rpcport = "7777";
$request_load_wallet = json_encode([ 'jsonrpc' => '2.0', 'id' => 1, 'method' => 'load_wallet', 'params' => [ "wallet_path" => "...", "password" => "..." ] ]);
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://$rpcuser:$rpcpassword@$rpchost:$rpcport"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $request_load_wallet); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response_load_wallet = curl_exec($ch); curl_close($ch);
RETURN: Load Wallet Response: {"id": 1, "jsonrpc": "2.0", "result": null}
after, $request_list_wallets = json_encode([ 'jsonrpc' => '2.0', 'id' => 2, 'method' => 'list_wallets' ]);
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://$rpcuser:$rpcpassword@$rpchost:$rpcport"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $request_list_wallets); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response_list_wallets = curl_exec($ch); curl_close($ch);
echo '<pre>'; echo "List Wallets Response: "; echo $response_list_wallets; echo '</pre>';
RETURN: List Wallets Response: {"id": 2, "jsonrpc": "2.0", "result": [{"path": "c:\\users\\user\\appdata\\roaming\\electrum\\wallets\\wallet", "synchronized": true, "unlocked": false}]}
after,
$request_unlock = json_encode([ 'jsonrpc' => '2.0', 'id' => 3, 'method' => 'password', 'params' => ["..."] ]);
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://$rpcuser:$rpcpassword@$rpchost:$rpcport"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $request_unlock); curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
$response_unlock = curl_exec($ch); curl_close($ch);
RETURN: Unlock Response: {"id": 3, "jsonrpc": "2.0", "error": {"code": 1, "message": "Password required. Unlock the wallet, or add a --password option to your command"}}
In the latter case, I put in CMD: ELECTRUM-4.5.8-Wallet "C: \ Ussers \ Gugam \ Appdata \ Roaming \ Electrum \ Wallets \wallet" And then I filled the password on the graphic interface of the Electrum. Note: With the daemon on I put the password.
|