[英]How to use bitcoin -rpcwallet flag in deno RPC
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我想用 bitcoin-cli 在钱包中创建一个地址,对于加载的钱包
bitcoin-cli getnewaddress some_users
,这个命令看起来像这样,而使用 Deno 我可以做到
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
我很想知道如何在需要指定
-rpcwallet
标志的情况下使用 deno rpc,例如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 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/
用于默认钱包。
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);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.