Home

Awesome

openassets-ruby Build Status Gem Version MIT License

The implementation of the Open Assets Protocol for Ruby.

Install

gem install openassets-ruby

Configuration

Initialize the connection information to the Bitcoin Core server.

The configuration options are as follows:

optiondescriptiondefault
networkThe using network. "mainnet" or "testnet" or "regtest" or "litecoin" or "litecoin_testnet"mainnet
providerThe RPC server. "bitcoind" is the only option for now.bitcoind
cacheThe path to the database file. Specify ':memory:' to use in-memory database.cache.db
dust_limitThe amount of Bitcoin, which is set to the each output of the Open Assets Protocol (issue or transfer).600 (satoshi)
default_feesThe default transaction fee in satoshi. Specify :auto to use auto fee settings. (used by issue_asset and send_asset, send_bitcoin )10000 (satoshi)
min_confirmationThe minimum number of confirmations the transaction containing an output that used to get UTXO.1
max_confirmationThe maximum number of confirmations the transaction containing an output that used to get UTXO.9999999
rpcThe access information to the RPC server of Bitcoin Core.N/A

Using the API with multi-wallet support

To use the Bitcoin Core multi-wallet support (version 0.15 onwards), you should use multiple instances of API, for example:

@apis = Hash.new
@apis[1] = OpenAssets::Api.new({
            network:             'testnet',
            provider:           'bitcoind',
            cache:            'testnet.db',
            dust_limit:                600,
            default_fees:            10000,
            min_confirmation:            1,
            max_confirmation:      9999999,
            rpc: {
              user:                  'xxx',
              password:              'xxx',
              schema:               'http',
              port:                  18332,
              host:            'localhost',
              wallet:      'wallet001.dat',
              timeout:                  60,
              open_timeout:             60 }
          })
@apis[2] = OpenAssets::Api.new({
            network:             'testnet',
            provider:           'bitcoind',
            cache:            'testnet.db',
            dust_limit:                600,
            default_fees:            10000,
            min_confirmation:            1,
            max_confirmation:      9999999,
            rpc: {
              user:                  'xxx',
              password:              'xxx',
              schema:               'http',
              port:                  18332,
              host:            'localhost',
              wallet:      'wallet002.dat',
              timeout:                  60,
              open_timeout:             60 }
          })
# More wallets perhaps...
# Then call API selectively
@apis[1].provider.list_unspent
@apis[2].provider.list_unspent

API

Currently openassets-ruby support the following API.

If specified output_qty, the issue output is divided by the number of output_qty. For example, amount = 125 and output_qty = 2, the marker output asset quantity is [62, 63] and issue TxOut is two.

If specified output_qty, the send output is divided by the number of output_qty. Ex, asset holding amount = 200, and send amount = 125 and output_qty = 2, the marker output asset quantity is [62, 63, 75] and send TxOut is three. The last of the asset quantity is change asset output.

If specified output_qty, the send output is divided by the number of output_qty. Ex, amount = 60000 and output_qty = 2, send TxOut is two (each value is 30000, 30000) and change TxOut one.

Command line interface

Openassets-ruby comes with a openassets command line interface that allows easy interaction with OpenAssets.

Usage

openassets [options] [command]

Options:
-c path to config JSON which is passed to OpenAssets::Api.new - see Configuration for details
-e load config from ENV variables (look at the exe/openassets file for details)

commands:
* console runs an IRB console and gives you an initialized API instance to interact with OpenAssets
* any method on the API instance, helpful for get_balance, list_unspent

License

openassets-ruby is licensed under the MIT License.