Skip to content

gaiax/oreki

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

134 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oreki

original endpoint sales kit

oreki is a package for sale API that you developed. You can choose bitcoin or ethereum.

🌴 Prerequisites

OS Amazon Linux2
Storage about 500GB

🚀 Installation

cd /path/to/oreki

cd install-script
./install-yum.sh
./install-golang.sh
# set up GOPATH and golang etc
./install-glide.sh
./install-lnd.sh
# install btcd or bitcoind(optional)
# ./install-btcd.sh
# ./install-bitcoind.sh
# install geth for using ethereum(optional)
# ./install-geth.sh

✅ To check

1. bitcoin or ethereum

If you want to use ethereum, read here

2. btcd or bitcoind or neutrino(case of bitcoin)

If you want to build bitcoin fullnode, use btcd, and read here.

If you want to use bitcoind, read here.

If you don't want to build bitcoin node, use neutrino mode of lnd, and read here. This solution is to trust other server. It's easy, but you don't get real benefit of blockchain.

🚀 Quick Start

create your LND Wallet

check here

publish your public key of lnd

prepare to use oreki

1. install oreki-node to your project

npm install oreki-node

2. copy rpc.proto from this repository to your project

3. make "config.json" from example(bitcoin) or example(ethereum)

4. import oreki module

5. initialize oreki object and call init function

6. set event handler that notices payment

7. register payment reservation

8. call start function to check transactions

When customer buy API access authority

  1. Call addPayment function, and let customer know invoice decoded

  2. Customer connects to your lnd node using your public key

  3. Customer opens payment channel

  4. Customer pays to you by invoice

  5. Customer closes payment channel

📚 Documentation

import

const Oreki = require("oreki-node").Oreki

initialize

const oreki = new Oreki("config file path")
oreki.init().then(function(success) {
  if (!success) {
    //It failed
  }
})

add payment event

oreki.on("paid", function(payment) {
  //increment api point from payment.point and payment.user_id and payment.endpoint_id
})

oreki.on("insufficient", function(payment) {
  // when the payment is insufficient
  // ethereum only
})

start

oreki.start()

register payment reservation

oreki.addPayment(<user_id: string>, <endpoint_id: string>, <point: int>, <bitcoin amount: int>).then(function(payment) {
  //payment.payee: bitcoin invoice or ethereum address
})
//oreki.addPayment("user_id", "endpoint_id", 100, 1000)

✅ How to test

  1. Create 2 processes of lnd(as Alice and Bob)
  2. Set password "HelloWorld" to Alice and Bob
  3. Get coins with 2 accounts by testnet faucet more than 10000
  4. Run "npm test"

🔧 Contribution

  1. Fork oreki-node
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Implement it and check it runs(npm test)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request

📔 License

MIT License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors