hexim/zcash-bundle

Symfony ZCash RPC 扩展包

安装: 24

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

类型:symfony-bundle

0.0.3 2017-06-04 16:52 UTC

This package is not auto-updated.

Last update: 2024-09-13 23:54:19 UTC


README

注意:该扩展包与 Symfony 2.0 及以上版本兼容。

  1. 首先将此扩展包下载到您的项目中。推荐使用 Composer 包管理器

    $ composer require hexim/zcash-bundle
  2. 将此扩展包添加到您的应用程序内核

    // app/AppKernel.php
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Hexim\HeximZcashBundle\HeximZcashBundle(),
            // ...
        );
    }
  3. 在配置中配置此扩展包

    # 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

使用方法

在您的应用程序控制器方法中

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(),
                ]);
            }
        }

        ...
}