I want to create an address in a wallet with bitcoin-cli, the command for this will look like this for the loaded wallet bitcoin-cli getnewaddress some_users
and with Deno I can just do
import { createRemote } from "https://deno.land/x/gentleRpc/rpcClient.ts";
let Node = new URL("http://127.0.0.1:8332");
Node.port = "8332";
Node.username = "some_user";
Node.password = "some_password";
const remote = createRemote(Node);
const address = remote.getnewaddress(addressLabel);
I would love to know how to use deno rpc for cases where I need to specify the -rpcwallet
flag, like this bitcoin-cli -rpcwallet=some_unique_wallet getnewaddress some_users
So after reading the doc further, I realised I can do this by passing the wallet name to the url like this http://127.0.0.1:8332/wallet/${walletName}
or just this http://127.0.0.1:8332/wallet/
for the default wallet.
So the code will look like this,
createConnection(walletName?: string) {
const uri = !!walletName ?
'http://127.0.0.1:8332/wallet/${walletName}' :
'http://127.0.0.1:8332/wallet/';
let Node = new URL(uri);
Node.port = "8332";
Node.username = "some_user";
Node.password = "some_password";
return createRemote(Node);
}