lib/bit_wallet/account.rb in bit_wallet-0.2.0 vs lib/bit_wallet/account.rb in bit_wallet-0.3.0
- old
+ new
@@ -46,9 +46,29 @@
client.listtransactions(self.name, count).map do |hash|
Transaction.new self.wallet, hash
end
end
+ def send_many(account_values={})
+ addresses_values = {}
+ account_values.each do |key, value|
+ address = key.respond_to?(:address) ? key.address : key
+ addresses_values[address] = value
+ end
+
+ txid = client.send_many(self.name,
+ addresses_values,
+ BitWallet.config.min_conf)
+ txid
+ rescue => e
+ error_message = JSON.parse(e.response).with_indifferent_access
+ if error_message[:error][:code] == -6
+ fail InsufficientFunds, "'#{self.name}' does not have enough funds"
+ else
+ raise e
+ end
+ end
+
private
def parse_error(response)
json_response = JSON.parse(response)
hash = json_response.with_indifferent_access