簡體   English   中英

如何在 deno RPC 中使用比特幣 -rpcwallet 標志

[英]How to use bitcoin -rpcwallet flag in deno RPC

我想用 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);

我很想知道如何在需要指定-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/用於默認錢包。

所以代碼看起來像這樣,

    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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM