webworker01 / komodophp
Library to interact with Komodo-based blockchains
v0.1.7
2022-06-05 12:26 UTC
Requires
- php: >=7.0.0
- bitwasp/bitcoin: ^1.0
- clue/socket-raw: ^1.3
- guzzlehttp/guzzle: ^6.3
This package is auto-updated.
Last update: 2024-11-20 01:05:01 UTC
README
A library for manipulating Komodo addresses and keys and interacting with Electrum servers
Usage
composer require webworker01/komodophp
Working with Addressess and Keys
For manipulating Komodo addresses and keys please see docs in https://github.com/Bit-Wasp/bitcoin-php
You will pass in the Komodo object
use webworker01\Komodo\Komodo; use BitWasp\Bitcoin\Address\AddressCreator; $komodo = new Komodo(); $addrCreator = new AddressCreator(); $addressInput = 'RWEBo1Yp4uGkeXPi1ZGQARfLPkGmoW1MwY'; try { $address = $addrCreator->fromString($addressInput, $komodo); } catch ( \BitWasp\Bitcoin\Exceptions\UnrecognizedAddressException $e) { $errormessage = 'The address you entered is not valid, please try again'; echo $errormessage; }
Working with ElectrumX
use webworker01\Komodo\Electrum; $electrum = new Electrum(); $electrum->connect($electrumhost, $electrumport); $unspent = $electrum->blockchainAddressListunspent($address);
Working with CLI
Simple CLI/RPC interface to a locally running full node.
This class is not aware of commands in komodod, so any data validation is handled by the daemon.
use webworker01\Komodo\Cli; $cli = new Cli(); $notarizations = $cli->run('getaddresstxids', [['addresses' => [$notarizationAddress], 'start' => $currentblock, 'end' => $currentendblock]] ); foreach ($notarizations as $tx) { $rawtx = $cli->run('getrawtransaction', [$tx, 1]); }
Opreturn
Decode opreturns to search for notarization data
use webworker01\Komodo\Opreturn; $opreturn = new Opreturn(); $notarisationdata = $opreturn->decode($rawtx->vout[1]->scriptPubKey->hex);