glueby 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/glueby/contract/timestamp.rb +2 -3
- data/lib/glueby/utxo_provider.rb +15 -1
- data/lib/glueby/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd80045038551e7ffc41a613fb67401f3675c79098222e335359209070ff280a
|
4
|
+
data.tar.gz: f966a44bb7de60429e91d39681f63c6b827dbcb8806700cbfe6b5e961f013b2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e443a845c4d65eeba06c83d40617497b984f8a0c158e54debb1ac82d762af53ebba8073e8fc18855f93816370dc8969657bec8d8e95d5990df3fe50c9c7471a
|
7
|
+
data.tar.gz: 2c5f2670b48f6a1149052b239d89c626c323e21f222bd2deb201074b96d54ac935080624cb92a2399414aed03de44258a41da5b0fc4ecc5221d854ef201c06de
|
@@ -19,9 +19,8 @@ module Glueby
|
|
19
19
|
module_function
|
20
20
|
|
21
21
|
# @param [Glueby::Wallet] wallet
|
22
|
-
# @param [Array]
|
23
|
-
# @return [
|
24
|
-
# Return (pay-to-contract address, public key used for generating address)
|
22
|
+
# @param [Array] contents The data to be used for generating pay-to-contract address
|
23
|
+
# @return [pay-to-contract address, public key used for generating address]
|
25
24
|
def create_pay_to_contract_address(wallet, contents: nil)
|
26
25
|
pubkey = wallet.internal_wallet.create_pubkey.pubkey
|
27
26
|
# Calculate P + H(P || contents)G
|
data/lib/glueby/utxo_provider.rb
CHANGED
@@ -44,7 +44,7 @@ module Glueby
|
|
44
44
|
|
45
45
|
fee = fee_estimator.fee(dummy_tx(txb.build))
|
46
46
|
# The outputs need to be shuffled so that no utxos are spent twice as possible.
|
47
|
-
sum, outputs =
|
47
|
+
sum, outputs = collect_uncolored_outputs(wallet, fee + value)
|
48
48
|
|
49
49
|
outputs.each do |utxo|
|
50
50
|
txb.add_utxo({
|
@@ -73,6 +73,20 @@ module Glueby
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
+
def collect_uncolored_outputs(wallet, amount)
|
77
|
+
utxos = wallet.list_unspent.select { |o| !o[:color_id] && o[:amount] == @default_value }
|
78
|
+
utxos.shuffle!
|
79
|
+
|
80
|
+
utxos.inject([0, []]) do |sum, output|
|
81
|
+
new_sum = sum[0] + output[:amount]
|
82
|
+
new_outputs = sum[1] << output
|
83
|
+
return [new_sum, new_outputs] if new_sum >= amount
|
84
|
+
|
85
|
+
[new_sum, new_outputs]
|
86
|
+
end
|
87
|
+
raise Glueby::Contract::Errors::InsufficientFunds
|
88
|
+
end
|
89
|
+
|
76
90
|
def validate_config!
|
77
91
|
if UtxoProvider.config
|
78
92
|
utxo_pool_size = UtxoProvider.config[:utxo_pool_size]
|
data/lib/glueby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glueby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- azuchi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tapyrus
|
@@ -147,7 +147,7 @@ metadata:
|
|
147
147
|
homepage_uri: https://github.com/chaintope/glueby
|
148
148
|
source_code_uri: https://github.com/chaintope/glueby
|
149
149
|
changelog_uri: https://github.com/chaintope/glueby
|
150
|
-
post_install_message:
|
150
|
+
post_install_message:
|
151
151
|
rdoc_options: []
|
152
152
|
require_paths:
|
153
153
|
- lib
|
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
163
|
version: '0'
|
164
164
|
requirements: []
|
165
165
|
rubygems_version: 3.2.3
|
166
|
-
signing_key:
|
166
|
+
signing_key:
|
167
167
|
specification_version: 4
|
168
168
|
summary: A Ruby library of smart contracts that can be used on Tapyrus.
|
169
169
|
test_files: []
|