bitcoin-ruby 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.travis.yml +2 -7
- data/COPYING +1 -1
- data/Gemfile +2 -6
- data/Gemfile.lock +34 -0
- data/README.rdoc +16 -68
- data/Rakefile +3 -6
- data/bin/bitcoin_shell +0 -1
- data/{concept-examples/blockchain-pow.rb → examples/concept-blockchain-pow.rb} +0 -0
- data/lib/bitcoin.rb +350 -296
- data/lib/bitcoin/builder.rb +3 -1
- data/lib/bitcoin/connection.rb +2 -1
- data/lib/bitcoin/contracthash.rb +76 -0
- data/lib/bitcoin/dogecoin.rb +97 -0
- data/lib/bitcoin/ffi/bitcoinconsensus.rb +74 -0
- data/lib/bitcoin/ffi/openssl.rb +98 -2
- data/lib/bitcoin/ffi/secp256k1.rb +144 -0
- data/lib/bitcoin/key.rb +12 -2
- data/lib/bitcoin/logger.rb +3 -12
- data/lib/bitcoin/protocol/block.rb +3 -9
- data/lib/bitcoin/protocol/parser.rb +6 -2
- data/lib/bitcoin/protocol/tx.rb +44 -13
- data/lib/bitcoin/protocol/txin.rb +4 -2
- data/lib/bitcoin/protocol/txout.rb +2 -2
- data/lib/bitcoin/script.rb +212 -37
- data/lib/bitcoin/trezor/mnemonic.rb +130 -0
- data/lib/bitcoin/version.rb +1 -1
- data/spec/bitcoin/bitcoin_spec.rb +32 -3
- data/spec/bitcoin/builder_spec.rb +18 -0
- data/spec/bitcoin/contracthash_spec.rb +45 -0
- data/spec/bitcoin/dogecoin_spec.rb +176 -0
- data/spec/bitcoin/ffi_openssl.rb +45 -0
- data/spec/bitcoin/fixtures/156e6e1b84c5c3bd3a0927b25e4119fadce6e6d5186f363317511d1d680fae9a.json +24 -0
- data/spec/bitcoin/fixtures/8d0b238a06b5a70be75d543902d02d7a514d68d3252a949a513865ac3538874c.json +24 -0
- data/spec/bitcoin/fixtures/coinbase-toshi.json +33 -0
- data/spec/bitcoin/fixtures/coinbase.json +24 -0
- data/spec/bitcoin/fixtures/dogecoin-block-60323982f9c5ff1b5a954eac9dc1269352835f47c2c5222691d80f0d50dcf053.bin +0 -0
- data/spec/bitcoin/fixtures/rawtx-01-toshi.json +46 -0
- data/spec/bitcoin/fixtures/rawtx-02-toshi.json +46 -0
- data/spec/bitcoin/fixtures/rawtx-03-toshi.json +73 -0
- data/spec/bitcoin/fixtures/rawtx-testnet-04fdc38d6722ab4b12d79113fc4b2896bdcc5169710690ee4e78541b98e467b4.bin +0 -0
- data/spec/bitcoin/fixtures/rawtx-testnet-0b294c7d11dd21bcccb8393e6744fed7d4d1981a08c00e3e88838cc421f33c9f.bin +0 -0
- data/spec/bitcoin/fixtures/rawtx-testnet-3bc52ac063291ad92d95ddda5fd776a342083b95607ad32ed8bc6f8f7d30449e.bin +0 -0
- data/spec/bitcoin/fixtures/rawtx-testnet-6f0bbdd4e71a8af4305018d738184df32dbb6f27284fdebd5b56d16947f7c181.bin +0 -0
- data/spec/bitcoin/fixtures/rawtx-testnet-a7c9b06e275e8674cc19a5f7d3e557c72c6d93576e635b33212dbe08ab7cdb60.bin +0 -0
- data/spec/bitcoin/fixtures/rawtx-testnet-f80acbd2f594d04ddb0e1cacba662132104909157dff526935a3c88abe9201a5.bin +0 -0
- data/spec/bitcoin/protocol/block_spec.rb +0 -22
- data/spec/bitcoin/protocol/tx_spec.rb +145 -2
- data/spec/bitcoin/script/script_spec.rb +282 -0
- data/spec/bitcoin/secp256k1_spec.rb +48 -0
- data/spec/bitcoin/spec_helper.rb +0 -51
- data/spec/bitcoin/trezor/mnemonic_spec.rb +161 -0
- metadata +48 -98
- data/bin/bitcoin_dns_seed +0 -130
- data/bin/bitcoin_gui +0 -80
- data/bin/bitcoin_node +0 -153
- data/bin/bitcoin_node_cli +0 -81
- data/bin/bitcoin_wallet +0 -402
- data/doc/CONFIG.rdoc +0 -66
- data/doc/EXAMPLES.rdoc +0 -13
- data/doc/NAMECOIN.rdoc +0 -34
- data/doc/NODE.rdoc +0 -225
- data/doc/STORAGE.rdoc +0 -33
- data/doc/WALLET.rdoc +0 -102
- data/examples/balance.rb +0 -66
- data/examples/forwarder.rb +0 -73
- data/examples/index_nhash.rb +0 -24
- data/examples/reindex_p2sh_addrs.rb +0 -44
- data/examples/relay_tx.rb +0 -22
- data/examples/verify_tx.rb +0 -57
- data/lib/bitcoin/config.rb +0 -58
- data/lib/bitcoin/gui/addr_view.rb +0 -44
- data/lib/bitcoin/gui/bitcoin-ruby.png +0 -0
- data/lib/bitcoin/gui/bitcoin-ruby.svg +0 -80
- data/lib/bitcoin/gui/conn_view.rb +0 -38
- data/lib/bitcoin/gui/connection.rb +0 -70
- data/lib/bitcoin/gui/em_gtk.rb +0 -30
- data/lib/bitcoin/gui/gui.builder +0 -1643
- data/lib/bitcoin/gui/gui.rb +0 -292
- data/lib/bitcoin/gui/helpers.rb +0 -115
- data/lib/bitcoin/gui/tree_view.rb +0 -84
- data/lib/bitcoin/gui/tx_view.rb +0 -69
- data/lib/bitcoin/namecoin.rb +0 -280
- data/lib/bitcoin/network/command_client.rb +0 -104
- data/lib/bitcoin/network/command_handler.rb +0 -570
- data/lib/bitcoin/network/connection_handler.rb +0 -387
- data/lib/bitcoin/network/node.rb +0 -565
- data/lib/bitcoin/storage/dummy/dummy_store.rb +0 -179
- data/lib/bitcoin/storage/models.rb +0 -171
- data/lib/bitcoin/storage/sequel/migrations.rb +0 -99
- data/lib/bitcoin/storage/sequel/migrations/001_base_schema.rb +0 -52
- data/lib/bitcoin/storage/sequel/migrations/002_tx.rb +0 -45
- data/lib/bitcoin/storage/sequel/migrations/003_change_txin_script_sig_to_blob.rb +0 -18
- data/lib/bitcoin/storage/sequel/migrations/004_change_txin_prev_out_to_blob.rb +0 -18
- data/lib/bitcoin/storage/sequel/migrations/005_change_tx_hash_to_bytea.rb +0 -14
- data/lib/bitcoin/storage/sequel/migrations/006_add_tx_nhash.rb +0 -31
- data/lib/bitcoin/storage/sequel/migrations/007_add_prev_out_index_index.rb +0 -16
- data/lib/bitcoin/storage/sequel/migrations/008_add_txin_p2sh_type.rb +0 -31
- data/lib/bitcoin/storage/sequel/migrations/009_add_addrs_type.rb +0 -56
- data/lib/bitcoin/storage/sequel/sequel_store.rb +0 -551
- data/lib/bitcoin/storage/storage.rb +0 -517
- data/lib/bitcoin/storage/utxo/migrations/001_base_schema.rb +0 -52
- data/lib/bitcoin/storage/utxo/migrations/002_utxo.rb +0 -18
- data/lib/bitcoin/storage/utxo/migrations/003_update_indices.rb +0 -14
- data/lib/bitcoin/storage/utxo/migrations/004_add_addrs_type.rb +0 -14
- data/lib/bitcoin/storage/utxo/utxo_store.rb +0 -374
- data/lib/bitcoin/validation.rb +0 -400
- data/lib/bitcoin/wallet/coinselector.rb +0 -33
- data/lib/bitcoin/wallet/keygenerator.rb +0 -77
- data/lib/bitcoin/wallet/keystore.rb +0 -207
- data/lib/bitcoin/wallet/txdp.rb +0 -118
- data/lib/bitcoin/wallet/wallet.rb +0 -281
- data/spec/bitcoin/fixtures/freicoin-block-000000005d231b285e63af83edae2d8f5e50e70d396468643092b9239fd3be3c.bin +0 -0
- data/spec/bitcoin/fixtures/freicoin-block-000000005d231b285e63af83edae2d8f5e50e70d396468643092b9239fd3be3c.json +0 -43
- data/spec/bitcoin/fixtures/freicoin-genesis-block-000000005b1e3d23ecfd2dd4a6e1a35238aa0392c0a8528c40df52376d7efe2c.bin +0 -0
- data/spec/bitcoin/fixtures/freicoin-genesis-block-000000005b1e3d23ecfd2dd4a6e1a35238aa0392c0a8528c40df52376d7efe2c.json +0 -67
- data/spec/bitcoin/namecoin_spec.rb +0 -182
- data/spec/bitcoin/node/command_api_spec.rb +0 -663
- data/spec/bitcoin/storage/models_spec.rb +0 -104
- data/spec/bitcoin/storage/reorg_spec.rb +0 -236
- data/spec/bitcoin/storage/storage_spec.rb +0 -387
- data/spec/bitcoin/storage/validation_spec.rb +0 -300
- data/spec/bitcoin/wallet/coinselector_spec.rb +0 -38
- data/spec/bitcoin/wallet/keygenerator_spec.rb +0 -69
- data/spec/bitcoin/wallet/keystore_spec.rb +0 -190
- data/spec/bitcoin/wallet/txdp_spec.rb +0 -76
- data/spec/bitcoin/wallet/wallet_spec.rb +0 -238
@@ -1,76 +0,0 @@
|
|
1
|
-
# encoding: ascii-8bit
|
2
|
-
|
3
|
-
require_relative '../spec_helper'
|
4
|
-
include Bitcoin
|
5
|
-
include Bitcoin::Wallet
|
6
|
-
include MiniTest
|
7
|
-
|
8
|
-
describe "Bitcoin::Wallet::TxDP" do
|
9
|
-
|
10
|
-
before do
|
11
|
-
Bitcoin.network = :testnet
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should parse txdp" do
|
15
|
-
txt = fixtures_file("txdp-1.txt")
|
16
|
-
txdp = TxDP.parse(txt)
|
17
|
-
txdp.id.should == "3fX59xPj"
|
18
|
-
txdp.tx.size.should == 3
|
19
|
-
txdp.tx.first.hash.should ==
|
20
|
-
"2aa1938705066d0f9988923000ee75d5fc728b92b9739b71f94c139e5a729527"
|
21
|
-
txdp.inputs.size.should == 2
|
22
|
-
end
|
23
|
-
|
24
|
-
it "should parse unsigned txdp" do
|
25
|
-
txt = fixtures_file("txdp-2-unsigned.txt")
|
26
|
-
txdp = TxDP.parse(txt)
|
27
|
-
txdp.id.should == "7Q74Wkre"
|
28
|
-
txdp.tx.size.should == 2
|
29
|
-
txdp.inputs.size.should == 1
|
30
|
-
txdp.inputs.first[1].should == nil
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should parse signed txdp" do
|
34
|
-
txt = fixtures_file("txdp-2-signed.txt")
|
35
|
-
txdp = TxDP.parse(txt)
|
36
|
-
txdp.id.should == "7Q74Wkre"
|
37
|
-
txdp.tx.size.should == 2
|
38
|
-
txdp.inputs.size.should == 1
|
39
|
-
txdp.inputs.first[1].should ==[["mnheKkGdmw8d1fUV15XZbfmLR6AjQjVthy", "49304602210087bc1ff770c6cb3c7e47b9a3acb7dce678c16350f29acaa92e4ab231692256cf0221002da46fc1f39e132e726dea46a6e87e4278e85d36ccd393e39e931b89d55fc3a2014104955ec5646652d1b5bb14b2f867ef8879bcf224f1eab01072147fdfe0992440a234b36792937a23df736e8430613da6f0466bfc5505f2ad41b056131b7af13086"]]
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should serialize unsigned txdp" do
|
43
|
-
txt = fixtures_file("txdp-2-unsigned.txt")
|
44
|
-
txdp = TxDP.parse(txt)
|
45
|
-
txdp.serialize.should == txt.strip
|
46
|
-
end
|
47
|
-
|
48
|
-
it "should serialize signed txdp" do
|
49
|
-
txt = fixtures_file("txdp-2-signed.txt")
|
50
|
-
txdp = TxDP.parse(txt)
|
51
|
-
txdp.serialize.should == txt.strip
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should create txdp from tx" do
|
55
|
-
tx1 = Bitcoin::P::Tx.from_json(fixtures_file("rawtx-05.json"))
|
56
|
-
tx2 = Bitcoin::P::Tx.from_json(fixtures_file("rawtx-04.json"))
|
57
|
-
sig = tx2.in[0].script_sig
|
58
|
-
tx2.in[0].script_sig_length = 0
|
59
|
-
tx2.in[0].script_sig = ""
|
60
|
-
txdp = TxDP.new([tx2, tx1])
|
61
|
-
txdp.id.should != nil
|
62
|
-
txdp.inputs.size.should == 1
|
63
|
-
txdp.inputs.first[0].should == 5e9
|
64
|
-
txt = txdp.serialize
|
65
|
-
|
66
|
-
txt.should =~ /--BEGIN-TRANSACTION-#{txdp.id}--/
|
67
|
-
txt.should =~ /^_TXDIST_fabfb5da_#{txdp.id}_00cb$/
|
68
|
-
txt.should =~ /^_TXINPUT_00_50.00000000$/
|
69
|
-
txt.should =~ /--END-TRANSACTION-#{txdp.id}--/
|
70
|
-
|
71
|
-
txdp.add_sig(0, tx1.out[0].value, "mh8YhPYEAYs3E7EVyKtB5xrcfMExkkdEMF", sig)
|
72
|
-
txt = txdp.serialize
|
73
|
-
txt.should =~ /^_SIG_mh8YhPYEAYs3E7EVyKtB5xrcfMExkkdEMF_00_0048$/
|
74
|
-
end
|
75
|
-
|
76
|
-
end
|
@@ -1,238 +0,0 @@
|
|
1
|
-
# encoding: ascii-8bit
|
2
|
-
|
3
|
-
require_relative '../spec_helper'
|
4
|
-
require 'json'
|
5
|
-
require 'fileutils'
|
6
|
-
include MiniTest
|
7
|
-
include Bitcoin
|
8
|
-
include Bitcoin::Wallet
|
9
|
-
|
10
|
-
def txout_mock(value, next_in = true, in_block = true)
|
11
|
-
tx, txout = Mock.new, Mock.new
|
12
|
-
tx.expect(:get_block, in_block)
|
13
|
-
4.times { txout.expect(:value, value) }
|
14
|
-
2.times { txout.expect(:get_next_in, next_in) }
|
15
|
-
6.times { txout.expect(:hash, [value, next_in].hash) }
|
16
|
-
txout.expect(:eql?, false, [1])
|
17
|
-
txout.expect(:==, false, [1])
|
18
|
-
txout.expect(:get_tx, tx)
|
19
|
-
end
|
20
|
-
|
21
|
-
describe Bitcoin::Wallet::Wallet do
|
22
|
-
|
23
|
-
class DummyKeyStore
|
24
|
-
|
25
|
-
def initialize keys
|
26
|
-
@keys = keys.map{|k| { key: k, addr: k.addr } }
|
27
|
-
end
|
28
|
-
|
29
|
-
def key(addr)
|
30
|
-
@keys.select{|k| k[:key].addr == addr }.first
|
31
|
-
end
|
32
|
-
|
33
|
-
def keys
|
34
|
-
@keys
|
35
|
-
end
|
36
|
-
|
37
|
-
def new_key
|
38
|
-
k=Bitcoin::Key.generate
|
39
|
-
@keys << { key: k, addr: k.addr}
|
40
|
-
@keys[-1]
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
before do
|
45
|
-
Bitcoin.network = :bitcoin
|
46
|
-
@storage = Mock.new
|
47
|
-
@key = Key.from_base58('5J2hn1E8KEXmQn5gqykzKotyCcHbKrVbe8fjegsfVXRdv6wwon8')
|
48
|
-
@addr = '1M89ZeWtmZmATzE3b6PHTBi8c7tGsg5xpo'
|
49
|
-
#@key2 = Key.from_base58('5KK9Lw8gtNd4kcaXQJmkwcmNy8Y5rLGm49RqhcYAb7qRhWxaWMJ')
|
50
|
-
#@addr2 = '134A4Bi8jN5V2KjkwmXUHjokDqdyqZ778J'
|
51
|
-
#@key3 = Key.from_base58('5JFcJByQvwYnWjQ2RHTTu6LLGiBj9oPQYsHqKWuKLDVAvv4cQ7E')
|
52
|
-
#@addr3 = '1EnrPVaRiRgrs1D7pujYZNN1N6iD9unZV6'
|
53
|
-
|
54
|
-
@storage.expect(:add_watched_address, [], [@addr])
|
55
|
-
|
56
|
-
keystore_data = [{:addr => @key.addr, :priv => @key.priv, :pub => @key.pub}]
|
57
|
-
file_stub = StringIO.new
|
58
|
-
file_stub.write(keystore_data.to_json); file_stub.rewind
|
59
|
-
@keystore = SimpleKeyStore.new(file: file_stub)
|
60
|
-
@selector = MiniTest::Mock.new
|
61
|
-
@wallet = Wallet.new(@storage, @keystore, @selector)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should get total balance" do
|
65
|
-
@storage.expect(:class, Bitcoin::Storage::Backends::SequelStore, [])
|
66
|
-
@storage.expect(:get_txouts_for_address, [], [@addr])
|
67
|
-
2.times { @storage.expect(:class, Bitcoin::Storage::Backends::SequelStore, []) }
|
68
|
-
@wallet.get_balance.should == 0
|
69
|
-
|
70
|
-
@storage.expect(:get_txouts_for_address, [txout_mock(5000, nil)], [@addr])
|
71
|
-
@wallet.get_balance.should == 5000
|
72
|
-
|
73
|
-
@storage.expect(:get_txouts_for_address, [txout_mock(5000, true), txout_mock(1000, nil)],
|
74
|
-
[@addr])
|
75
|
-
@wallet.get_balance.should == 1000
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should get all addrs" do
|
79
|
-
@wallet.addrs.should == [@addr]
|
80
|
-
@wallet.addrs.size.should == 1
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should list all addrs with balances" do
|
84
|
-
@storage.expect(:get_balance, 0, ['dcbc93494b38ae96b14b1cc080d2acb514b7e955'])
|
85
|
-
list = @wallet.list
|
86
|
-
list.size.should == 1
|
87
|
-
list = list[0]
|
88
|
-
list.size.should == 2
|
89
|
-
list[0][:addr].should == "1M89ZeWtmZmATzE3b6PHTBi8c7tGsg5xpo"
|
90
|
-
list[1].should == 0
|
91
|
-
|
92
|
-
@storage.expect(:get_balance, 5000, ['dcbc93494b38ae96b14b1cc080d2acb514b7e955'])
|
93
|
-
list = @wallet.list
|
94
|
-
list.size.should == 1
|
95
|
-
list = list[0]
|
96
|
-
list.size.should == 2
|
97
|
-
list[0][:addr].should == @addr
|
98
|
-
list[1].should == 5000
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should create new addr" do
|
102
|
-
@wallet.addrs.size.should == 1
|
103
|
-
|
104
|
-
@storage.expect(:add_watched_address, [], [String])
|
105
|
-
a = @wallet.get_new_addr
|
106
|
-
@wallet.addrs.size.should == 2
|
107
|
-
@wallet.addrs[1].should == a
|
108
|
-
end
|
109
|
-
|
110
|
-
# describe "Bitcoin::Wallet::Wallet#tx" do
|
111
|
-
|
112
|
-
# before do
|
113
|
-
# txout = txout_mock(5000, nil)
|
114
|
-
# tx = Mock.new
|
115
|
-
# 2.times { tx.expect(:binary_hash, "foo") }
|
116
|
-
# 8.times { tx.expect(:out, [txout]) }
|
117
|
-
# 3.times { tx.expect(:get_block, true) }
|
118
|
-
# 5.times { txout.expect(:get_tx, tx) }
|
119
|
-
# 6.times { txout.expect(:get_address, @addr) }
|
120
|
-
# 8.times { txout.expect(:pk_script, Script.to_address_script(@addr)) }
|
121
|
-
# 2.times { @storage.expect(:get_txouts_for_address, [txout], [@addr]) }
|
122
|
-
# 2.times { @storage.expect(:class, Bitcoin::Storage::Backends::SequelStore, []) }
|
123
|
-
# selector = Bitcoin::Wallet::SimpleCoinSelector.new([txout])
|
124
|
-
# 2.times { @selector.expect(:new, selector, [[txout]]) }
|
125
|
-
# @tx = @wallet.new_tx([[:address, '1M2JjkX7KAgwMyyF5xc2sPSfE7mL1jqkE7', 1000]])
|
126
|
-
# end
|
127
|
-
|
128
|
-
|
129
|
-
# it "should have hash" do
|
130
|
-
# @tx.hash.size.should == 64
|
131
|
-
# end
|
132
|
-
|
133
|
-
# it "should have correct inputs" do
|
134
|
-
# @tx.in.size.should == 1
|
135
|
-
# @tx.in.first.prev_out.should == ("foo" + "\x00"*29)
|
136
|
-
# @tx.in.first.prev_out_index.should == 0
|
137
|
-
# end
|
138
|
-
|
139
|
-
# it "should have correct outputs" do
|
140
|
-
# @tx.out.size.should == 2
|
141
|
-
# @tx.out.first.value.should == 1000
|
142
|
-
# s = Script.new(@tx.out.first.pk_script)
|
143
|
-
# s.get_address.should == '1M2JjkX7KAgwMyyF5xc2sPSfE7mL1jqkE7'
|
144
|
-
# end
|
145
|
-
|
146
|
-
# it "should have change output" do
|
147
|
-
# @tx.out.last.value.should == 4000
|
148
|
-
# s = Script.new(@tx.out.last.pk_script)
|
149
|
-
# s.get_address.should == @addr
|
150
|
-
# end
|
151
|
-
|
152
|
-
# it "should leave tx fee" do
|
153
|
-
# @tx = @wallet.new_tx([[:address, '1M2JjkX7KAgwMyyF5xc2sPSfE7mL1jqkE7', 1000]], 50)
|
154
|
-
# @tx.out.last.value.should == 3950
|
155
|
-
# end
|
156
|
-
|
157
|
-
# it "should send change to specified address" do
|
158
|
-
# @tx = @wallet.new_tx([[:address, '1M2JjkX7KAgwMyyF5xc2sPSfE7mL1jqkE7', 1000]], 50,
|
159
|
-
# '1EAntvSjkNeaJJTBQeQcN1ieU2mYf4wU9p')
|
160
|
-
# Script.new(@tx.out.last.pk_script).get_address.should ==
|
161
|
-
# '1EAntvSjkNeaJJTBQeQcN1ieU2mYf4wU9p'
|
162
|
-
# end
|
163
|
-
|
164
|
-
# it "should send change to new address" do
|
165
|
-
# @tx = @wallet.new_tx([[:address, '1M2JjkX7KAgwMyyF5xc2sPSfE7mL1jqkE7', 1000]], 50, :new)
|
166
|
-
# @wallet.addrs.size.should == 2
|
167
|
-
# Script.new(@tx.out.last.pk_script).get_address.should == @wallet.addrs.last
|
168
|
-
# end
|
169
|
-
|
170
|
-
# it "should raise exception if insufficient balance" do
|
171
|
-
# -> {@tx = @wallet.new_tx([[:address, '1M2JjkX7KAgwMyyF5xc2sPSfE7mL1jqkE7', 7000]])}
|
172
|
-
# .should.raise(RuntimeError).message.should == "Insufficient funds."
|
173
|
-
# end
|
174
|
-
|
175
|
-
|
176
|
-
# it "should create unsigned tx" do
|
177
|
-
# Bitcoin.network = :spec
|
178
|
-
# @key = Bitcoin::Key.generate
|
179
|
-
# @key2 = Bitcoin::Key.generate
|
180
|
-
# @store = Storage.sequel(db: "sqlite:/")
|
181
|
-
# @store.log.level = :debug
|
182
|
-
|
183
|
-
# @keystore = SimpleKeyStore.new(file: StringIO.new("[]"))
|
184
|
-
# @wallet = Wallet.new(@store, @keystore, SimpleCoinSelector)
|
185
|
-
|
186
|
-
# @wallet.keystore.add_key(addr: @key.addr)
|
187
|
-
|
188
|
-
# @genesis = Bitcoin::P::Block.new("0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4adae5494dffff001d1aa4ae180101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000".htb)
|
189
|
-
|
190
|
-
# @store.new_block @genesis
|
191
|
-
# create_block(@genesis.hash, true, [], @key, 50e8)
|
192
|
-
|
193
|
-
# list = @wallet.list
|
194
|
-
# list.size.should == 1
|
195
|
-
# list[0][0].should == {addr: @key.addr}
|
196
|
-
# list[0][1].should == 50e8
|
197
|
-
|
198
|
-
# tx = @wallet.new_tx([[:address, @key2.addr, 10e8]])
|
199
|
-
# tx.in[0].sig_hash.should != nil
|
200
|
-
# end
|
201
|
-
|
202
|
-
# end
|
203
|
-
|
204
|
-
# # TODO
|
205
|
-
# describe "Bitcoin::Wallet::Wallet#tx (multisig)" do
|
206
|
-
|
207
|
-
|
208
|
-
# before do
|
209
|
-
# txout = txout_mock(5000, nil)
|
210
|
-
# tx = Mock.new
|
211
|
-
# tx.expect(:binary_hash, "foo")
|
212
|
-
# 4.times { tx.expect(:out, [txout]) }
|
213
|
-
# tx.expect(:get_block, true)
|
214
|
-
# txout.expect(:get_tx, tx)
|
215
|
-
# 2.times { txout.expect(:get_address, @addr) }
|
216
|
-
# 4.times { txout.expect(:pk_script, Script.to_address_script(@addr)) }
|
217
|
-
# @storage.expect(:get_txouts_for_address, [txout], [@key.addr])
|
218
|
-
# @storage.expect(:get_txouts_for_address, [txout], [@key2.addr])
|
219
|
-
# @storage.expect(:get_txouts_for_address, [txout], [@key3.addr])
|
220
|
-
# @storage.expect(:class, Bitcoin::Storage::Backends::SequelStore, [])
|
221
|
-
# @keystore = DummyKeyStore.new([@key, @key2, @key3])
|
222
|
-
# selector = Mock.new
|
223
|
-
# selector.expect(:select, [txout], [1000])
|
224
|
-
# @selector.expect(:new, selector, [[txout]])
|
225
|
-
# @wallet = Wallet.new(@storage, @keystore, @selector)
|
226
|
-
# @tx = @wallet.new_tx([[:multisig, 1, @key2.pub, @key3.pub, 1000]])
|
227
|
-
# end
|
228
|
-
|
229
|
-
# it "should have correct outputs" do
|
230
|
-
# @tx.out.size.should == 2
|
231
|
-
# @tx.out.first.value.should == 1000
|
232
|
-
# s = Script.new(@tx.out.first.pk_script)
|
233
|
-
# s.get_addresses.should == [@addr2, @addr3]
|
234
|
-
# end
|
235
|
-
|
236
|
-
# end
|
237
|
-
|
238
|
-
end
|