hhstore / blog

My Tech Blog: about Mojo / Rust / Golang / Python / Kotlin / Flutter / VueJS / Blockchain etc.
https://github.com/hhstore/blog/issues
286 stars 24 forks source link

blockchain: btc(bitcoin) #14

Open hhstore opened 6 years ago

hhstore commented 6 years ago

ref:

官网:

下载地址:

源码库:

hhstore commented 5 years ago

book:

hhstore commented 5 years ago

ref:

比特币搬砖:

hhstore commented 5 years ago

参考:

BTC挖矿协议:

hhstore commented 5 years ago

Insight API:

官方:

参考:

本地环境:

https://github.com/bitpay/insight


npm install -g bitcore-node

# create:
bitcore-node create mynode

cd mynode
bitcore-node install insight-api
bitcore-node install insight-ui

# start:
bitcore-node start

# Open a web browser to 
# http://localhost:3001/insight/

# dev:
npm run build
npm run watch
hhstore commented 5 years ago

restful api:

https://github.com/bitpay/insight-api https://www.npmjs.com/package/insight-bitcore-api

/insight-api/tx/[:txid]
/insight-api/tx/525de308971eabd941b139f46c7198b5af9479325c2395db7f2fb5ae8562556c
/insight-api/rawtx/[:rawid]
/insight-api/rawtx/525de308971eabd941b139f46c7198b5af9479325c2395db7f2fb5ae8562556c

/insight-api/addr/[:addr]/balance
/insight-api/addr/[:addr]/totalReceived
/insight-api/addr/[:addr]/totalSent
/insight-api/addr/[:addr]/unconfirmedBalance

/insight-api/tx/525de308971eabd941b139f46c7198b5af9479325c2395db7f2fb5ae8562556c

# 示例:
https://insight.bitpay.com/api/tx/e5ceadf7a87888b11d71f5a216620ab9a0c26444490d146f1e64c1c115c1d833

https://insight.bitpay.com/api/rawtx/e5ceadf7a87888b11d71f5a216620ab9a0c26444490d146f1e64c1c115c1d833

# test env:
https://test-insight.bitpay.com/api/tx/d193a7ed1cea05a6e191ccacd381d1cb13b9065dd39b90189c2b55b835c267f7
https://test-insight.bitpay.com/api/rawtx/d193a7ed1cea05a6e191ccacd381d1cb13b9065dd39b90189c2b55b835c267f7
hhstore commented 5 years ago

bitcoin API:

rpc:

https://pypi.python.org/pypi/bitcoin-python/0.3


# 客户端:

>>> import jsonrpclib
>>> server = jsonrpclib.Server('http://localhost:8080')
>>> server.add(5,6)
11
>>> print jsonrpclib.history.request
{"jsonrpc": "2.0", "params": [5, 6], "id": "gb3c9g37", "method": "add"}
>>> print jsonrpclib.history.response
{'jsonrpc': '2.0', 'result': 11, 'id': 'gb3c9g37'}
>>> server.add(x=5, y=10)
15
>>> server._notify.add(5,6)
# No result returned...
>>> batch = jsonrpclib.MultiCall(server)
>>> batch.add(5, 6)
>>> batch.ping({'key':'value'})
>>> batch._notify.add(4, 30)
>>> results = batch()
>>> for result in results:
>>> ... print result
11
{'key': 'value'}
# Note that there are only two responses -- this is according to spec.

# 服务器端:
from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCServer

server = SimpleJSONRPCServer(('localhost', 8080))
server.register_function(pow)
server.register_function(lambda x,y: x+y, 'add')
server.register_function(lambda x: x, 'ping')
server.serve_forever()

其他:

http://8btc.com/forum.php?mod=viewthread&tid=2549

hhstore commented 5 years ago

查询测试API:

btc, etc, eth:

https://kovan.etherscan.io/tx/0x15860b8a6c8040312da2aa6004854e1e9ebb5ea29ed046d8a3a6f3dbb93a582c

https://test-insight.bitpay.com/tx/03cb5264525f2105b4a98f8172864ec62889bd9f31b199f19c44fa75eec80206

web3.py

pip install web3
hhstore commented 5 years ago

资讯类参考: