openassets-ruby 0.3.1 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/lib/openassets/api.rb +1 -1
- data/lib/openassets/protocol/transaction_output.rb +5 -1
- data/lib/openassets/transaction/transaction_builder.rb +18 -10
- data/lib/openassets/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55f541af3749707d21e550e2fa82882062a203f1
|
4
|
+
data.tar.gz: 00909d9fb3f0eef92d696b1fd97ed34554c5c805
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 748937bd4d011a5ee5b62a3527c032a230ad154812526fc0dccf01127dca1213c7bd90fd21a03d4c37c05b254f3a3c1a4760d30237b052a11bb20432d18aa3df
|
7
|
+
data.tar.gz: 5c97eb9169a61a16b645fcf697d63f09fcefa2fd78c96b64208e6d4d9c81fc5b202f089a1f7b3b3b919224ccace384a9f0b575b2f3454fbfc39ac21e5e6b8293
|
data/README.md
CHANGED
@@ -215,7 +215,6 @@ Creates a transaction for sending **multiple** asset from the open asset address
|
|
215
215
|
tx = api.send_assets(from, params)
|
216
216
|
```
|
217
217
|
|
218
|
-
|
219
218
|
## Command line interface
|
220
219
|
|
221
220
|
Openassets-ruby comes with a `openassets` command line interface that allows easy interaction with OpenAssets.
|
data/lib/openassets/api.rb
CHANGED
@@ -122,7 +122,7 @@ module OpenAssets
|
|
122
122
|
|
123
123
|
# Creates a transaction for sending multiple asset from an address to another.
|
124
124
|
# @param[String] from The open asset address to send the asset from.
|
125
|
-
# @param[Array[OpenAssets::
|
125
|
+
# @param[Array[OpenAssets::SendAssetParam]] send_asset_params The send Asset information(asset_id, amount, to).
|
126
126
|
# @param[Integer] fees The fess in satoshis for the transaction.
|
127
127
|
# @param[String] mode 'broadcast' (default) for signing and broadcasting the transaction,
|
128
128
|
# 'signed' for signing the transaction without broadcasting,
|
@@ -63,12 +63,16 @@ module OpenAssets
|
|
63
63
|
'asset_id' => @asset_id,
|
64
64
|
'asset_quantity' => @asset_quantity.to_s,
|
65
65
|
'asset_amount' => asset_amount.to_s,
|
66
|
-
'account' =>
|
66
|
+
'account' => account,
|
67
67
|
'asset_definition_url' => @asset_definition_url,
|
68
68
|
'proof_of_authenticity' => proof_of_authenticity
|
69
69
|
}
|
70
70
|
end
|
71
71
|
|
72
|
+
def account
|
73
|
+
@account.nil? ? nil : @account.encode('ISO-8859-1').force_encoding('UTF-8')
|
74
|
+
end
|
75
|
+
|
72
76
|
private
|
73
77
|
|
74
78
|
@@definition_cache = {}
|
@@ -133,20 +133,28 @@ module OpenAssets
|
|
133
133
|
inputs = []
|
134
134
|
outputs = []
|
135
135
|
asset_quantities = []
|
136
|
+
|
137
|
+
asset_based_specs = {}
|
136
138
|
asset_transfer_specs.each{|asset_id, transfer_spec|
|
137
|
-
|
138
|
-
|
139
|
+
asset_based_specs[asset_id] = [] unless asset_based_specs.has_key?(asset_id)
|
140
|
+
asset_based_specs[asset_id] << transfer_spec
|
141
|
+
}
|
139
142
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
143
|
+
asset_based_specs.each{|asset_id, transfer_specs|
|
144
|
+
transfer_amount = transfer_specs.inject(0){|sum, s| sum + s.amount}
|
145
|
+
colored_outputs, total_amount = TransactionBuilder.collect_colored_outputs(transfer_specs[0].unspent_outputs, asset_id, transfer_amount)
|
146
|
+
inputs = inputs + colored_outputs
|
147
|
+
transfer_specs.each{|spec|
|
148
|
+
# add asset transfer output
|
149
|
+
spec.split_output_amount.each {|amount|
|
150
|
+
outputs << create_colored_output(oa_address_to_address(spec.to_script))
|
151
|
+
asset_quantities << amount
|
152
|
+
}
|
144
153
|
}
|
145
|
-
|
146
154
|
# add the rest of the asset to the origin address
|
147
|
-
if total_amount >
|
148
|
-
outputs << create_colored_output(oa_address_to_address(
|
149
|
-
asset_quantities << (total_amount -
|
155
|
+
if total_amount > transfer_amount
|
156
|
+
outputs << create_colored_output(oa_address_to_address(transfer_specs[0].change_script))
|
157
|
+
asset_quantities << (total_amount - transfer_amount)
|
150
158
|
end
|
151
159
|
}
|
152
160
|
|
data/lib/openassets/version.rb
CHANGED
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- azuchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bitcoin-ruby
|