Bitnob

— This is a Ruby gem for easy integration of Bitnob For Business API for various applications written in Ruby language from Bitnob.

Getting started

Requirements

This gem requires Ruby 2.6+ and Rails 5.2+

Installation

gem 'bitnob', '~> 0.0.2'

Then run:

bundle install

Usage

By default the package assumes that you are currently working using a sandbox credential in development, however to go live, your secret key nust be a production-grade secret key and you need to specify true when instantiating your bitnob class like this:

require 'bitnob'

    wallet = Wallet.new(true) # production
   get_wallets = wallet.fetch_wallets
   p get_wallets.body

    # Sandbox environment

    wallet = Wallet.new 
    
    get_transaction = wallet.fetch_all_transactions
   p get_transaction.body

NOTE: It is best practice to always set your API keys to your environment variable for security purpose. Please be warned not use this package without setting your API keys in your environment variables in production.

Bitnob Functions

Customers

Lightning

Full Transaction Workflow
require 'bitnob'

    ln = Lightning.new(true)

    payload = {
        customerEmail: "parah@bitnob.com",
        description: "Dorime for Nonso and Tumise",
        tokens: 300,
        expires_at: "24h",
    }

    # Create a lightning invoice

   new_ln_invoice = ln.create_invoice(payload)

LNURL vs Lightning Address

A Lightning Address is a wrapper around lnurl. A Lightning Address is an Internet Identifier that allows anyone to send you Bitcoin over the Lightning Network. No scanning of QR codes or pasting invoices necessary. The Lightning URL on the other hand, is a lot more technical and requires the embedding and scanning of lightning invoices to initiate payments The username you use to create the lnurl automatically becomes the lightning address in this case.

Lightning URL (LNURL) :new

Onchain

Full Transaction Workflow

    require 'bitnob'

    on_chain = Onchain.new(true)

    payload = {
        customerEmail: "parah@bitnob.com",
        satoshis: 30000,
        address: "btcjshlidlsidskdslisidsdosilsdmxksjsjldksossjoioidjifkji.zjijsi",
        description: "Go buy your momma a house!",
        priorityLevel: "regular"
    }

    # Send bitcoin using onchain

    new_onchain = on_chain.send_bitcoin(payload)

Wallets

Virtual Cards :new

Swap :new

Checkout :new

StableCoin :new

Webhook Authentication

        require 'bitnob'

        check_webhook = webhook_authentication(requests) # return true or false

Important Note

require 'bitnob'

    wallet = Wallet.new(true) # production
   get_wallets = wallet.fetch_wallets
   p get_wallets.body # fetches response body
   p get_wallets.headers # fetches response headers

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at github.com/bitnob/bitnob_ruby_SDK. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct. Simply create a new branch and raise a Pull Request, we would review and merge.

License

The gem is available as open source under the terms of the BSD License