Created
June 22, 2015 19:14
-
-
Save NelsonBurton/0ab16e782096e1581053 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$:.unshift( File.expand_path("../../lib", __FILE__) ) | |
require 'bitcoin' | |
require 'ap' | |
require 'open-uri' | |
#specify to use the testnet network, could use :bitcoin to use bitcoin network | |
Bitcoin::network = :testnet3 | |
=begin | |
key = Bitcoin::generate_key | |
ap key | |
address = Bitcoin::pubkey_to_address(key[1]) | |
ap address | |
prev_tx = Bitcoin::Protocol::Tx.from_json_file('spec/bitcoin/fixtures/rawtx-testnet-e232e0055dbdca88bbaa79458683195a0b7c17c5b6c524a8d146721d4d4d652f.json') | |
=end | |
include Bitcoin::Builder | |
prev_hash = "13a8cf532bb0485feeb6ef4596e6476c182a92519dabb745eb4bde475f267475" | |
prev_out_index = 1 | |
prev_tx = Bitcoin::P::Tx.from_json(open("http://test.webbtc.com/tx/#{prev_hash}.json")) | |
keySender = Bitcoin::Key.new("9baf399f185279928a965b0c6fe1eb1c19a6292d1c8ffcf41dda8f234665782a") | |
ap Bitcoin::encode_base58("9baf399f185279928a965b0c6fe1eb1c19a6292d1c8ffcf41dda8f234665782a") | |
ap prev_tx.to_hash | |
toAddress = "mqRU7gKpUgrG9Budv7xnZyVmkWQd8XV7Hy" | |
ap Bitcoin::hash160_from_address("mnwpcUh76eLVYzEXCuh4fypzABEtygqFR5") | |
public_key = keySender.pub | |
#ap Bitcoin::verify_signature( hash , signature, public_key) | |
new_tx = build_tx do |t| | |
t.input do |i| | |
i.prev_out prev_tx | |
i.prev_out_index prev_out_index | |
i.signature_key keySender | |
end | |
t.output do |o| | |
o.value 70000000 # 70 million satoshi = .7 BTC | |
o.to toAddress | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment