openassets-ruby 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +12 -5
- data/lib/openassets/api.rb +2 -1
- data/lib/openassets/protocol/asset_definition.rb +28 -2
- data/lib/openassets/protocol/transaction_output.rb +6 -1
- data/lib/openassets/version.rb +1 -1
- data/openassets-ruby.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d4b61f5231ce9ddde842d4269de8a9b683c7d0e
|
4
|
+
data.tar.gz: a8231c78393699625f5a7c03be616d0586c18b0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e54c5aa9436b2528065b9a77da06cae8a123dd8b38478561ca4f4df9d89dabce2a41bd0020e6326ccd290c03292f8fccdb3c309a6c8b657aa85e48ad21c7c88
|
7
|
+
data.tar.gz: a49134f3c11dd99c874f1578dd4864d1e1b700309c5c30058991a2a4fe98b2c13d5b153dca0df8f0e524345f80753cd30ff7f13bd4d2276ba3c08b00417bf599
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ require 'openassets'
|
|
17
17
|
|
18
18
|
api = OpenAssets::Api.new({:network => 'mainnet',
|
19
19
|
:provider => 'bitcoind',
|
20
|
-
:dust_limit => 600, :default_fees => 10000,
|
20
|
+
:dust_limit => 600, :default_fees => 10000, :min_confirmation => 1, :max_confirmation => 9999999,
|
21
21
|
:rpc => {:user => 'xxx', :password => 'xxx', :schema => 'http', :port => 8332, :host => 'localhost'}})
|
22
22
|
```
|
23
23
|
|
@@ -28,7 +28,7 @@ require 'openassets'
|
|
28
28
|
|
29
29
|
api = OpenAssets::Api.new({:network => 'testnet',
|
30
30
|
:provider => 'bitcoind',
|
31
|
-
:dust_limit => 600, :default_fees => 10000,
|
31
|
+
:dust_limit => 600, :default_fees => 10000, :min_confirmation => 1, :max_confirmation => 9999999,
|
32
32
|
:rpc => {:user => 'xxx', :password => 'xxx', :schema => 'http', :port => 18332, :host => 'localhost'}})
|
33
33
|
```
|
34
34
|
|
@@ -40,6 +40,8 @@ The configuration options are as follows:
|
|
40
40
|
|**provider**|The RPC server. Specify possible now only "bitcoind".|bitcoind|
|
41
41
|
|**dust_limit**|The amount of Bitcoin, which is set to the each output of the Open Assets Protocol(issue or transfer).|600 (satoshi)|
|
42
42
|
|**default_fees**|The transaction fee. (used by issue_asset and send_asset, send_bitcoin )|10000 (satoshi)|
|
43
|
+
|**min_confirmation**|The minimum number of confirmations the transaction containing an output that used to get UTXO.|1|
|
44
|
+
|**max_confirmation**|The maximum number of confirmations the transaction containing an output that used to get UTXO.|9999999|
|
43
45
|
|**rpc**|The access information to the RPC server of Bitcoin Core.|N/A|
|
44
46
|
|
45
47
|
## API
|
@@ -68,7 +70,8 @@ Returns an array of unspent transaction outputs, argument with the asset ID and
|
|
68
70
|
"account": "openassets-ruby",
|
69
71
|
"asset_quantity": "67",
|
70
72
|
"asset_amount": "6.7",
|
71
|
-
"asset_definition_url": "http://goo.gl/fS4mEj"
|
73
|
+
"asset_definition_url": "http://goo.gl/fS4mEj",
|
74
|
+
"proof_of_authenticity": false
|
72
75
|
},
|
73
76
|
...
|
74
77
|
```
|
@@ -87,6 +90,7 @@ Returns an array of unspent transaction outputs, argument with the asset ID and
|
|
87
90
|
|asset_quantity|The asset quantity is an unsigned integer representing how many units of that asset are stored on the output.|
|
88
91
|
|asset_amount| The asset amount is the value obtained by converting the asset quantity to the unit of divisibility that are defined in the Asset definition file. |
|
89
92
|
|asset_definition_url|The url of asset definition file.|
|
93
|
+
|proof_of_authenticity|The result of [Proof of Authenticity](https://github.com/OpenAssets/open-assets-protocol/blob/master/asset-definition-protocol.mediawiki#Proof_of_Authenticity) that is checked consistent with the subject in the SSL certificate. If the result is true, issuer is verified. If the result is false, issuer is not verified.||
|
90
94
|
|
91
95
|
* **get_balance**
|
92
96
|
Returns the balance in both bitcoin and colored coin assets for all of the addresses available in your Bitcoin Core wallet.
|
@@ -106,13 +110,15 @@ Returns the balance in both bitcoin and colored coin assets for all of the addre
|
|
106
110
|
"asset_id": "AWo3R89p5REmoSyMWB8AeUmud8456bRxZL",
|
107
111
|
"quantity": "81",
|
108
112
|
"amount": "20.7",
|
109
|
-
"asset_definition_url": "http://goo.gl/fS4mEj"
|
113
|
+
"asset_definition_url": "http://goo.gl/fS4mEj",
|
114
|
+
"proof_of_authenticity": false
|
110
115
|
},
|
111
116
|
{
|
112
117
|
"asset_id": "AJk2Gx5V67S2wNuwTK5hef3TpHunfbjcmX",
|
113
118
|
"quantity": "67",
|
114
119
|
"amount": "6.7",
|
115
|
-
"asset_definition_url": ""
|
120
|
+
"asset_definition_url": "",
|
121
|
+
"proof_of_authenticity": false
|
116
122
|
}
|
117
123
|
],
|
118
124
|
"account": "openassets-ruby"
|
@@ -130,6 +136,7 @@ Returns the balance in both bitcoin and colored coin assets for all of the addre
|
|
130
136
|
|asset_quantity|The asset quantity is an unsigned integer representing how many units of that asset are stored on the output.|
|
131
137
|
|asset_amount| The asset amount is the value obtained by converting the asset quantity to the unit of divisibility that are defined in the Asset definition file. |
|
132
138
|
|asset_definition_url|The url of asset definition file.|
|
139
|
+
|proof_of_authenticity|The result of [Proof of Authenticity](https://github.com/OpenAssets/open-assets-protocol/blob/master/asset-definition-protocol.mediawiki#Proof_of_Authenticity) that is checked consistent with the subject in the SSL certificate. If the result is true, issuer is verified. If the result is false, issuer is not verified.|
|
133
140
|
|account|The name of an account.|
|
134
141
|
|
135
142
|
* **issue_asset**
|
data/lib/openassets/api.rb
CHANGED
@@ -63,7 +63,8 @@ module OpenAssets
|
|
63
63
|
'asset_id' => asset_id,
|
64
64
|
'quantity' => outputs.inject(0) { |sum, o| sum + o.asset_quantity }.to_s,
|
65
65
|
'amount' => outputs.inject(0) { |sum, o| sum + o.asset_amount }.to_s,
|
66
|
-
'asset_definition_url' => outputs[0].asset_definition_url
|
66
|
+
'asset_definition_url' => outputs[0].asset_definition_url,
|
67
|
+
'proof_of_authenticity' => outputs[0].proof_of_authenticity
|
67
68
|
}
|
68
69
|
}
|
69
70
|
{
|
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'rest-client'
|
2
|
-
|
2
|
+
require 'httpclient'
|
3
3
|
module OpenAssets
|
4
4
|
module Protocol
|
5
5
|
|
6
6
|
# The Definition of Open Asset
|
7
7
|
class AssetDefinition
|
8
8
|
|
9
|
+
attr_accessor :asset_definition_url
|
10
|
+
|
9
11
|
attr_accessor :asset_ids
|
10
12
|
attr_accessor :name_short
|
11
13
|
attr_accessor :name
|
@@ -51,7 +53,9 @@ module OpenAssets
|
|
51
53
|
# @param[String] url The URL of Asset Definition.
|
52
54
|
def self.parse_url(url)
|
53
55
|
begin
|
54
|
-
parse_json(RestClient.get url, :accept => :json)
|
56
|
+
definition = parse_json(RestClient.get url, :accept => :json)
|
57
|
+
definition.asset_definition_url = url
|
58
|
+
definition
|
55
59
|
rescue => e
|
56
60
|
puts e
|
57
61
|
nil
|
@@ -75,6 +79,28 @@ module OpenAssets
|
|
75
79
|
result.update(key => instance_variable_get(var))
|
76
80
|
end
|
77
81
|
end
|
82
|
+
|
83
|
+
# Check Proof of authenticity.
|
84
|
+
# SSL certificate subject matches issuer.
|
85
|
+
def proof_of_authenticity
|
86
|
+
@proof_of_authenticity ||= calc_proof_of_authenticity
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
def calc_proof_of_authenticity
|
91
|
+
result = false
|
92
|
+
unless asset_definition_url.nil?
|
93
|
+
client = HTTPClient.new
|
94
|
+
response = client.get(asset_definition_url, :follow_redirect => true)
|
95
|
+
cert = response.peer_cert
|
96
|
+
unless cert.nil?
|
97
|
+
subject = response.peer_cert.subject.to_a
|
98
|
+
o = subject.find{|x|x[0] == 'O'}
|
99
|
+
result = true if !o.nil? && o.length > 2 && o[1] == issuer
|
100
|
+
end
|
101
|
+
end
|
102
|
+
result
|
103
|
+
end
|
78
104
|
end
|
79
105
|
|
80
106
|
end
|
@@ -48,6 +48,10 @@ module OpenAssets
|
|
48
48
|
@asset_definition.divisibility
|
49
49
|
end
|
50
50
|
|
51
|
+
def proof_of_authenticity
|
52
|
+
valid_asset_definition? ? @asset_definition.proof_of_authenticity : false
|
53
|
+
end
|
54
|
+
|
51
55
|
# convert to hash object.
|
52
56
|
def to_hash
|
53
57
|
address = script_to_address(@script)
|
@@ -60,7 +64,8 @@ module OpenAssets
|
|
60
64
|
'asset_quantity' => @asset_quantity.to_s,
|
61
65
|
'asset_amount' => asset_amount.to_s,
|
62
66
|
'account' => @account,
|
63
|
-
'asset_definition_url' => @asset_definition_url
|
67
|
+
'asset_definition_url' => @asset_definition_url,
|
68
|
+
'proof_of_authenticity' => proof_of_authenticity
|
64
69
|
}
|
65
70
|
end
|
66
71
|
|
data/lib/openassets/version.rb
CHANGED
data/openassets-ruby.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_runtime_dependency "bitcoin-ruby", "~> 0.0.7"
|
22
22
|
spec.add_runtime_dependency "ffi", "~>1.9.8"
|
23
23
|
spec.add_runtime_dependency "rest-client", "~>1.8.0"
|
24
|
+
spec.add_runtime_dependency "httpclient"
|
24
25
|
spec.add_development_dependency "bundler", "~> 1.9"
|
25
26
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
27
|
spec.add_development_dependency "rspec"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openassets-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- azuchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bitcoin-ruby
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.8.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: httpclient
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: bundler
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|