简体   繁体   中英

How to generate wallet and retrieve the bitcoin wallet using RPC

I want to understand how to create a wallet and what is the difference between wallet and addresses, and also how to get back the wallet, just created using RPC. So I'm using PHP and node js for implementation. PHP I'm using a laravel package denpamusic/laravel-bitcoinrpc and node js I am using request-promise and I have connected successfully.

const   USER = process.env.RPC_USER,
        PASS = process.env.RPC_PASSWORD,
        PORT = process.env.RPC_PORT,//8332
        HOST = process.env.RPC_HOST;//12.1.122.1

async getWalletInfo({req, response}){
    return await rp(requestOption(`{"jsonrpc":"1.0","id":"curltext","method":"getwalletinfo","params":[]}`))
  }
function requestOption(dataString) {
  return {
      url: `http://${USER}:${PASS}@${HOST}:${PORT}/`,
      method: "POST",
      headers: headers,
      body: dataString
  };
}

That is the node.js code and below for PHP

public function requestNewWallet($block, $wallet){
        switch ($block) {
            case 'bitcoin':
                return $this->bitcoind()->getwalletinfo();
            default:
                return null;
        }
}

it gives given the same error

Denpa\Bitcoin\Exceptions\BadRemoteCallException Wallet file not specified (must request wallet RPC through /wallet/<filename> uri-path)

So please how do fix this error it is the same on both language

Ok Found The Answer so I have to pass through the wallet for the PHP and for the node.js I have to go through the wallet/{name} endpoint so it looks it url: http://${USER}:${PASS}@${HOST}:${PORT}/wallet/{name} ,

Then PHP Code

public function requestNewWallet($block, $wallet){
        switch ($block) {
            case 'bitcoin':
                return $this->bitcoind()->wallet('{dirname}')->getwalletinfo();
            default:
                return null;
        }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM