openassets-ruby 0.1.3 → 0.1.4

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: e0eaaa8534a56f07b4c978704728bd12c7c9a9fb
4
- data.tar.gz: 79de745bf7f838e122780ffcf71ab6ada8c1bb15
3
+ metadata.gz: 0ebe922dafaddce5468b643e800caeebfac700c5
4
+ data.tar.gz: 238a308ab6eea7f04ed160d70468831ab5a2d6e2
5
5
  SHA512:
6
- metadata.gz: de391a3bd688f1f137035f76137a2bbeca849b391761309f9d029fb389879a18fd4089357b677153dc829f58360c5cfa36831d18228e5c562e730b5aea6f5e5a
7
- data.tar.gz: 113ecc06ae0872c566e87fae32d0b421925f411fb3f1d9c2d36c40ac1a31faa76285292013f58a598fcfde5f83ae766ef9a319fdd45b39de6ecfa4986db4137a
6
+ metadata.gz: 73085f2221a5753ca9d4463cf712a71efe175e2b77705723faac92fe89a64a6478af497814206e1b5d0aa7c56a936d58675093a4e9e7e194d815d80967057004
7
+ data.tar.gz: cd26cfd741e51acc8d4be4ba6631bbbad19956d52285550ba855630f7fd3b118aa7940531d4bb9d5cc1d3d6fbbc2e53de335aa2025d93abb443ab0e70cd83066
data/README.md CHANGED
@@ -48,12 +48,15 @@ Returns the balance in both bitcoin and colored coin assets for all of the addre
48
48
  Creates a transaction for issuing an asset.
49
49
  ```ruby
50
50
  # issue asset
51
- # api.issue_asset(<issuer open asset address>, <issuing asset quantity>, <metadata>, <to open asset address>, <fees (The fess in satoshis for the transaction. use 10000 satoshi if specified nil)>, <mode=('broadcast', 'signed', 'unsigned')>)
51
+ # api.issue_asset(<issuer open asset address>, <issuing asset quantity>, <metadata>, <to open asset address>, <fees (The fess in satoshis for the transaction. use 10000 satoshi if specified nil)>, <mode=('broadcast', 'signed', 'unsigned')>, <output_qty default value is 1.>)
52
52
 
53
53
  # example
54
54
  address = 'akEJwzkzEFau4t2wjbXoMs7MwtZkB8xixmH'
55
55
  api.issue_asset(address, 150, 'u=https://goo.gl/bmVEuw', address, nil, 'broadcast')
56
56
  ```
57
+ If specified output_qty, the issue output is divided by the number of output_qty.
58
+ Ex, amount = 125 and output_qty = 2, the marker output asset quantity is [62, 63] and issue TxOut is two.
59
+
57
60
  * **send_asset**
58
61
  Creates a transaction for sending an asset from the open asset address to another.
59
62
  ```ruby
@@ -22,7 +22,7 @@ module OpenAssets
22
22
  if @config[:provider] == 'bitcoind'
23
23
  @provider = Provider::BitcoinCoreProvider.new(@config[:rpc])
24
24
  else
25
- raise StandardError, 'specified unsupported provider.'
25
+ raise OpenAssets::Error, 'specified unsupported provider.'
26
26
  end
27
27
  end
28
28
 
@@ -96,12 +96,15 @@ module OpenAssets
96
96
  # 'broadcast' (default) for signing and broadcasting the transaction,
97
97
  # 'signed' for signing the transaction without broadcasting,
98
98
  # 'unsigned' for getting the raw unsigned transaction without broadcasting"""='broadcast'
99
- def issue_asset(from, amount, metadata = nil, to = nil, fees = nil, mode = 'broadcast')
99
+ # @param[Integer] output_qty The number of divides the issue output. Default value is 1.
100
+ # Ex. amount = 125 and output_qty = 2, asset quantity = [62, 63] and issue TxOut is two.
101
+ # @return[Bitcoin::Protocol::Tx] The Bitcoin::Protocol::Tx object.
102
+ def issue_asset(from, amount, metadata = nil, to = nil, fees = nil, mode = 'broadcast', output_qty = 1)
100
103
  to = from if to.nil?
101
104
  builder = OpenAssets::Transaction::TransactionBuilder.new(@config[:dust_limit])
102
105
  colored_outputs = get_unspent_outputs([oa_address_to_address(from)])
103
106
  issue_param = OpenAssets::Transaction::TransferParameters.new(colored_outputs, to, from, amount)
104
- tx = builder.issue_asset(issue_param, metadata, fees.nil? ? @config[:default_fees]: fees)
107
+ tx = builder.issue_asset(issue_param, metadata, fees.nil? ? @config[:default_fees]: fees, output_qty)
105
108
  tx = process_transaction(tx, mode)
106
109
  tx
107
110
  end
@@ -1,7 +1,7 @@
1
1
  module OpenAssets
2
2
  module Provider
3
3
 
4
- class ApiError < StandardError
4
+ class ApiError < OpenAssets::Error
5
5
 
6
6
  end
7
7
 
@@ -1,7 +1,7 @@
1
1
  module OpenAssets
2
2
  module Transaction
3
3
 
4
- class TransactionBuildError < StandardError
4
+ class TransactionBuildError < OpenAssets::Error
5
5
 
6
6
  end
7
7
 
@@ -16,7 +16,7 @@ module OpenAssets
16
16
  # @param [bytes] metadata The metadata to be embedded in the transaction.
17
17
  # @param [Integer] fees The fees to include in the transaction.
18
18
  # @return[Bitcoin:Protocol:Tx] An unsigned transaction for issuing asset.
19
- def issue_asset(issue_spec, metadata, fees)
19
+ def issue_asset(issue_spec, metadata, fees, output_qty = 1)
20
20
  inputs, total_amount =
21
21
  TransactionBuilder.collect_uncolored_outputs(issue_spec.unspent_outputs, 2 * @amount + fees)
22
22
  tx = Bitcoin::Protocol::Tx.new
@@ -29,8 +29,16 @@ module OpenAssets
29
29
  issue_address = oa_address_to_address(issue_spec.to_script)
30
30
  from_address = oa_address_to_address(issue_spec.change_script)
31
31
  validate_address([issue_address, from_address])
32
- tx.add_out(create_colored_output(issue_address))
33
- tx.add_out(create_marker_output([issue_spec.amount], metadata))
32
+ asset_quantities =[]
33
+ output_qty.times {|index|
34
+ if index == output_qty - 1
35
+ asset_quantities[index] = issue_spec.amount / output_qty + issue_spec.amount % output_qty
36
+ else
37
+ asset_quantities[index] = issue_spec.amount / output_qty
38
+ end
39
+ tx.add_out(create_colored_output(issue_address))
40
+ }
41
+ tx.add_out(create_marker_output(asset_quantities, metadata))
34
42
  tx.add_out(create_uncolored_output(from_address, total_amount - @amount - fees))
35
43
  tx
36
44
  end
@@ -1,3 +1,3 @@
1
1
  module OpenAssets
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
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.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - azuchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-11 00:00:00.000000000 Z
11
+ date: 2015-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bitcoin-ruby