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 +4 -4
- data/README.md +4 -1
- data/lib/openassets/api.rb +6 -3
- data/lib/openassets/provider/api_error.rb +1 -1
- data/lib/openassets/transaction/transaction_build_error.rb +1 -1
- data/lib/openassets/transaction/transaction_builder.rb +11 -3
- 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: 0ebe922dafaddce5468b643e800caeebfac700c5
|
4
|
+
data.tar.gz: 238a308ab6eea7f04ed160d70468831ab5a2d6e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/openassets/api.rb
CHANGED
@@ -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
|
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
|
-
|
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
|
@@ -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
|
-
|
33
|
-
|
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
|
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.1.
|
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
|
+
date: 2015-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bitcoin-ruby
|