0

I have Bitcoin Core on Debian

Bitcoin Core

Need to create new receiving address with PHP.

As you see at screenshot, I've try to create new address from terminal, but that does not added at Bitcoin Core Receiving Address List, address created but, it's address list empty again.

Need that way which can give me new address and also it inserted in "Requested payments history".

Is it possible with PHP? If yes please explain me how it is possible. Please do not send me only links: EasyBitcoin, Bit-Wasp, etc.

Is it possible with this "denpamusic/php-bitcoinrpc" and if yes, please help to to understand how it is possible.

1

Need that way which can give me new address and also it inserted in "Requested payments history

New address created with getnewaddress RPC command will be visible in 'receiving addresses'. I have created 2 addresses from CLI with getnewaddress.

receiving-addresses

Address created using 'Create new receiving address' button can have more information associated with it (date, message, amount etc.) which is saved in 'Requested payments history'. bcrt1qe4ryqy8lv59na0wkm6y96p8tu9njjlkme32szz in 'receiving addresses' was created using this option.

payment-history

Is it possible with PHP?

Yes you can create new address with PHP:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'http://localhost:18333/wallet/P1',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{"jsonrpc": "1.0", "id": "curltest", "method": "getnewaddress", "params": []}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Basic dXNlcjpwYXNz',
    'Content-Type: text/plain'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

RPC credentials used in above code:

regtest.rpcport=18333
rpcuser=user
rpcpassword=pass

4
  • Thank you!!! This is what I want. I appreciate that.
    – Giorgi
    Aug 15 at 20:35
  • One question please, how do you get Authorization Basic? I mean "dXNlcjpwYXNz"
    – Giorgi
    Aug 15 at 20:37
  • 1
    $rpc_credentials = 'user:pass'; echo base64_encode($rpc_credentials);
    – Prayank
    Aug 16 at 0:31
  • Thank you @Prayank
    – Giorgi
    Aug 16 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.