Skip to content

Instantly share code, notes, and snippets.

@sigmike
Created September 28, 2016 19:15
Show Gist options
  • Save sigmike/4965adf60ead301bec3e8079084bcdc7 to your computer and use it in GitHub Desktop.
Save sigmike/4965adf60ead301bec3e8079084bcdc7 to your computer and use it in GitHub Desktop.
require 'json'
count = 10
slice = 0
output = "8JJE8rUrYCG2c7jCozYMtn147bw5WWmoMU"
unspent = JSON.load(File.read('unspent.json'))
txs = unspent["txs"][slice * count, count]
inputs, amount = txs.reduce([[], 0]) do |(inputs, amount), tx|
[
inputs + [{txid: tx["hash"], vout: tx["out_index"]}],
amount + tx["amount"],
]
end
puts [
"createrawtransaction",
"'#{inputs.to_json}'",
"'#{{output => amount}.to_json}'",
].join(" ")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment