How to generate new address for blockchain wallet

0 votes

I am trying to generate new address for each wallet using blockchain API using the following code:

<?php

$guid = "7c74bb77-4e25-4eea-a9d3-df1cf6a9d218";

$main_password = "******";

$label = "firsttym";

$json_url = "http://localhost:3000/merchant/$guid/new_address?

password = $main_password & label = $label";

$json_data = file_get_contents($json_url);

$json_feed = json_decode($json_data ,true);

$message = $json_feed->message;

$txid = $json_feed->tx_hash;

?>

I get the following error:

Warning: file_get_contents(localhost:3000/merchant/7c74bb77-4e25-4eea??-a9d3-df1cf6a9d218/…??) [function.file-get-contents]: failed to open stream:

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

in C:\wamp\www\block\first.php on line 8

Fatal error: Maximum execution time of 30 seconds exceeded in C:\wamp\www\block\first.php on line 8

How to solve this?

Jul 16, 2018 in Blockchain by slayer
• 29,370 points
3,277 views

1 answer to this question.

0 votes

You can use the following to generate wallet addresses. 
Start the blockchain before making the request using this code:

blockchain-wallet-service start --port 3000

then use the following code:

$url = "http://localhost:3000/merchant/$guid/new_address?password=$password&label=$label";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

   $data = json_decode(curl_exec($ch), TRUE);

   return $data;

answered Jul 16, 2018 by digger
• 26,740 points

Related Questions In Blockchain

0 votes
1 answer

How to create a new wallet on a blockchain?

Firstly, you need to have a clear ...READ MORE

answered Apr 4, 2018 in Blockchain by Christine
• 15,790 points
1,383 views
0 votes
0 answers

hd wallet bip44 in js - how to create an address for a chain other than bitcoin?

I have a small script basically taken ...READ MORE

Mar 2, 2022 in Blockchain by Aditya
• 7,680 points
990 views
0 votes
1 answer

How can I retrieve to and from address in transaction directly from blockchain?

The spending conditions, i.e., who is able ...READ MORE

answered Jul 11, 2018 in Blockchain by Shashank
• 10,400 points
1,309 views
0 votes
1 answer

How to check history of blockchain.info wallet?

In the link you mentioned(https://blockchain.info/q), there are ...READ MORE

answered Jul 23, 2018 in Blockchain by slayer
• 29,370 points
1,855 views
+1 vote
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,460 points
1,428 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,923 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,451 views
0 votes
1 answer

How to extract h160 address of bitcoin blockchain?

You can extract the data using the ...READ MORE

answered Jul 16, 2018 in Blockchain by digger
• 26,740 points
2,556 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP