123 - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of 123.php
- namespace App\Http\Controllers;
- use Illuminate\Http\Request;
- use BitWasp\Bitcoin\Key\Deterministic\HierarchicalKeyFactory;
- use BitWasp\Bitcoin\Network\NetworkFactory;
- use BitWasp\Bitcoin\Key\KeyToScript\Factory\P2pkhScriptDataFactory;
- use BitWasp\Bitcoin\Address\PayToPubKeyHashAddress;
- class BitcoinController extends Controller
- {
- public function generateAddress(Request $request)
- {
- $network = NetworkFactory::bitcoin();
- $seed = 'doctor bachelor pride believe script swarm shrug stereo grocery eternal control tattoo';
- $root = HierarchicalKeyFactory::fromEntropy($seed, null, $network);
- $child = $root->derivePath("m/44'/0'/0'/0/0");
- $scriptDataFactory = new P2pkhScriptDataFactory();
- $scriptData = $scriptDataFactory->convertKey($child->getPublicKey());
- $address = new PayToPubKeyHashAddress($scriptData->getScriptPubKey(), $network);
- return response()->json([
- 'address' => $address->getAddress()
- ]);
- }
- }