bigchaindb 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bigchaindb.rb +15 -6
- 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: 032bede9af8f3733da574abdeb202d319d02c7e1
|
4
|
+
data.tar.gz: a21acaffee7f993a1bdd64f3caf70c18dd40e02b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8aa8011c0fa0e32599b1b0008a40ec433e2004a77366ba5303636a3d1b1231ac5933409e7506962621dff57359a0f650842b83cb56dd0c6118d7e194c197386a
|
7
|
+
data.tar.gz: eb79eaff388e0b5208e4adc8b07ec820f287f2b61e40e68e9d19524f4cad786d762eb5bbcd3ba7ee887cf0ffdc28015b760d489184d3409ab857440106f57d60
|
data/lib/bigchaindb.rb
CHANGED
@@ -59,7 +59,7 @@ module Bdb
|
|
59
59
|
JSON.parse(resp.body)
|
60
60
|
end
|
61
61
|
|
62
|
-
def self.transfer_asset(ipdb,
|
62
|
+
def self.transfer_asset(ipdb, receiver_pubkeys_amounts, sender_pubkey, sender_privkey, inputs, asset_id, metadata = {"ts"=> Time.now.to_s})
|
63
63
|
asset = { "id" => asset_id}
|
64
64
|
new_inputs = []
|
65
65
|
input_amount = 0
|
@@ -81,14 +81,23 @@ module Bdb
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
|
85
|
-
|
84
|
+
outgoing_amount = 0
|
85
|
+
receiver_pubkeys_amounts.each do |pa|
|
86
|
+
if pa[:amount] <= 0
|
87
|
+
puts "Invalid amount (<=0) found for #{pa[:pubkey]}"
|
88
|
+
return nil
|
89
|
+
end
|
90
|
+
outgoing_amount += pa[:amount]
|
91
|
+
end
|
92
|
+
|
93
|
+
if outgoing_amount > input_amount
|
94
|
+
puts "input_amount #{input_amount} < outgoing_amount #{outgoing_amount}"
|
86
95
|
return nil
|
87
96
|
end
|
88
|
-
outputs =
|
89
|
-
if
|
97
|
+
outputs = receiver_pubkeys_amounts.collect { |pa| Bdb.generate_output(pa[:pubkey],pa[:amount]) }
|
98
|
+
if outgoing_amount < input_amount
|
90
99
|
# left-over amount should be transferred back to sender
|
91
|
-
outputs.push(Bdb.generate_output(sender_pubkey,input_amount -
|
100
|
+
outputs.push(Bdb.generate_output(sender_pubkey,input_amount - outgoing_amount))
|
92
101
|
end
|
93
102
|
|
94
103
|
transfer = Bdb.transfer_txn(new_inputs, outputs, asset, metadata)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bigchaindb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nilesh Trivedi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|