当前位置: 首页 > 软件库 > Web3 > 开源货币/比特币 >

Cashier-BTC

💰 Self-hosted Bitcoin payment gateway (฿)
授权协议 Readme
开发语言 Python
所属分类 Web3、 开源货币/比特币
软件类型 开源软件
地区 不详
投 递 者 伯和蔼
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Cashier-BTC

v2 refactored and improved

Tests:

Self-hosted Node.js Bitcoin payment gateway. Provides REST API (microservice).Process Bitcoin payments on your end, securely, with no comission.

Request payments (invoicing), check payments (whether invoice is paid), receive callbacks if payment is made.Aggregate funds on final (aggregational) address.Depends on Nodejs v8+, Bitcoin Core, Couchdb for storage.

  • Simple
  • No 3rd parties (works though Bitcoin Core node)
  • Transactions are signed locally. No private keys leak
  • Battle-tested in production
  • SegWit compatible

Installation

$ git clone https://github.com/Overtorment/Cashier-BTC && cd Cashier-BTC
$ npm install
$ cp config.js.dev config.js

Edit config.js:

  • Point it to a new Couchdb database
  • Point it to a Bitcoin Core RPC server

Tests

$ npm test

Running

$ nodejs cashier-btc.js
$ nodejs worker.js
$ nodejs worker2.js

Open http://localhost:2222 in browser, you should see 'Cashier-BTC reporting for duty'.That's it, ready to use.Use tools like supervisord or foreverjs to keep it running.

License

WTFPL

Author

Igor Korsakov

TODO

  • Get rid of Chain and leave Bitcore only
  • Add options to work through bitcoind and other bitcoin network endpoints
  • Add tests
  • Better abstractioning (add more abstraction layers)
  • CI
  • Better logging & error handling
  • Stats
  • Better tests
  • Ditch bitcore-lib in favor of bitcoinjs-lib
  • SegWit
  • Flexible (user-defined?) fees
  • BigNumber lib for all numbers handling

API

GET /request_payment/:expect/:currency/:message/:seller/:customer/:callback_url

Create a request to pay, supported currencies: BTC, USD, EUR. Non-btc currency is converted to btc using current rate from bitstamp.com.Returns a json document with QR code to be displayed to the payer, and a unique address for that particular payment (you can use it as invoice id).Message will be displayed to the client (for example, you can write "Payment for goods"). Seller and customer - system field, here you canwrite the application that created the request and the payer id. Keep Seller field private, it is also used for payouts.Callback_url will be requested once the invoice is paid.

Example

	http://localhost:2222/request_payment/0.005/BTC/wheres%20the%20money%20lebowski/treehorn/lebowski/http%3A%2F%2Fgoogle.com%2F

Response

	{
		"link" : "bitcoin:1DzJepHCRD2C9vpFjk11eXJi97juEZ3ftv?amount=0.004&message=wheres%20the%20money%20lebowski",
		"qr" : "http://localhost:2222/generate_qr/bitcoin%3A1DzJepHCRD2C9vpFjk11eXJi97juEZ3ftv%3Famount%3D0.004%26message%3Dwheres%2520the%2520money%2520lebowski",
		"qr_simple" : "http://localhost:2222/generate_qr/1DzJepHCRD2C9vpFjk11eXJi97juEZ3ftv",
		"address" : "1DzJepHCRD2C9vpFjk11eXJi97juEZ3ftv"
	}

Link can be opened by the payer, there is a chance it will be handled by his bitcoin wallet.QR shoud be shown to payer as well. Duplicate it with text, like, dear user, please pay the %expect% amount to %address%.

GET /check_payment/:address

Check payment by a unique address received in the "request_payment" call.

Example

	http://localhost:2222/check_payment/16FsTPe5JG8yj1P31AqXrMGzu7iAet7NTL

Response

	{
		"btc_expected" : 0.0001009,
		"btc_actual" : 0.0001009,
		"btc_unconfirmed" : 0.0001009
	}

Using difference between "btc_expected" and "btc_actual" you can judge whether payment request (invoice) was paid.You can use this call to implement some kind of frontend animation which shows 'waiting for funds', andpolls periodically about the status of payment (i.e. unconfirmed incoming funds, paid in full/not in full).In case you accept unconfirmed balances (see config.small_amount_threshhold), you might want to check payment again before shipping actual goods.

GET /payout/:seller/:amount/:currency/:address

Transfer funds from aggregated seller's address to some other address.Supported currencies: BTC.There's no additional sequrity here, it is presumed that the %seller% identifier is kept secret.You might want to disable this call for security reasons (or manually replace seller's address indatabase with the one you control).

Example

	http://localhost:2222/payout/new_test_seller/0.01/BTC/1MahZCousgNv6EAofCfi7Wpp2RKUfHH8uD

Response

	If successfull, json document with transaction details (txid etc)

GET /get_seller_balance/:seller

Check the total balance of seller's aggregated address.

Example

	http://localhost:2222/get_seller_balance/treehorn

Response

	Json encoded available balance

Hardening for Production

When the seller is created in /request_payment/ call, database record also stores seller's addressand associated WIF which allows to spend seller's aggregated funds.You might want to manually replace this record with your own address (probably a cold storage), and not putting WIF in the record.This breaks the /payout/ call, but at least the funds from orders will be forwarded to a secure storage.

Small risk remains with hot wallets still having their WIFs in the database, but this is a reality any other Bitcoin processorhas to live in.

Alternatives

Opensource alternatives

SaaS alternatives

  • 题目描述 A supermarket in Tehran is open 24 hours a day every day and needs a number of cashiers to fit its need. The supermarket manager has hired you to help him, solve his problem. The problem is that

  • 关键字:区块链 初次流通 2010.5.22,Laszlo Hanyecz用10,000个BTC买了2个披萨 重仓投资 Winklevoss兄弟,13年100多美元开始,买入1W多BTC投资 首台ASIC矿机 2013.1出现首台ASIC矿机。 政府监管 2013.10,丝路网站被FBI查抄,魔兽14W BTC。 房价涨的优点 如果没有高房价,那粮食就会涨价。 美国为了刺激炒房 零首付和前两年只还

  • 滴答滴答---题目链接 time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vasya has recently got a job as a cashier at a local store. His day at work is

  • time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Vasya went to the supermarket to get some groceries. He walked about the supermarket

 相关资料
  • Introduction Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services. It handles almost all of the boilerplate subscription billing code you are dreading wri

  • BTC RPC Explorer Self-Hosted Bitcoin explorer for anyone running Bitcoin Core. This is a self-hosted explorer for the Bitcoin blockchain, driven by RPC calls to your own Bitcoin node. It is easy to ru

  • Bitcoin & Monero Cross-chain Atomic Swap ia.cr/2020/1126 Abstract In blockchains where hashed timelock contracts are possible atomic swaps are already deployed, but when one blockchain doesn't have th

  • 最常用的BIF之一,返回调用进程的pid。 语法 (Syntax) self() 参数 (Parameters) 没有 返回值 (Return Value) 返回调用进程的pid。 例如 (For example) -module(helloworld). -export([start/0]). start() -> io:fwrite("~p~n",[self()]). 输出 (

  • 在定义类的过程中,无论是显式创建类的构造方法,还是向类中添加实例方法,都要求将 self 参数作为方法的第一个参数。例如,定义一个 Person 类: 那么,self 到底扮演着什么样的角色呢?本节就对 self 参数做详细的介绍。 事实上,Python 只是规定,无论是构造方法还是实例方法,最少要包含一个参数,并没有规定该参数的具体名称。之所以将其命名为 self,只是程序员之间约定俗成的一种习

  • 简介 Laravel Cashier 提供了直观、流畅的接口来接入 Stripe's 和 Braintree's 订阅付费服务。它可以处理几乎所有你写起来非常头疼付费订阅代码。除了提供基本的订阅管理之外,Cashier 还可以帮你处理优惠券,交换订阅、订阅“数量”、取消宽限期,甚至还可以生成pdf文档。 {note} 如果你只是“一次性”的收费并且不提供订阅。你就不应该使用 Cashier 。可以