bigchaindb 0.0.5 → 0.0.6

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 +9 -10
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 032bede9af8f3733da574abdeb202d319d02c7e1
4
- data.tar.gz: a21acaffee7f993a1bdd64f3caf70c18dd40e02b
3
+ metadata.gz: 3e580cfe72ce29831bf5f59c7668acd7fcd43099
4
+ data.tar.gz: 4ab58de601a18bda19161e3ed6dc11da1c52b679
5
5
  SHA512:
6
- metadata.gz: 8aa8011c0fa0e32599b1b0008a40ec433e2004a77366ba5303636a3d1b1231ac5933409e7506962621dff57359a0f650842b83cb56dd0c6118d7e194c197386a
7
- data.tar.gz: eb79eaff388e0b5208e4adc8b07ec820f287f2b61e40e68e9d19524f4cad786d762eb5bbcd3ba7ee887cf0ffdc28015b760d489184d3409ab857440106f57d60
6
+ metadata.gz: 97a2d52b6ed5929683f2588b8b1a92f5a5d7702e639dbe8962373e4893d38765a3aa9e226657b9dcbd0111808654391c261b9c00bb41d264428c2f25b7834b21
7
+ data.tar.gz: 6fa188ae7253540457c2e31713aab14b10f1c07252e464b85ffd7327bcceaace2ca2aa761e7aa6a7ec88a8aee1e75e2f378e64ae17693ad87c70671b3ef8fe36
@@ -67,6 +67,9 @@ module Bdb
67
67
  if inputs.nil? || inputs.none?
68
68
  # ask IPDB for unspent outputs
69
69
  unspent = Bdb.unspent_outputs(ipdb, sender_pubkey)
70
+ if unspent.none?
71
+ return nil, "#{sender_pubkey} does not have any unspent outputs for asset #{asset_id}"
72
+ end
70
73
  unspent.each do |u|
71
74
  txn = JSON.parse(Bdb.get_transaction_by_id(ipdb, u["transaction_id"]).body)
72
75
  next unless txn["asset"]["id"] == asset_id
@@ -84,15 +87,13 @@ module Bdb
84
87
  outgoing_amount = 0
85
88
  receiver_pubkeys_amounts.each do |pa|
86
89
  if pa[:amount] <= 0
87
- puts "Invalid amount (<=0) found for #{pa[:pubkey]}"
88
- return nil
90
+ return nil, "Invalid amount (<=0) found for #{pa[:pubkey]}"
89
91
  end
90
92
  outgoing_amount += pa[:amount]
91
93
  end
92
94
 
93
95
  if outgoing_amount > input_amount
94
- puts "input_amount #{input_amount} < outgoing_amount #{outgoing_amount}"
95
- return nil
96
+ return nil, "input_amount #{input_amount} < outgoing_amount #{outgoing_amount}"
96
97
  end
97
98
  outputs = receiver_pubkeys_amounts.collect { |pa| Bdb.generate_output(pa[:pubkey],pa[:amount]) }
98
99
  if outgoing_amount < input_amount
@@ -109,21 +110,19 @@ module Bdb
109
110
  sleep(5)
110
111
  status_resp = get_transaction_status(ipdb, txn["id"])
111
112
  if (status_resp.code == 200) && JSON.parse(status_resp.body)["status"] == "valid"
112
- return {"transfer" => transfer, "txn" => txn}
113
+ return txn, "success"
113
114
  else
114
115
  puts "Trying again: #{status_resp.code} #{status_resp.body}"
115
116
  sleep(5)
116
117
  status_resp = get_transaction_status(ipdb, txn["id"])
117
118
  if (status_resp.code == 200) && JSON.parse(status_resp.body)["status"] == "valid"
118
- return {"transfer" => transfer, "txn" => txn}
119
+ return txn, "success"
119
120
  else
120
- puts "Tried twice but failed. #{status_resp.code} #{status_resp.body}"
121
- return nil
121
+ return nil, "Tried twice but failed. #{status_resp.code} #{status_resp.body}"
122
122
  end
123
123
  end
124
124
  else
125
- puts "Error in transfer_asset: #{resp.code} #{resp.body}"
126
- return nil
125
+ return nil, "Error in transfer_asset: #{resp.code} #{resp.body}"
127
126
  end
128
127
  end
129
128
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigchaindb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nilesh Trivedi