比特币 API 不依赖于正在运行的比特币守护进程?
我正在尝试建立一个以比特币为中心的网站,并且由于我的主机的限制,我需要能够执行以下操作,而无需在任何服务器上运行比特币守护程序:
- 创建一个新的比特币地址(<代码>getnewaddress($account))
- 在该地址接收硬币;确定收到的金额 (
getreceivedbyaccount($account, $minconf=1)
) - 将硬币发送到地址 (
sendfrom($fromaccount, $tobitcoinaddress, $amount, $minconf=1, $ comment="", $comment-to="")
)
这些都是现有 json-rpc php 客户端,但所有这些都依赖于服务器上正在运行的比特币守护进程。
我确实也阅读了“lazy api”的内容,但我宁愿不依赖其他服务来获取块数据或发送比特币。
tl;dr:我需要一个不需要运行守护进程的比特币 php api 版本,至少具有上述功能。
I'm trying to get a bitcoin-centric website going, and I need to be able to perform the following actions without having a bitcoin daemon running on any server due to limitations in place by my host:
- Create a new bitcoin address (
getnewaddress($account)
) - Receive coins at that address; determine how much was received (
getreceivedbyaccount($account, $minconf=1)
) - Send coins to an address (
sendfrom($fromaccount, $tobitcoinaddress, $amount, $minconf=1, $comment="", $comment-to="")
)
These are all functions that exist within the existing json-rpc php client, but all of which depend on a running bitcoin daemon on a server.
I did read through the "lazy api" stuff as well, but I would rather not depend on another service to get the block data or send the bitcoins.
tl;dr: I need a version of the bitcoin php api which does not need the daemon running, with at a bare minimum the functions described above.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
目前还没有这样的功能。我听说过将 bitcoind 移植到本机 PHP 或可以在浏览器中运行的 Java 小程序的说法,但是没有守护进程某处就没有比特币 - 尽管您可能可以使用以下命令来管理这些基本功能: MtGox 商家 API。
或者,如果您家里有足够可靠的设置,您可以将一个设备专用于bitcoind,并在路由器设置中转发适当的端口。您通常无法在住宅互联网上托管站点的唯一原因是 ISP 阻止了端口 80;他们不会阻止 8337(如果阻止的话,无论如何也是可以配置的)。 PHP API 应该能够通过网络连接到 bitcoind,就像在同一个盒子上一样。
At present, no such function exists. I've heard talk of bitcoind being ported to native PHP or a Java applet that can run in the browser, but there is no bitcoin without a daemon somewhere - although you could probably manage those basic functions with the MtGox Merchant API.
Alternately, if you have a reliable enough setup at home you could dedicate a rig to bitcoind and forward the appropriate port in your router settings. The only reason you can't usually host sites on your residential internet is that ISPs block port 80; they don't block 8337 (and if they do it's configurable anyway). The PHP API should be capable of connecting to bitcoind just the same across the 'net as if it's on the same box.
Blockchain.info 提供了与 Bitcoind JSON rpc 兼容的 api。
http://blockchain.info/api/json_rpc_api
Blockchain.info provides a Bitcoind JSON rpc compatible api.
http://blockchain.info/api/json_rpc_api
TL;DR;:不运行某种比特币客户端并且不信任第三方是不可能的。
虽然可以信任第三方告诉您帐户的余额,但一旦您使用
getnewaddress
或 < code>sendfrom,这可能不是您想要做的。据我所知,可能的最小解决方案是使用第三方,例如 http://blockchain.info ,跟踪余额(读取您在发送交易时可以声明的可支出
输出
),并使用通知服务告诉您传入的交易(此处列出了一些作为替代方案https://en.bitcoin.it/wiki/BitcoinNotify)。现在,为了能够接收交易,您所需要做的就是创建一个新地址以向您网站上的用户显示。在 PHP 中创建这样的地址应该不难,只需查看 wiki 即可。
现在对于发送部分来说,这将变得更加困难,因为它涉及:
正如您所看到的,当您尝试发送交易时,它很快就会变得复杂。如果不是绝对需要发送交易,我建议只向服务器提供可以接收交易的地址列表 BitAddress 允许您为此目的创建私钥/地址对。
TL;DR;: not running some sort of Bitcoin client and not trusting a third party will not be possible.
While it is possible to trust a third party to tell you the balance of an account you would have to trust the third party to handle the private keys needed to sign transactions as soon as you use either
getnewaddress
orsendfrom
, which is probably not what you want to do.As far as I see it a possible minimal solution would be to use a third party, such as http://blockchain.info, to keep track of the balances (read the spendable
outputs
you can claim when sending a transaction), and use a notification service to tell you about incoming transactions (some are listed as alternatives here https://en.bitcoin.it/wiki/BitcoinNotify).Now to be able to receive transactions all you need is to create a new address to show the users on your website. It should not be difficult to create such an address in PHP, just take a look at the wiki.
Now for the sending part, that's going to be quite a lot more difficult, as it involves:
So as you can see it gets complicated quickly as you try to send out transactions. If sending transactions is not absolutely required I'd suggest to just provide the server with a list of addresses to which it can receive transactions BitAddress allows you to create private key / address pairs just for this purpose.
如果您只想生成比特币地址和私钥,请尝试:
https://github.com/zamgo/ PHPCoinAddress
也许我们可以构建一个脚本,只找到 20 个比特币对等节点来广播我们的交易。
来自 bitseed.xf2.org 或 chainparams.cpp 源代码中的硬编码对等列表:
https://en.bitcoin.it/wiki/Satoshi_Client_Node_Discovery
If you want to only generate bitcoin address and private key, give a try to:
https://github.com/zamgo/PHPCoinAddress
And maybe we can build a script only to find 20 bitcoin peer nodes to broadcast our transaction.
from bitseed.xf2.org or hard coded peer list in chainparams.cpp source code:
https://en.bitcoin.it/wiki/Satoshi_Client_Node_Discovery
最好的情况下,您将需要服务提供商提供的 API 来允许钱包创建和交易查询。
当您正在寻找:创建、发送、接收 - 这意味着您将需要一个已经托管此服务的服务:
Coinkite 可能是一个不错的选择,因为大多数比特币操作都可以使用 API 完成:
发送并通过电子邮件、短信或比特币地址请求比特币
生成公钥 (HD)
检查余额并接收通知
将比特币安全地存储在 HSM 或多重签名账户中
创建凭证和纸钱包(私钥已公开)
创建P2SH支付地址,通过M-of-N多重签名提现。
导入并清理私钥
https://coinkite.com/faq/开发人员
At best you will need an API from a service provider that allows wallet creation and transaction queries.
As you're looking for: create, send, receive - this means that you will need a service that is hosting this already:
Coinkite may be a good option as the majority of bitcoin operations can be done with the API:
Send and request bitcoin by email, sms or bitcoin address
Generate public keys (HD)
Check balances and receive notifications
Safely store bitcoin in the HSM or Multi-signature accounts
Create vouchers and paper wallets (with private key published)
Create P2SH payment addresses, withdraw via M-of-N multisig.
Import and sweep private keys
https://coinkite.com/faq/developers
您可以使用开源 GoUrl.io 比特币-PHP 支付库 -
https:// github.com/cryptoapi/Payment-Gateway
You can use Open Source GoUrl.io Bitcoin-PHP Payment library -
https://github.com/cryptoapi/Payment-Gateway