bin/bitcoin_wallet in bitcoin-ruby-0.0.5 vs bin/bitcoin_wallet in bitcoin-ruby-0.0.6
- old
+ new
@@ -67,11 +67,11 @@
optparse.parse!
cmd = ARGV.shift; cmdopts = ARGV
unless cmd
- exit puts optparse
+ puts optparse; exit
end
Bitcoin.network = options[:network]
options[:keystore] ||= "simple::file=~/.bitcoin-ruby/#{Bitcoin.network_name}/keys.json"
@@ -118,10 +118,12 @@
puts "#{script.get_pubkey} (pubkey)"
elsif script.is_hash160?
puts "#{script.get_address} (address)"
elsif script.is_multisig?
puts "#{script.get_addresses.join(' ')} (multisig)"
+ elsif script.is_op_return?
+ puts "#{script.get_op_return_data} (op_return)"
elsif script.is_namecoin?
puts "#{script.get_address} (#{script.type})"
print " " * 16
if script.is_name_new?
puts "Name Hash: #{script.get_namecoin_hash}"
@@ -139,11 +141,11 @@
unless $stdin.gets.chomp.downcase == 'y'
puts "Aborted."; exit
end
end
EM.run do
- Bitcoin::Network::CommandClient.connect(*options[:command].split(":")) do
+ Bitcoin::Network::CommandClient.connect(*options[:command]) do
on_connected do
request(:relay_tx, tx.to_payload.hth)
end
on_relay_tx do |res|
if res["success"]
@@ -309,12 +311,13 @@
(puts "Error creating tx."; exit) unless tx
send_transaction(storage, options, tx, true)
puts tx.hash
when "send"
- to = cmdopts[0].split(',').map do |pair|
- type, *addrs, value = pair.split(":")
+ to = cmdopts[0].split(',').map do |opts|
+ o = opts.split(":")
+ type, *addrs, value = *(o.size == 2 ? [:address, *o] : o)
value = val_str(value)
[type.to_sym, *addrs, value]
end
fee = val_str(cmdopts[1]) || 0
value = val_str value
@@ -380,11 +383,11 @@
unless $stdin.gets.chomp.downcase == 'y'
puts "Aborted."; exit
end
EM.run do
- EM.connect(*options[:command].split(":")) do |conn|
+ EM.connect(*options[:command]) do |conn|
conn.send_data(["relay_tx", tx.to_payload.unpack("H*")[0]].to_json)
def conn.receive_data(data)
(@buf ||= BufferedTokenizer.new("\x00")).extract(data).each do |packet|
res = JSON.load(packet)
puts "Transaction relayed: #{res[1]["hash"]}"
@@ -393,7 +396,7 @@
end
end
end
else
- puts "Unknown command."
+ puts "Unknown command. See --help for available commands."
end