RecordsKeeperRubyLib 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +114 -0
- data/LICENSE.txt +8 -0
- data/README.md +1 -0
- data/Rakefile +6 -0
- data/RecordsKeeperRuby.gemspec +34 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docs/addressdoc.rb +116 -0
- data/docs/assetsdoc.rb +65 -0
- data/docs/blockchaindoc.rb +77 -0
- data/docs/blockdoc.rb +76 -0
- data/docs/permissionsdoc.rb +65 -0
- data/docs/streamdoc.rb +84 -0
- data/docs/transactiondoc.rb +121 -0
- data/docs/walletdoc.rb +133 -0
- data/lib/RecordsKeeperRuby/address.rb +186 -0
- data/lib/RecordsKeeperRuby/assets.rb +87 -0
- data/lib/RecordsKeeperRuby/block.rb +89 -0
- data/lib/RecordsKeeperRuby/blockchain.rb +135 -0
- data/lib/RecordsKeeperRuby/permissions.rb +77 -0
- data/lib/RecordsKeeperRuby/sample_config.yaml +60 -0
- data/lib/RecordsKeeperRuby/stream.rb +169 -0
- data/lib/RecordsKeeperRuby/transaction.rb +182 -0
- data/lib/RecordsKeeperRuby/version.rb +3 -0
- data/lib/RecordsKeeperRuby/wallet.rb +252 -0
- data/lib/RecordsKeeperRuby.rb +9 -0
- data/lib/sample_config.yaml +60 -0
- data/sample_config.yaml +60 -0
- metadata +203 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8d8fd3853ae02d7f3ec7ee1c453837ab9d149a5f06bb063bfc2e80de90149c1c
|
4
|
+
data.tar.gz: 4d899180eb9ccd3e6f4ffc5ffeacb85fdb858e302ed10da9cf95f64e53a6bd98
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0fc4ab5b4f29de5102f1625d4fd7a37efbf4db20fc664743a1c530bed066388d62d7ac3897cee5405fa1626a8d2b3daa71a8d000b1088b9164c32c0f2b1736bb
|
7
|
+
data.tar.gz: a518c458f9bdd1246fd42f781b1f57987818a85364ab6019b80a4dfbdd177c39a2ec89d7213dc18faf629a896522909b86b3e10c08b6231572b3a83ab1bf25dc
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at yusraq10. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/RecordsKeeper/#{recordskeeper-ruby-sdk}" }
|
4
|
+
|
5
|
+
gem "httparty", " 0.16.2"
|
6
|
+
gem "hex_string", " 1.0.1"
|
7
|
+
gem "binary_parser", " 1.3.0"
|
8
|
+
gem "json", " 2.1.0"
|
9
|
+
gem "test-unit", "3.2.8"
|
10
|
+
gem "rspec-rails", "3.7.2"
|
11
|
+
|
12
|
+
gemspec
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
RecordsKeeperRubyLib (0.1.0)
|
5
|
+
binary_parser (~> 1.3.0)
|
6
|
+
hex_string (~> 1.0.1)
|
7
|
+
httparty (~> 0.16.2)
|
8
|
+
json (~> 2.1.0)
|
9
|
+
rspec-rails (~> 3.7.2)
|
10
|
+
test-unit (~> 3.2.8)
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
actionpack (5.2.0)
|
16
|
+
actionview (= 5.2.0)
|
17
|
+
activesupport (= 5.2.0)
|
18
|
+
rack (~> 2.0)
|
19
|
+
rack-test (>= 0.6.3)
|
20
|
+
rails-dom-testing (~> 2.0)
|
21
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
22
|
+
actionview (5.2.0)
|
23
|
+
activesupport (= 5.2.0)
|
24
|
+
builder (~> 3.1)
|
25
|
+
erubi (~> 1.4)
|
26
|
+
rails-dom-testing (~> 2.0)
|
27
|
+
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
28
|
+
activesupport (5.2.0)
|
29
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
30
|
+
i18n (>= 0.7, < 2)
|
31
|
+
minitest (~> 5.1)
|
32
|
+
tzinfo (~> 1.1)
|
33
|
+
binary_parser (1.3.0)
|
34
|
+
builder (3.2.3)
|
35
|
+
concurrent-ruby (1.0.5)
|
36
|
+
crass (1.0.4)
|
37
|
+
diff-lcs (1.3)
|
38
|
+
erubi (1.7.1)
|
39
|
+
hex_string (1.0.1)
|
40
|
+
httparty (0.16.2)
|
41
|
+
multi_xml (>= 0.5.2)
|
42
|
+
i18n (1.0.1)
|
43
|
+
concurrent-ruby (~> 1.0)
|
44
|
+
json (2.1.0)
|
45
|
+
loofah (2.2.2)
|
46
|
+
crass (~> 1.0.2)
|
47
|
+
nokogiri (>= 1.5.9)
|
48
|
+
method_source (0.9.0)
|
49
|
+
mini_portile2 (2.3.0)
|
50
|
+
minitest (5.11.3)
|
51
|
+
multi_xml (0.6.0)
|
52
|
+
nokogiri (1.8.2-x64-mingw32)
|
53
|
+
mini_portile2 (~> 2.3.0)
|
54
|
+
power_assert (1.1.1)
|
55
|
+
rack (2.0.5)
|
56
|
+
rack-test (1.0.0)
|
57
|
+
rack (>= 1.0, < 3)
|
58
|
+
rails-dom-testing (2.0.3)
|
59
|
+
activesupport (>= 4.2.0)
|
60
|
+
nokogiri (>= 1.6)
|
61
|
+
rails-html-sanitizer (1.0.4)
|
62
|
+
loofah (~> 2.2, >= 2.2.2)
|
63
|
+
railties (5.2.0)
|
64
|
+
actionpack (= 5.2.0)
|
65
|
+
activesupport (= 5.2.0)
|
66
|
+
method_source
|
67
|
+
rake (>= 0.8.7)
|
68
|
+
thor (>= 0.18.1, < 2.0)
|
69
|
+
rake (10.5.0)
|
70
|
+
rspec (3.7.0)
|
71
|
+
rspec-core (~> 3.7.0)
|
72
|
+
rspec-expectations (~> 3.7.0)
|
73
|
+
rspec-mocks (~> 3.7.0)
|
74
|
+
rspec-core (3.7.1)
|
75
|
+
rspec-support (~> 3.7.0)
|
76
|
+
rspec-expectations (3.7.0)
|
77
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
78
|
+
rspec-support (~> 3.7.0)
|
79
|
+
rspec-mocks (3.7.0)
|
80
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
81
|
+
rspec-support (~> 3.7.0)
|
82
|
+
rspec-rails (3.7.2)
|
83
|
+
actionpack (>= 3.0)
|
84
|
+
activesupport (>= 3.0)
|
85
|
+
railties (>= 3.0)
|
86
|
+
rspec-core (~> 3.7.0)
|
87
|
+
rspec-expectations (~> 3.7.0)
|
88
|
+
rspec-mocks (~> 3.7.0)
|
89
|
+
rspec-support (~> 3.7.0)
|
90
|
+
rspec-support (3.7.1)
|
91
|
+
test-unit (3.2.8)
|
92
|
+
power_assert
|
93
|
+
thor (0.20.0)
|
94
|
+
thread_safe (0.3.6)
|
95
|
+
tzinfo (1.2.5)
|
96
|
+
thread_safe (~> 0.1)
|
97
|
+
|
98
|
+
PLATFORMS
|
99
|
+
x64-mingw32
|
100
|
+
|
101
|
+
DEPENDENCIES
|
102
|
+
RecordsKeeperRubyLib!
|
103
|
+
binary_parser (= 1.3.0)
|
104
|
+
bundler (~> 1.16)
|
105
|
+
hex_string (= 1.0.1)
|
106
|
+
httparty (= 0.16.2)
|
107
|
+
json (= 2.1.0)
|
108
|
+
rake (~> 10.0)
|
109
|
+
rspec (~> 3.0)
|
110
|
+
rspec-rails (= 3.7.2)
|
111
|
+
test-unit (= 3.2.8)
|
112
|
+
|
113
|
+
BUNDLED WITH
|
114
|
+
1.16.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
Copyright (c) 2016-2018 Recordskeeper
|
2
|
+
License: GNU General Public License version 3, see COPYING
|
3
|
+
|
4
|
+
Portions copyright (c) 2014-2017 Coin Sciences Ltd
|
5
|
+
Portions copyright (c) 2009-2016 The Bitcoin Core developers
|
6
|
+
Portions copyright many others - see individual files
|
7
|
+
|
8
|
+
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# RecordsKeeper-SDK-Ruby
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "RecordsKeeperRuby/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "RecordsKeeperRubyLib"
|
8
|
+
spec.version = RecordsKeeperRuby::VERSION
|
9
|
+
spec.authors = ["Yusra Qureshi"]
|
10
|
+
spec.email = ["yusraq10"]
|
11
|
+
|
12
|
+
spec.summary = %q{Recordskeeper-SDK-Ruby}
|
13
|
+
spec.description = %q{This is a Recordskeeper library in Ruby.}
|
14
|
+
spec.homepage = "https://github.com/RecordsKeeper"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
spec.add_dependency "httparty", "~> 0.16.2"
|
28
|
+
spec.add_dependency "hex_string", "~> 1.0.1"
|
29
|
+
spec.add_dependency "binary_parser", "~> 1.3.0"
|
30
|
+
spec.add_dependency "json", "~> 2.1.0"
|
31
|
+
spec.add_dependency "test-unit", "~>3.2.8"
|
32
|
+
spec.add_dependency "rspec-rails", "~> 3.7.2"
|
33
|
+
|
34
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "RecordsKeeperRuby"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/docs/addressdoc.rb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
# = Address Class Usage
|
2
|
+
# This is a library to work with RecordsKeeper block information.
|
3
|
+
# You can generate new address, check all addresses, check address validity, check address permissions, check address balance by using Address class. You just have to pass parameters to invoke the pre-defined functions.
|
4
|
+
# ---------
|
5
|
+
# == Libraries
|
6
|
+
# Require these ruby libraries first to get started with the functionality.
|
7
|
+
# require 'rubygems'
|
8
|
+
# require 'httparty'
|
9
|
+
# require 'json'
|
10
|
+
# require 'binary_parser'
|
11
|
+
# require 'yaml'
|
12
|
+
# -----------------
|
13
|
+
# == Create Connection
|
14
|
+
# Entry point for accessing Address class resources.
|
15
|
+
# * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
|
16
|
+
# * Chain-name: chain name
|
17
|
+
# cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
|
18
|
+
# * Set a *network* value to change the network-type
|
19
|
+
# network = cfg['testnet'] # Network variable to store the network that you want to access
|
20
|
+
# **NOTE:* Default network is *Test-net*, you can change it to mainnet or testnet
|
21
|
+
# Check the network type for url and chain name:
|
22
|
+
# if @network==cfg['testnet']
|
23
|
+
# @url = cfg['testnet']['url']
|
24
|
+
# @chain = cfg['testnet']['chain']
|
25
|
+
# else
|
26
|
+
# @url = cfg['mainnet']['url']
|
27
|
+
# @chain = cfg['mainnet']['chain']
|
28
|
+
# end
|
29
|
+
# -------------------
|
30
|
+
# == Node Authentication
|
31
|
+
# Import values from config file.
|
32
|
+
# * User name: The rpc user is used to call the APIs.
|
33
|
+
# * Password: The rpc password is used to authenticate the APIs.
|
34
|
+
# * Check the network type for username and password:
|
35
|
+
# if @network==cfg['testnet']
|
36
|
+
# @user = cfg['testnet']['rkuser']
|
37
|
+
# @password = cfg['testnet']['passwd']
|
38
|
+
# else
|
39
|
+
# @user = cfg['mainnet']['rkuser']
|
40
|
+
# @password = cfg['mainnet']['passwd']
|
41
|
+
# end
|
42
|
+
# Now we have node authentication credentials.
|
43
|
+
# ------------
|
44
|
+
# = class Address
|
45
|
+
# Address class is used to call address related functions like generate new address, list all addresses and no of addresses on the node’s wallet, check if given address is valid or not, check if given address has mining permission or not and check a particular address balance on the node functions which are used on the RecordsKeeeper Blockchain.
|
46
|
+
# === 1. getAddress
|
47
|
+
# This function generates a new address on the node wallet.
|
48
|
+
# getAddress
|
49
|
+
# newAddress = getAddress # Function call
|
50
|
+
#
|
51
|
+
# puts newAddress # prints a new address
|
52
|
+
# === 2. getMultisigAddress nrequired, key
|
53
|
+
# This function generates a new multisignature address.
|
54
|
+
#
|
55
|
+
# You have to pass these two arguments to the getMultisigAddress function call:
|
56
|
+
# * nrequired: To pass the no of signatures that are a must to sign a transaction.
|
57
|
+
# * key: To pass any number of comma-separated public addresses that are to be used with this multisig address as a single variable.
|
58
|
+
# getMultisigAddress nrequired, key
|
59
|
+
# newAddress = getMultisigAddress nrequired, key # Function call
|
60
|
+
#
|
61
|
+
# puts newAddress # prints a new address
|
62
|
+
# === 3. getMultisigWalletAddress nrequired, key
|
63
|
+
# This function generates a new multisignature address on the node's wallet.
|
64
|
+
#
|
65
|
+
# You have to pass these two arguments to the getMultisigWalletAddress function call:
|
66
|
+
# * nrequired: This variable is required to pass the number of signatures that are a must to sign a transaction.
|
67
|
+
# * key: This variable is required to pass a string of comma-separated public addresses that are to be used with this multisig address as a single variable.
|
68
|
+
# getMultisigWalletAddress nrequired, key
|
69
|
+
# newAddress = getMultisigWalletAddress nrequired, key # Function call
|
70
|
+
#
|
71
|
+
# puts newAddress #prints a new address
|
72
|
+
# === 4. retrieveAddresses
|
73
|
+
# To list all the addresses and number of addresses on the node's wallet
|
74
|
+
# retrieveAddresses
|
75
|
+
# allAddresses, address_count = retrieveAddresses # Function call
|
76
|
+
#
|
77
|
+
# puts allAddresses # prints all the addresses of the wallet
|
78
|
+
# puts address_count # prints the address count
|
79
|
+
# === 5. checkifValid address
|
80
|
+
# To check validity of the address
|
81
|
+
#
|
82
|
+
# You have to pass address as argument to the checkifValid function call:
|
83
|
+
# * Address: To check its validity.
|
84
|
+
# checkifValid
|
85
|
+
# addressC = checkifValid address # Function call
|
86
|
+
#
|
87
|
+
# puts addressC # prints validity
|
88
|
+
# === 6. checkifMineAllowed address
|
89
|
+
# To check if given address has mining permission or not
|
90
|
+
#
|
91
|
+
# You have to pass address as argument to the checkifMineAllowed function call:
|
92
|
+
# * Address: To check the permission status
|
93
|
+
# checkifMineAllowed address
|
94
|
+
# permissionCheck = checkifMineAllowed address # Function call
|
95
|
+
#
|
96
|
+
# puts permissionCheck # prints permission status of the given address
|
97
|
+
# === 7. checkBalance address
|
98
|
+
# To check address balance on a particular node
|
99
|
+
#
|
100
|
+
# You have to pass address as argument to the checkifMineAllowed function call:
|
101
|
+
# * Address: To check the balance
|
102
|
+
# checkBalance address
|
103
|
+
# address_balance = checkBalance address # Function call
|
104
|
+
#
|
105
|
+
# puts address_balance # prints balance of the address
|
106
|
+
# === 8. importAddress public_address
|
107
|
+
# To import a non-wallet address on RecordsKeeeper Blockchain
|
108
|
+
#
|
109
|
+
# You have to pass address as argument to the importAddress function call:
|
110
|
+
# * Address: A non-wallet address to import on a particular node
|
111
|
+
# importAddress public_address
|
112
|
+
# response = importAddress public_address # Function call
|
113
|
+
#
|
114
|
+
# puts response # prints response
|
115
|
+
class Address
|
116
|
+
end
|
data/docs/assetsdoc.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# = Assets Class Usage
|
2
|
+
# This is a library to work with RecordsKeeper assets.
|
3
|
+
# You can create new assets and list all assets by using Assets class. You just have to pass parameters to invoke the pre-defined functions.
|
4
|
+
# ---------
|
5
|
+
# == Libraries
|
6
|
+
# Require these ruby libraries first to get started with the functionality.
|
7
|
+
# require 'rubygems'
|
8
|
+
# require 'httparty'
|
9
|
+
# require 'json'
|
10
|
+
# require 'binary_parser'
|
11
|
+
# require 'yaml'
|
12
|
+
# -----------------
|
13
|
+
# == Create Connection
|
14
|
+
# Entry point for accessing Address class resources.
|
15
|
+
# * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
|
16
|
+
# * Chain-name: chain name
|
17
|
+
# cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
|
18
|
+
# * Set a *network* value to change the network-type
|
19
|
+
# network = cfg['testnet'] # Network variable to store the network that you want to access
|
20
|
+
# **NOTE:* Default network is *Test-net*, you can change it to mainnet or testnet
|
21
|
+
# Check the network type for url and chain name:
|
22
|
+
# if @network==cfg['testnet']
|
23
|
+
# @url = cfg['testnet']['url']
|
24
|
+
# @chain = cfg['testnet']['chain']
|
25
|
+
# else
|
26
|
+
# @url = cfg['mainnet']['url']
|
27
|
+
# @chain = cfg['mainnet']['chain']
|
28
|
+
# end
|
29
|
+
# -------------------
|
30
|
+
# == Node Authentication
|
31
|
+
# Import values from config file.
|
32
|
+
# * User name: The rpc user is used to call the APIs.
|
33
|
+
# * Password: The rpc password is used to authenticate the APIs.
|
34
|
+
# * Check the network type for username and password:
|
35
|
+
# if @network==cfg['testnet']
|
36
|
+
# @user = cfg['testnet']['rkuser']
|
37
|
+
# @password = cfg['testnet']['passwd']
|
38
|
+
# else
|
39
|
+
# @user = cfg['mainnet']['rkuser']
|
40
|
+
# @password = cfg['mainnet']['passwd']
|
41
|
+
# end
|
42
|
+
# Now we have node authentication credentials.
|
43
|
+
# ------------
|
44
|
+
# = class Assets
|
45
|
+
# Assets class is used to call assets related functions like create assets and list assets functions which are used on the RecordsKeeeper Blockchain.
|
46
|
+
# === 1. createAsset
|
47
|
+
# This function is used to create or issue an asset.
|
48
|
+
# txid = createAsset # Function call
|
49
|
+
#
|
50
|
+
# puts txid # prints tx id of the issued asset
|
51
|
+
# === 2. retrieveAssets
|
52
|
+
# This function is used to list all assets, no of assets, issued quantity and issued transaction id of all the assets on RecordsKeeper Blockchain.
|
53
|
+
# asset_name, issue_id, issue_qty, asset_count = retrieveAssets # Function call
|
54
|
+
#
|
55
|
+
# puts asset_name # prints all the addresses of the wallet
|
56
|
+
# puts asset_count # prints the address count
|
57
|
+
# puts issue_qty # prints assets issued quantity
|
58
|
+
# puts issue_id # prints assets issued transaction id
|
59
|
+
# === 3. sendAsset
|
60
|
+
# This function is used to send an asset.
|
61
|
+
# txid = sendAsset # Function call
|
62
|
+
#
|
63
|
+
# puts txid # prints tx id of the sent asset
|
64
|
+
class Assets
|
65
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# = Blockchain Class Usage
|
2
|
+
# This is a library to work with Blockchain in RecordsKeeper Blockchain.
|
3
|
+
# You can retrieve information about the chain and node, list all the permissions and the pending transactions and check your node's balance.
|
4
|
+
# ---------
|
5
|
+
# == Libraries
|
6
|
+
# Require these ruby libraries first to get started with the functionality.
|
7
|
+
# require 'rubygems'
|
8
|
+
# require 'httparty'
|
9
|
+
# require 'json'
|
10
|
+
# require 'binary_parser'
|
11
|
+
# require 'yaml'
|
12
|
+
# -----------------
|
13
|
+
# == Create Connection
|
14
|
+
# Entry point for accessing Blockchain class resources.
|
15
|
+
# * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
|
16
|
+
# * Chain-name: Name of the chain
|
17
|
+
# cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
|
18
|
+
# * Set a *network* value to change the network-type
|
19
|
+
# network = cfg['testnet'] # Network variable to store the network that you want to access
|
20
|
+
# **NOTE:* Default network is *Test-net* ( i.e., you can set it to either testnet or mainnet).
|
21
|
+
# Check the network type for url and chain name:
|
22
|
+
# if @network==cfg['testnet']
|
23
|
+
# @url = cfg['testnet']['url']
|
24
|
+
# @chain = cfg['testnet']['chain']
|
25
|
+
# else
|
26
|
+
# @url = cfg['mainnet']['url']
|
27
|
+
# @chain = cfg['mainnet']['chain']
|
28
|
+
# end
|
29
|
+
# -------------------
|
30
|
+
# == Node Authentication
|
31
|
+
# Import values from config file.
|
32
|
+
# * User name: The rpc user is used to call the APIs.
|
33
|
+
# * Password: The rpc password is used to authenticate the APIs.
|
34
|
+
# * Check the network type for username and password:
|
35
|
+
# if @network==cfg['testnet']
|
36
|
+
# @user = cfg['testnet']['rkuser']
|
37
|
+
# @password = cfg['testnet']['passwd']
|
38
|
+
# else
|
39
|
+
# @user = cfg['mainnet']['rkuser']
|
40
|
+
# @password = cfg['mainnet']['passwd']
|
41
|
+
# end
|
42
|
+
# Now we have node authentication credentials.
|
43
|
+
# ------------
|
44
|
+
# = class Blockchain
|
45
|
+
# Blockchain class is used to call blockchain related functions to retrieve information about the chain and node, list all the permissions and the pending transactions and check your node's balance.
|
46
|
+
# === 1. getChainInfo
|
47
|
+
# This function retrieves information about the chain.
|
48
|
+
# getChainInfo
|
49
|
+
# chainInfo = getChainInfo # Function call
|
50
|
+
#
|
51
|
+
# puts chainInfo # Prints chain_protocol, chain_description, root_stream, max_blocksize, default_networkport, default_rpcport, mining_diversity and chain_name.
|
52
|
+
# === 2. getNodeInfo
|
53
|
+
# This function retrieves information related to your node.
|
54
|
+
# getNodeInfo
|
55
|
+
# nodeInfo = getNodeInfo # Function call
|
56
|
+
#
|
57
|
+
# puts nodeInfo # Prints node_balance, synced_blocks, node_address and difficulty.
|
58
|
+
# === 3. permissions
|
59
|
+
# This function lists all the permissions.
|
60
|
+
# permissions
|
61
|
+
# listpermissions = permissions # Function call
|
62
|
+
#
|
63
|
+
# puts listpermissions # Prints the list of permissions.
|
64
|
+
# === 4. getpendingTransactions
|
65
|
+
# This function retrieves information related to your node.
|
66
|
+
# getpendingTransactions
|
67
|
+
# pentransac = getpendingTransactions # Function call
|
68
|
+
#
|
69
|
+
# puts pentransac # Prints transaction_count and the transactions.
|
70
|
+
# === 5. checkNodeBalance
|
71
|
+
# This function retrieves information related to your node.
|
72
|
+
# checkNodeBalance
|
73
|
+
# nodeBal = checkNodeBalance # Function call
|
74
|
+
#
|
75
|
+
# puts nodeBal # Prints node's balance amount.
|
76
|
+
class Blockchain
|
77
|
+
end
|
data/docs/blockdoc.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# = Block Class Usage
|
2
|
+
# This is a library to work with RecordsKeeper block information.
|
3
|
+
# You can generate new address, check all addresses, check address validity, check address permissions, check address balance by using Address class. You just have to pass parameters to invoke the pre-defined functions.
|
4
|
+
# ---------
|
5
|
+
# == Libraries
|
6
|
+
# Require these ruby libraries first to get started with the functionality.
|
7
|
+
# require 'rubygems'
|
8
|
+
# require 'httparty'
|
9
|
+
# require 'json'
|
10
|
+
# require 'binary_parser'
|
11
|
+
# require 'yaml'
|
12
|
+
# -----------------
|
13
|
+
# == Create Connection
|
14
|
+
# Entry point for accessing Address class resources.
|
15
|
+
# * URL: Url to connect to the chain ([RPC Host]:[RPC Port])
|
16
|
+
# * Chain-name: chain name
|
17
|
+
# cfg = YAML::load(File.open('sample_config.yaml','r')) # Loads the configuration file
|
18
|
+
# * Set a *network* value to change the network-type
|
19
|
+
# network = cfg['testnet'] # Network variable to store the network that you want to access
|
20
|
+
# **NOTE:* Default network is *Test-net*, you can change it to mainnet or testnet
|
21
|
+
# Check the network type for url and chain name:
|
22
|
+
# if @network==cfg['testnet']
|
23
|
+
# @url = cfg['testnet']['url']
|
24
|
+
# @chain = cfg['testnet']['chain']
|
25
|
+
# else
|
26
|
+
# @url = cfg['mainnet']['url']
|
27
|
+
# @chain = cfg['mainnet']['chain']
|
28
|
+
# end
|
29
|
+
# -------------------
|
30
|
+
# == Node Authentication
|
31
|
+
# Import values from config file.
|
32
|
+
# * User name: The rpc user is used to call the APIs.
|
33
|
+
# * Password: The rpc password is used to authenticate the APIs.
|
34
|
+
# * Check the network type for username and password:
|
35
|
+
# if @network==cfg['testnet']
|
36
|
+
# @user = cfg['testnet']['rkuser']
|
37
|
+
# @password = cfg['testnet']['passwd']
|
38
|
+
# else
|
39
|
+
# @user = cfg['mainnet']['rkuser']
|
40
|
+
# @password = cfg['mainnet']['passwd']
|
41
|
+
# end
|
42
|
+
# Now we have node authentication credentials.
|
43
|
+
# ------------
|
44
|
+
# = class Block
|
45
|
+
# Block class is used to call block related functions like blockinfo which is used to retrieve block details
|
46
|
+
# like block's hash value, size, nonce, transaction ids, transaction count, miner address, previous block hash,
|
47
|
+
# next block hash, merkleroot, blocktime and difficulty of the block for which you have made the query.
|
48
|
+
# === 1. blockinfo block_height
|
49
|
+
# * You have to pass the block height as an argument in the blockinfo function call (Block height: Height of the block of which you want to collect information.)
|
50
|
+
# * It will return transaction ids, transaction count, nonce, size, hash value, previous block's hash value, next block hash value, merkle root, difficulty, blocktime and miner address of the block.
|
51
|
+
# blockinfo block_height # Function call
|
52
|
+
# tx_count, tx, miner, size, nonce, blockHash, prevblock, nextblock, merkleroot, blocktime, difficulty = blockinfo block_height
|
53
|
+
#
|
54
|
+
# puts tx_count # prints transaction count of the block
|
55
|
+
# puts tx # prints transaction ids of the block
|
56
|
+
# puts size # prints size of the block
|
57
|
+
# puts blockHash # prints hash value of the block
|
58
|
+
# puts nonce # prints nonce of the block
|
59
|
+
# puts miner # prints miner's address of the block
|
60
|
+
# puts nextblock # prints next block's hash
|
61
|
+
# puts prevblock # prints previous block's hash
|
62
|
+
# puts merkleroot # prints merkle root of the block
|
63
|
+
# puts blocktime # prints time at which block is mined
|
64
|
+
# puts difficulty # prints difficulty of the block
|
65
|
+
# === 2. retrieveBlocks block_range
|
66
|
+
# * You have to pass the block's height as the argument to the retrieveBlocks function call (Block range: Range of the block of which you want to collect information)
|
67
|
+
# * It will return blockhash, miner address, blocktime and transaction count of the blocks.
|
68
|
+
# retrieveBlocks block_range # Function call
|
69
|
+
# block_hash, miner_add, block_time, txcount = retrieveBlocks block_range
|
70
|
+
#
|
71
|
+
# puts block_hash # prints hash of the blocks
|
72
|
+
# puts miner_add # prints miner of the blocks
|
73
|
+
# puts block_time # prints block time of the blocks
|
74
|
+
# puts txcount # prints transaction count of the blocks
|
75
|
+
class Block
|
76
|
+
end
|