bigchaindb 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bigchaindb.rb +15 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d8abc42966871eb1e5cc52e7fa076f71f4db173
4
- data.tar.gz: c22dcf61a6a391cad1ac6f9baa0dbd83462c1402
3
+ metadata.gz: 032bede9af8f3733da574abdeb202d319d02c7e1
4
+ data.tar.gz: a21acaffee7f993a1bdd64f3caf70c18dd40e02b
5
5
  SHA512:
6
- metadata.gz: fc9ce5d7442eb4c78c0d198acacf5c38362a7bb721e0f47c7b0050d93a512242ca5a241c3275f8cd9185adba81146dab767e498eb244f1aaca1f44a49ddf3aea
7
- data.tar.gz: 0fbf4e30a803c3de846100972117cd924fdd4008f24ee111e04bd95190175768aaee6d14ccaaf8c420b6d102c376f3c29fbf4d4b9d20789f5b4791bbf96f6272
6
+ metadata.gz: 8aa8011c0fa0e32599b1b0008a40ec433e2004a77366ba5303636a3d1b1231ac5933409e7506962621dff57359a0f650842b83cb56dd0c6118d7e194c197386a
7
+ data.tar.gz: eb79eaff388e0b5208e4adc8b07ec820f287f2b61e40e68e9d19524f4cad786d762eb5bbcd3ba7ee887cf0ffdc28015b760d489184d3409ab857440106f57d60
@@ -59,7 +59,7 @@ module Bdb
59
59
  JSON.parse(resp.body)
60
60
  end
61
61
 
62
- def self.transfer_asset(ipdb, receiver_pubkey, sender_pubkey, sender_privkey, inputs, amount, asset_id, metadata = {"ts"=> Time.now.to_s})
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
- if amount > input_amount
85
- puts "input_amount #{input_amount} < amount #{amount}"
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 = [Bdb.generate_output(receiver_pubkey,amount)]
89
- if amount < input_amount
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 - 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
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-09-05 00:00:00.000000000 Z
11
+ date: 2017-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty