hexim/zcash-bundle

Symfony ZCash RPC Bundle

Installs: 24

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:symfony-bundle

0.0.3 2017-06-04 16:52 UTC

This package is not auto-updated.

Last update: 2024-05-10 22:22:26 UTC


README

NOTE: The bundle is compatible with Symfony 2.0 upwards.

  1. Download this bundle to your project first. The preferred way to do it is to use Composer package manager:

    $ composer require hexim/zcash-bundle
  2. Add this bundle to your application's kernel:

    // app/AppKernel.php
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Hexim\HeximZcashBundle\HeximZcashBundle(),
            // ...
        );
    }
  3. Configure the bundle in your config:

    # app/config/config.yml
    hexim_zcash:
        rpc_password: "%zcash_rpc_password%"
        rpc_user: "%zcash_rpc_user%"
        rpc_port: "%zcash_rpc_port%"
    # app/config/parameters.yml
    parameters:
        zcash_rpc_password: password
        zcash_rpc_user: user
        zcash_rpc_port: 8282

Usage

In your application controller methods:

public function yourAction(Request $request)
{
        $wallet = $this->get('hexim_zcash.wallet');
        if (!$walletInfo = $wallet->getWalletInfo()) {
            throw new \Exception('Error: ' . $wallet->getError());
        }

        ...
}
public function yourAction(Request $request)
{
        $wallet = $this->get('hexim_zcash.wallet');
        $walletInfo = $wallet->getWalletInfo();
        $transactions = $wallet->listTransactions($walletInfo['result']['txcount']);
        
        ...
}
public function yourAction(Request $request)
{
        $myAddress = "t1ededed...";

        $zcashUtil = $this->get('hexim_zcash.util');
        if ($data = $zcashUtil->validateAddress($myAddress) {
            if (!$data['result']['isvalid']) {
                $this->addFlash('error', ' Sorry but this tAddress is not valid zcash address.');
                return $this->render('any.html.twig', [
                    'anyForm' => $form->createView(),
                ]);
            }
        }

        ...
}