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,170 points
114 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,550 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
85 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,350 points
83 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,170 points
56 views
0 votes
1 answer
0 votes
1 answer

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

yes all are over TCP/IP connections secured by TLS encryption in hashgraph architecture-hashgraph, ...READ MORE

answered Aug 6, 2018 in Blockchain by ariaholic
• 7,340 points
90 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
169 views
0 votes
1 answer
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,550 points
166 views
0 votes
1 answer