PHP code example of tmwclaxton / laravel-bitcoin-module
1. Go to this page and download the library: Download tmwclaxton/laravel-bitcoin-module library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tmwclaxton / laravel-bitcoin-module example snippets
$name = 'my-wallet';
$password = 'password for encrypt wallet files';
$title = 'My First Wallet';
$node = Bitcoin::createNode('localhost', 'LocalHost', '127.0.0.1');
$wallet = Bitcoin::createWallet($node, $name, $password, $title);
$name = 'my-wallet';
$password = 'password for encrypt wallet files';
$descriptions = json_decode('DESCRIPTORS JSON', true);
$title = 'My First Wallet';
$node = Bitcoin::createNode('localhost', 'LocalHost', '127.0.0.1');
$wallet = Bitcoin::importWallet($node, $name, $descriptions, $password, $title);
$wallet = BitcoinWallet::firstOrFail();
$title = 'My address title';
$address = Bitcoin::createAddress($wallet, AddressType::BECH32, $title);
$address = '....';
$node = BitcoinNode::firstOrFail();
$addressType = Bitcoin::validateAddress($node, $address);
if( $addressType === null ) {
die('Address is not valid!');
}
var_dump($addressType); // Enum value of AddressType
$wallet = BitcoinWallet::firstOrFail();
$address = 'to_address';
$txid = Bitcoin::sendAll($wallet, $address);
echo 'TXID: '.$txid;
$wallet = BitcoinWallet::firstOrFail();
$address = 'to_address';
$amount = 0.001;
$txid = Bitcoin::send($wallet, $address, $amount);
echo 'TXID: '.$txid;
'providers' => ServiceProvider::defaultProviders()->merge([
...,
\Mollsoft\LaravelBitcoinModule\BitcoinServiceProvider::class,
])->toArray(),
'aliases' => Facade::defaultAliases()->merge([
...,
'Bitcoin' => \Mollsoft\LaravelBitcoinModule\Facades\Bitcoin::class,
])->toArray(),
'webhook_handler' => \Mollsoft\LaravelBitcoinModule\WebhookHandlers\EmptyWebhookHandler::class,
class EmptyWebhookHandler implements WebhookHandlerInterface
{
public function handle(BitcoinWallet $wallet, BitcoinAddress $address, BitcoinDeposit $transaction): void
{
Log::error('Bitcoin Wallet '.$wallet->name.' new transaction '.$transaction->txid.' for address '.$address->address);
}
}
bash
php artisan bitcoin:install
bash
php artisan migrate
bash
> php artisan bitcoin:sync
bash
> php artisan bitcoin:sync-wallet {wallet_id}