-
Notifications
You must be signed in to change notification settings - Fork 13
/
payment_request_with_expiration_timestamp.php
30 lines (22 loc) · 1.21 KB
/
payment_request_with_expiration_timestamp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
declare(strict_types=1);
/*
* This file is part of the PHP Bitcoin BOLT11 package.
*
* (c) Jorijn Schrijvershof <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
use Jorijn\Bitcoin\Bolt11\Encoder\PaymentRequestDecoder;
use Jorijn\Bitcoin\Bolt11\Model\Tag;
use Jorijn\Bitcoin\Bolt11\Normalizer\PaymentRequestDenormalizer;
require dirname(__DIR__).DIRECTORY_SEPARATOR.'vendor'.DIRECTORY_SEPARATOR.'autoload.php';
$invoice = 'lnbc2500u1pvjluezpp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdq5xysxxatsyp3k7enxv4jsxqzpuaztrnwngzn3kdzw5hydlzf03qdgm2hdq27cqv3agm2awhz5se903vruatfhq77w3ls4evs3ch9zw97j25emudupq63nyw24cg27h2rspfj9srp';
$decoder = new PaymentRequestDecoder();
$denormalizer = new PaymentRequestDenormalizer();
$paymentRequest = $denormalizer->denormalize($decoder->decode($invoice));
echo 'satoshis: '.var_export($paymentRequest->getSatoshis(), true).PHP_EOL;
echo 'description: '.$paymentRequest->findTagByName(Tag::DESCRIPTION)->getData().PHP_EOL;
echo 'expiry: '.$paymentRequest->findTagByName(Tag::EXPIRE_TIME)->getData().PHP_EOL;
echo 'payment before: '.print_r($paymentRequest->getExpiryDateTime(), true).PHP_EOL;