psychiccat/monero-php
Composer 安装命令:
composer require psychiccat/monero-php
包简介
A PHP library for the Monero simplewallet JSON-RPC interface.
README 文档
README
A PHP library for the Monero simplewallet JSON-RPC interface.
For more information about Monero, please visit https://getmonero.org/home.
If you found this useful, feel free to donate!
XMR: 47Vmj6BXSRPax69cVdqVP5APVLkcxxjjXdcP9fJWZdNc5mEpn3fXQY1CFmJDvyUXzj2Fy9XafvUgMbW91ZoqwqmQ6RjbVtp
Installation
Install the library using Composer.
composer require psychiccat/monero-php
Create an Instance of the Wallet
require 'vendor/autoload.php'; use Monero\Wallet; $wallet = new Monero\Wallet();
Default hostname and port connects to http://127.0.0.1:18082.
To connect to an external IP or different port:
$hostname = YOUR_WALLET_IP; $port = YOUR_WALLET_PORT; $wallet = new Monero\Wallet($hostname, $port);
Wallet Methods
getBalance
$balance = $wallet->getBalance();
Responds with the current balance and unlocked (spendable) balance of the wallet in atomic units. Divide by 1e12 to convert.
Example response:
{ balance: 3611980142579999, unlocked_balance: 3611980142579999 }
getAddress
$address = $wallet->getAddress();
Responds with the Monero address of the wallet.
Example response:
{ address: '47Vmj6BXSRPax69cVdqVP5APVLkcxxjjXdcP9fJWZdNc5mEpn3fXQY1CFmJDvyUXzj2Fy9XafvUgMbW91ZoqwqmQ6RjbVtp' }
transfer
$tx_hash = $wallet->transfer($options);
Transfers Monero to a single recipient OR a group of recipients in a single transaction. Responds with the transaction hash of the payment.
Parameters:
options- an array containingdestinations(object OR array of objects),mixin(int),unlock_time(int),payment_id(string). Onlydestinationsis required. Default mixin value is 4.
$options = [ 'destinations' => (object) [ 'amount' => '1', 'address' => '47Vmj6BXSRPax69cVdqVP5APVLkcxxjjXdcP9fJWZdNc5mEpn3fXQY1CFmJDvyUXzj2Fy9XafvUgMbW91ZoqwqmQ6RjbVtp' ] ];
Example response:
{ tx_hash: '<b9272a68b0f242769baa1ac2f723b826a7efdc5ba0c71a2feff4f292967936d8>', tx_key: '' }
transferSplit
$tx_hash = $wallet->transferSplit($options);
Same as transfer(), but can split into more than one transaction if necessary. Responds with a list of transaction hashes.
Additional property available for the options array:
new_algorithm-trueto use the new transaction construction algorithm. defaults tofalse. (boolean)
Example response:
{ tx_hash_list: [ '<f17fb226ebfdf784a0f5814e1c5bb78c19ea26930a0d706c9dc1085a250ceb37>' ] }
sweepDust
$tx_hashes = $wallet->sweepDust();
Sends all dust outputs back to the wallet, to make funds easier to spend and mix. Responds with a list of the corresponding transaction hashes.
Example response:
{ tx_hash_list: [ '<75c666fc96120a643321a5e76c0376b40761582ee40cc4917e8d1379a2c8ad9f>' ] }
getPayments
$payments = $wallet->getPayments($payment_id);
Returns a list of incoming payments using a given payment ID.
Parameters:
paymentID- the payment ID to scan wallet for included transactions (string)
getBulkPayments
$payments = $wallet->getBulkPayments($payment_id, $height);
Returns a list of incoming payments using a single payment ID or a list of payment IDs from a given height.
Parameters:
paymentIDs- the payment ID or list of IDs to scan wallet for (array)minHeight- the minimum block height to begin scanning from (example: 800000) (int)
incomingTransfers
$transfers = $wallet->incomingTransfers($type);
Returns a list of incoming transfers to the wallet.
Parameters:
type- accepts"all": all the transfers,"available": only transfers that are not yet spent, or"unavailable": only transfers which have been spent (string)
queryKey
$key = $wallet->queryKey($type);
Returns the wallet's spend key (mnemonic seed) or view private key.
Parameters:
type- accepts"mnemonic": the mnemonic seed for restoring the wallet, or"view_key": the wallet's view key (string)
integratedAddress
$integratedAddress = $wallet->integratedAddress($payment_id);
Make and return a new integrated address from your wallet address and a given payment ID, or generate a random payment ID if none is given.
Parameters:
payment_id- a 64 character hexadecimal string. If not provided, a random payment ID is automatically generated. (string, optional)
Example response:
{ integrated_address: '4HCSju123guax69cVdqVP5APVLkcxxjjXdcP9fJWZdNc5mEpn3fXQY1CFmJDvyUXzj2Fy9XafvUgMbW91ZoqwqmQ96NYBVqEd6JAu9j3gk' }
splitIntegrated
$splitIntegrated = $wallet->splitIntegrated($integrated_address);
Returns the standard address and payment ID corresponding for a given integrated address.
Parameters:
integrated_address- an Monero integrated address (string)
Example response:
{ payment_id: '<61eec5ffd3b9cb57>',
standard_address: '47Vmj6BXSRPax69cVdqVP5APVLkcxxjjXdcP9fJWZdNc5mEpn3fXQY1CFmJDvyUXzj2Fy9XafvUgMbW91ZoqwqmQ6RjbVtp' }
getHeight
Usage:
$height = $wallet->getHeight();
Returns the current block height of the daemon.
Example response:
{ height: 874458 }
stopWallet
$wallet->stopWallet();
Cleanly shuts down the current simplewallet process.
psychiccat/monero-php 适用场景与选型建议
psychiccat/monero-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.45k 次下载、GitHub Stars 达 29, 最近一次更新时间为 2016 年 03 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cryptocurrency」 「Monero」 「Poloniex」 「Shapeshift」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 psychiccat/monero-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 psychiccat/monero-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 psychiccat/monero-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This is a virtual currency SDK that brings together multiple exchanges
Poloniex API Like the official document interface, Support for arbitrary extension.
PHP wrapper for the Poloniex API.
Cryptonator Merchant API
A modern fully strong-typed library for using the Monero daemon rpc and wallet rpc APIs
This bundle provides Coinhive services. It does'nt depend of coinhive.com
统计信息
- 总下载量: 8.45k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 31
- 点击次数: 9
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-03-10