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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d4b61f5231ce9ddde842d4269de8a9b683c7d0e
4
- data.tar.gz: a8231c78393699625f5a7c03be616d0586c18b0f
3
+ metadata.gz: 55f541af3749707d21e550e2fa82882062a203f1
4
+ data.tar.gz: 00909d9fb3f0eef92d696b1fd97ed34554c5c805
5
5
  SHA512:
6
- metadata.gz: 6e54c5aa9436b2528065b9a77da06cae8a123dd8b38478561ca4f4df9d89dabce2a41bd0020e6326ccd290c03292f8fccdb3c309a6c8b657aa85e48ad21c7c88
7
- data.tar.gz: a49134f3c11dd99c874f1578dd4864d1e1b700309c5c30058991a2a4fe98b2c13d5b153dca0df8f0e524345f80753cd30ff7f13bd4d2276ba3c08b00417bf599
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.
@@ -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::SendAssetParams]] send_asset_params The send Asset information(asset_id, amount, to).
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' => @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
- colored_outputs, total_amount = TransactionBuilder.collect_colored_outputs(transfer_spec.unspent_outputs, asset_id, transfer_spec.amount)
138
- inputs = inputs + colored_outputs
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
- # add asset transfer output
141
- transfer_spec.split_output_amount.each {|amount|
142
- outputs << create_colored_output(oa_address_to_address(transfer_spec.to_script))
143
- asset_quantities << amount
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 > transfer_spec.amount
148
- outputs << create_colored_output(oa_address_to_address(transfer_spec.change_script))
149
- asset_quantities << (total_amount - transfer_spec.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
 
@@ -1,3 +1,3 @@
1
1
  module OpenAssets
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.3'
3
3
  end
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.1
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-01-26 00:00:00.000000000 Z
11
+ date: 2016-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bitcoin-ruby