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.



Your result can be seen below.

Result of php executing





Full code of 123.php

  1. namespace App\Http\Controllers;
  2.  
  3.  
  4.  
  5. use Illuminate\Http\Request;
  6.  
  7. use BitWasp\Bitcoin\Key\Deterministic\HierarchicalKeyFactory;
  8.  
  9. use BitWasp\Bitcoin\Network\NetworkFactory;
  10.  
  11. use BitWasp\Bitcoin\Key\KeyToScript\Factory\P2pkhScriptDataFactory;
  12.  
  13. use BitWasp\Bitcoin\Address\PayToPubKeyHashAddress;
  14.  
  15.  
  16.  
  17. class BitcoinController extends Controller
  18.  
  19. {
  20.  
  21.     public function generateAddress(Request $request)
  22.  
  23.     {
  24.  
  25.         $network = NetworkFactory::bitcoin();
  26.  
  27.         $seed = 'doctor bachelor pride believe script swarm shrug stereo grocery eternal control tattoo';
  28.  
  29.  
  30.  
  31.         $root = HierarchicalKeyFactory::fromEntropy($seed, null, $network);
  32.  
  33.         $child = $root->derivePath("m/44'/0'/0'/0/0");
  34.  
  35.         $scriptDataFactory = new P2pkhScriptDataFactory();
  36.  
  37.         $scriptData = $scriptDataFactory->convertKey($child->getPublicKey());
  38.  
  39.         $address = new PayToPubKeyHashAddress($scriptData->getScriptPubKey(), $network);
  40.  
  41.  
  42.  
  43.         return response()->json([
  44.  
  45.             'address' => $address->getAddress()
  46.  
  47.         ]);
  48.  
  49.     }
  50.  
  51. }
File Description
  • 123
  • PHP Code
  • 28 Apr-2023
  • 1.06 Kb
You can Share it: