Code Monkey home page Code Monkey logo

bitcoin-ruby's People

Contributors

aalness avatar aduffeck avatar alexchien avatar altamic avatar blrhc avatar coblee avatar comboy avatar elihaims avatar etscrivner avatar fanquake avatar george-carlin avatar halorgium avatar isaacwaldron avatar jakecraige avatar jbaudanza avatar kento1218 avatar kevincb avatar kubicek avatar lian avatar losh11 avatar mhanne avatar oleganza avatar peterdavehello avatar sgarciac avatar shaulkf avatar sowbug avatar tarix avatar tmsrjs avatar weilu avatar wtogami avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bitcoin-ruby's Issues

OP_RETURN example

Are there any examples of creating a transaction with an OP_RETURN in bitcoin-ruby?

Verifying message given only signature, message, and address?

I have a Bitcoin address, a message, and a signature purportedly signed with the appropriate private key. With the current library it doesn't seem to be possible to verify a signature from just these three items. I cannot recreate a Key unless I have the full public key half of the Key, but the address is only a hash160 of it.

Yet this seems like a typical use case for signature validation (a typical user wouldn't have access to his own hex public key to send it along with the signature). Moreover, it appears to be quite possible to recover the public key, apparently given only the signature: https://bitcointalk.org/index.php?topic=6430.0 with proof of concept here: sipa/bitcoin@6e223c4

Would a Bitcoin::verify_signature(data, signature) method be possible? If not, then given just a Bitcoin address and a signature for a certain message, how can I verify that the signature is valid using this library?

Block 209373 causing problems

My node is stuck validating block 209373 with unknown script type and NoMethodError messages repeating periodically in the debug log. Interestingly test.webbtc.com seems to have stored this block but cannot display it; I get a similar error message when visiting http://test.webbtc.com/block/0000000005206f82f7ff49ca145176fdb968b5cf66f7a94fa1d108226774e840

Debug log example:

INFO  network: IP:port << getblocks: 0000000000024ab9bb8df04dabcf75c1b44c5c97c0bdb1bec93ca2e1a069ee2a
DEBUG storage: new block 0000000005206f82f7ff49ca145176fdb968b5cf66f7a94fa1d108226774e840
DEBUG storage: validating block syntax 0000000005206f82f7ff49ca145176fdb968b5cf66f7a94fa1d108226774e840 (5508 bytes)
DEBUG storage: validating tx syntax b3f261a5cf66bb669c071d4d7c9dcdfe92779537ac357d4047b629b603bdd08b (191 bytes)
DEBUG storage: validating tx syntax 5a25612be4700ec54b1ed1f3ce4f18a15d4a6fa656a3502110af8a903ac677fe (1518 bytes)
DEBUG storage: validating tx syntax d0ef4f63ba9df55588cd8972568194185e662f92c58ae9f7cc3e524e752c99f2 (930 bytes)
DEBUG storage: validating tx syntax 295fe9cc50ab9c6361162892cba3175b3f69e46cdfc834109810a03a8a0fe8d7 (225 bytes)
DEBUG storage: validating tx syntax 26088497c3d03d9a46a384ed0a34ead1a72c0548c7360843de9e5cc4df8fa300 (258 bytes)
DEBUG storage: validating tx syntax 3d14ce89c52ca05db938faf87535c975586308614bde5c2486861c5161045c5a (226 bytes)
DEBUG storage: validating tx syntax 109087017b0a6cc8f5adcba5072339c4b3b3a1a4b556106c37e6be2a648a668a (226 bytes)
DEBUG storage: validating tx syntax aba0441c4c9933dcd7db789c39053739ec435ab742ed2c23c05f22f1488c0bfd (1111 bytes)
DEBUG storage: validating tx syntax df27788dac0c6750771e2f405ec8b4c840a44e57b2a1d3839b6515694b2626ce (261 bytes)
DEBUG storage: validating tx syntax de1b7251464c641963c6b0a8eeb418bfd6f785ceaa5b7ced4d59d6cdeb11138f (372 bytes)
DEBUG storage: => main (209373)
DEBUG storage: validating block context 0000000005206f82f7ff49ca145176fdb968b5cf66f7a94fa1d108226774e840 (5508 bytes)
DEBUG storage: validating tx context b3f261a5cf66bb669c071d4d7c9dcdfe92779537ac357d4047b629b603bdd08b (191 bytes)
DEBUG storage: validating tx context 5a25612be4700ec54b1ed1f3ce4f18a15d4a6fa656a3502110af8a903ac677fe (1518 bytes)
DEBUG storage: validating tx context d0ef4f63ba9df55588cd8972568194185e662f92c58ae9f7cc3e524e752c99f2 (930 bytes)
DEBUG storage: validating tx context 295fe9cc50ab9c6361162892cba3175b3f69e46cdfc834109810a03a8a0fe8d7 (225 bytes)
DEBUG storage: validating tx context 26088497c3d03d9a46a384ed0a34ead1a72c0548c7360843de9e5cc4df8fa300 (258 bytes)
DEBUG storage: validating tx context 3d14ce89c52ca05db938faf87535c975586308614bde5c2486861c5161045c5a (226 bytes)
DEBUG storage: validating tx context 109087017b0a6cc8f5adcba5072339c4b3b3a1a4b556106c37e6be2a648a668a (226 bytes)
DEBUG storage: validating tx context aba0441c4c9933dcd7db789c39053739ec435ab742ed2c23c05f22f1488c0bfd (1111 bytes)
DEBUG storage: validating tx context df27788dac0c6750771e2f405ec8b4c840a44e57b2a1d3839b6515694b2626ce (261 bytes)
DEBUG storage: validating tx context de1b7251464c641963c6b0a8eeb418bfd6f785ceaa5b7ced4d59d6cdeb11138f (372 bytes)
INFO  storage: Unknown script type in aba0441c4c9933dcd7db789c39053739ec435ab742ed2c23c05f22f1488c0bfd:0
DEBUG storage: OP_2DUP OP_ADD 8 OP_EQUALVERIFY OP_SUB 2 OP_EQUAL
INFO  storage: Unknown script type in aba0441c4c9933dcd7db789c39053739ec435ab742ed2c23c05f22f1488c0bfd:1
DEBUG storage: 16 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 16 OP_CHECKMULTISIG
INFO  storage: Unknown script type in aba0441c4c9933dcd7db789c39053739ec435ab742ed2c23c05f22f1488c0bfd:2
DEBUG storage: OP_HASH256 4b4ceaa9ec37d585326d78ad41e9ff526f9f3ddc8404828793184dbe00000000 OP_EQUAL
INFO  storage: Unknown script type in aba0441c4c9933dcd7db789c39053739ec435ab742ed2c23c05f22f1488c0bfd:3
DEBUG storage: 2 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 15 16 4 OP_CHECKMULTISIG
INFO  storage: Unknown script type in aba0441c4c9933dcd7db789c39053739ec435ab742ed2c23c05f22f1488c0bfd:6
DEBUG storage: OP_DUP OP_HASH160 9ed2747b05faac46b84afd1729c6cbf1591d3586 OP_EQUALVERIFY
INFO  storage: Unknown script type in aba0441c4c9933dcd7db789c39053739ec435ab742ed2c23c05f22f1488c0bfd:7
DEBUG storage: 1
INFO  storage: Unknown script type in aba0441c4c9933dcd7db789c39053739ec435ab742ed2c23c05f22f1488c0bfd:8
DEBUG storage: 0:1:01
WARN  network: #<NoMethodError: undefined method `unpack' for 0:Fixnum>
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/script.rb:526:in `get_pubkey'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/script.rb:538:in `get_hash160'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/storage.rb:413:in `parse_script'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:90:in `block (3 levels) in persist_block'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:89:in `map'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:89:in `with_index'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:89:in `block (2 levels) in persist_block'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:87:in `map'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:87:in `with_index'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:87:in `block in persist_block'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/sequel-4.8.0/lib/sequel/database/transactions.rb:118:in `_transaction'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/sequel-4.8.0/lib/sequel/database/transactions.rb:93:in `block in transaction'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/sequel-4.8.0/lib/sequel/database/connecting.rb:229:in `block in synchronize'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/sequel-4.8.0/lib/sequel/connection_pool/threaded.rb:104:in `hold'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/sequel-4.8.0/lib/sequel/database/connecting.rb:229:in `synchronize'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/sequel-4.8.0/lib/sequel/database/transactions.rb:86:in `transaction'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:44:in `persist_block'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/storage.rb:206:in `store_block'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/storage.rb:153:in `new_block'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/network/node.rb:408:in `work_queue'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/em/timers.rb:56:in `call'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/em/timers.rb:56:in `fire'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `call'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/network/node.rb:218:in `run'
bin/bitcoin_node:170:in `<main>'
DEBUG storage: new block 00000000991dea3da3bd28276c7ded8e6b5bd703184b26db504922650ba1d645
DEBUG storage: validating block syntax 00000000991dea3da3bd28276c7ded8e6b5bd703184b26db504922650ba1d645 (5878 bytes)
DEBUG storage: validating tx syntax 69dece077df412fed35a07e984e2667a9165f9765c1fd322610089a3bc6529e6 (225 bytes)
DEBUG storage: validating tx syntax b46320baf8f71ab8deccc11d7d874d06e7c236ae133b0168745793d04ba670e0 (226 bytes)
DEBUG storage: validating tx syntax 19969663c3e9fb1a748276804f423d5e54f36ac7f0625ebe85dfd6477d32ec05 (225 bytes)
DEBUG storage: validating tx syntax ffb69cc71585d7812592594484ad2a4dfaf3e7d9415f5e7c3eccc5cd39523d04 (258 bytes)
DEBUG storage: validating tx syntax a3581df08777200b6a6f8dd4854617f41cd4ee366d6273d4d468b4cc9f8df272 (440 bytes)
DEBUG storage: validating tx syntax 1fb9487cdd009bddfe8450988c64a30982b15d55924fa473cad3d7ef38b93809 (371 bytes)
DEBUG storage: validating tx syntax a16ff45480e5de254e3d8aff803afe15c5702c1a22f8f8c168e87c25664c37e9 (1563 bytes)
DEBUG storage: validating tx syntax f401f72e91a0dde11294d8a8c28f3547ba6b7c423eed2cb77be66ab140807171 (191 bytes)
DEBUG storage: validating tx syntax 265378a61f0e7493018d899e266d804f07a70e62a759d60a2d020e8b8d74a50c (226 bytes)
DEBUG storage: validating tx syntax 1d263b12a5591c66d101243df543e6fed0800657241d6f1621635dd9728ff04c (226 bytes)
DEBUG storage: validating tx syntax 9c4ae980f3e487c69045810a4314c5fe769a3c4be4287adb8d6a94c86bb4b389 (373 bytes)
DEBUG storage: validating tx syntax b2485f2bd092e9f8ba715c771ae3bb90e590bc4fd418c5f801dad476d12c6b01 (226 bytes)
DEBUG storage: validating tx syntax 8784f2ec2ab7e29a8375094df974cf2acf5a05e52a6265c01201d772d7fc5b32 (226 bytes)
DEBUG storage: validating tx syntax 58e2c9fae14d087e6da2dbaf123a5bc631f5d800b3e5b4782d6264b159d4f56a (237 bytes)
DEBUG storage: validating tx syntax b5020980750e737b70e3f94f9ac9602e326c7aae3f830e3d4297cc6cf9873e50 (432 bytes)
DEBUG storage: validating tx syntax 8e166a82640b32d175ac7ed6241122a0152978f91721a68db28e8febf9262945 (243 bytes)
DEBUG storage: => orphan (4)
INFO  storage: Unknown script type in a16ff45480e5de254e3d8aff803afe15c5702c1a22f8f8c168e87c25664c37e9:0
DEBUG storage: OP_2DUP OP_ADD 8 OP_EQUALVERIFY OP_SUB 2 OP_EQUAL
INFO  storage: Unknown script type in a16ff45480e5de254e3d8aff803afe15c5702c1a22f8f8c168e87c25664c37e9:1
DEBUG storage: 16 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 16 OP_CHECKMULTISIG
INFO  storage: Unknown script type in a16ff45480e5de254e3d8aff803afe15c5702c1a22f8f8c168e87c25664c37e9:2
DEBUG storage: OP_HASH256 4b4ceaa9ec37d585326d78ad41e9ff526f9f3ddc8404828793184dbe00000000 OP_EQUAL
INFO  storage: Unknown script type in a16ff45480e5de254e3d8aff803afe15c5702c1a22f8f8c168e87c25664c37e9:3
DEBUG storage: 2 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 15 16 4 OP_CHECKMULTISIG
INFO  storage: Unknown script type in a16ff45480e5de254e3d8aff803afe15c5702c1a22f8f8c168e87c25664c37e9:6
DEBUG storage: OP_DUP OP_HASH160 9ed2747b05faac46b84afd1729c6cbf1591d3586 OP_EQUALVERIFY
INFO  storage: Unknown script type in a16ff45480e5de254e3d8aff803afe15c5702c1a22f8f8c168e87c25664c37e9:7
DEBUG storage: 1
INFO  storage: Unknown script type in a16ff45480e5de254e3d8aff803afe15c5702c1a22f8f8c168e87c25664c37e9:8
DEBUG storage: 0:1:01
WARN  network: #<NoMethodError: undefined method `unpack' for 0:Fixnum>
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/script.rb:526:in `get_pubkey'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/script.rb:538:in `get_hash160'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/storage.rb:413:in `parse_script'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:90:in `block (3 levels) in persist_block'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:89:in `map'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:89:in `with_index'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:89:in `block (2 levels) in persist_block'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:87:in `map'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:87:in `with_index'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:87:in `block in persist_block'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/sequel-4.8.0/lib/sequel/database/transactions.rb:118:in `_transaction'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/sequel-4.8.0/lib/sequel/database/transactions.rb:93:in `block in transaction'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/sequel-4.8.0/lib/sequel/database/connecting.rb:229:in `block in synchronize'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/sequel-4.8.0/lib/sequel/connection_pool/threaded.rb:104:in `hold'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/sequel-4.8.0/lib/sequel/database/connecting.rb:229:in `synchronize'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/sequel-4.8.0/lib/sequel/database/transactions.rb:86:in `transaction'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:44:in `persist_block'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/storage.rb:186:in `store_block'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/storage.rb:153:in `new_block'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/network/node.rb:408:in `work_queue'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/em/timers.rb:56:in `call'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/em/timers.rb:56:in `fire'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `call'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/network/node.rb:218:in `run'
bin/bitcoin_node:170:in `<main>'
DEBUG storage: new block 000000009a83ffd0485cc352b622c2638cc146a58e371ea8072a56a93958c167
DEBUG storage: validating block syntax 000000009a83ffd0485cc352b622c2638cc146a58e371ea8072a56a93958c167 (4949 bytes)
DEBUG storage: validating tx syntax 34585aa88190b703ec9010a0f18f0123bfc98dd0a77f55c647ac4e1ba24818f2 (258 bytes)
DEBUG storage: validating tx syntax 843d714d21742d0a47a4afcc858d899c5526966a7ff95a44565f1df225963298 (373 bytes)
DEBUG storage: validating tx syntax c52ffa4db5890a796f1b756be1678b0095776da2e7b91178393f9e07f6af7821 (258 bytes)
DEBUG storage: validating tx syntax 15258df74be1903050620d7a55a22d8e867a6c43a544111224104b7307a08b37 (258 bytes)
DEBUG storage: validating tx syntax c5640d5cc9569b9c67e8f84be562b2de7edce739d2c3261b73b2917a5713eeea (226 bytes)
DEBUG storage: validating tx syntax a060acdca43fa56cd0bbb8bcc622c67a29c1c68aed97bb6c6159a9cfa0c7f97e (293 bytes)
DEBUG storage: validating tx syntax cda5eb12ca6fff2593505b021ce8be664a66582fdd8bb29fb2e4d45a0213b561 (226 bytes)
DEBUG storage: validating tx syntax 40e3cfb15fbe851e0110258e757ef941a86ac41ed33de05155fc98335a36864c (2164 bytes)
DEBUG storage: validating tx syntax 5744bae1cc16f371feaaae6b3b1b7508927dedc60d3c4829f59312e103d3ab4b (351 bytes)
DEBUG storage: validating tx syntax af0a052796f0e06a42b0338c38781450412e3756054ea1b308a4aaee629683bf (352 bytes)
DEBUG storage: => orphan (1)
INFO  storage: Unknown script type in 40e3cfb15fbe851e0110258e757ef941a86ac41ed33de05155fc98335a36864c:0
DEBUG storage: OP_2DUP OP_ADD 8 OP_EQUALVERIFY OP_SUB 2 OP_EQUAL
INFO  storage: Unknown script type in 40e3cfb15fbe851e0110258e757ef941a86ac41ed33de05155fc98335a36864c:1
DEBUG storage: 16 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 16 OP_CHECKMULTISIG
INFO  storage: Unknown script type in 40e3cfb15fbe851e0110258e757ef941a86ac41ed33de05155fc98335a36864c:2
DEBUG storage: OP_HASH256 4b4ceaa9ec37d585326d78ad41e9ff526f9f3ddc8404828793184dbe00000000 OP_EQUAL
INFO  storage: Unknown script type in 40e3cfb15fbe851e0110258e757ef941a86ac41ed33de05155fc98335a36864c:3
DEBUG storage: 2 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 03bb52138972c48a132fc1f637858c5189607dd0f7fe40c4f20f6ad65f2d389ba4 15 16 4 OP_CHECKMULTISIG
INFO  storage: Unknown script type in 40e3cfb15fbe851e0110258e757ef941a86ac41ed33de05155fc98335a36864c:6
DEBUG storage: OP_DUP OP_HASH160 9ed2747b05faac46b84afd1729c6cbf1591d3586 OP_EQUALVERIFY
INFO  storage: Unknown script type in 40e3cfb15fbe851e0110258e757ef941a86ac41ed33de05155fc98335a36864c:7
DEBUG storage: 1
INFO  storage: Unknown script type in 40e3cfb15fbe851e0110258e757ef941a86ac41ed33de05155fc98335a36864c:8
DEBUG storage: 0:1:01
INFO  storage: Unknown script type in 40e3cfb15fbe851e0110258e757ef941a86ac41ed33de05155fc98335a36864c:13
DEBUG storage: OP_MIN 3 OP_EQUAL
INFO  storage: Unknown script type in 40e3cfb15fbe851e0110258e757ef941a86ac41ed33de05155fc98335a36864c:14
DEBUG storage: OP_SIZE
WARN  network: #<NoMethodError: undefined method `unpack' for 97:Fixnum>
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/script.rb:526:in `get_pubkey'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/script.rb:538:in `get_hash160'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/storage.rb:413:in `parse_script'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:90:in `block (3 levels) in persist_block'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:89:in `map'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:89:in `with_index'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:89:in `block (2 levels) in persist_block'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:87:in `map'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:87:in `with_index'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:87:in `block in persist_block'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/sequel-4.8.0/lib/sequel/database/transactions.rb:118:in `_transaction'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/sequel-4.8.0/lib/sequel/database/transactions.rb:93:in `block in transaction'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/sequel-4.8.0/lib/sequel/database/connecting.rb:229:in `block in synchronize'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/sequel-4.8.0/lib/sequel/connection_pool/threaded.rb:104:in `hold'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/sequel-4.8.0/lib/sequel/database/connecting.rb:229:in `synchronize'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/sequel-4.8.0/lib/sequel/database/transactions.rb:86:in `transaction'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/sequel/sequel_store.rb:44:in `persist_block'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/storage.rb:186:in `store_block'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/storage/storage.rb:153:in `new_block'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/network/node.rb:408:in `work_queue'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/em/timers.rb:56:in `call'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/em/timers.rb:56:in `fire'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `call'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
/home/user/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
/home/user/projects/bitcoin-ruby-vanilla/lib/bitcoin/network/node.rb:218:in `run'
bin/bitcoin_node:170:in `<main>'

Official ruby 2.0.0 support

Prepare the library for ruby version 2.0.0.

After the change of the file encodings to ascii-8bit (explicit by #encoding: ascii-bit8) there are currently 10 errors and 2 failures.

Add "monitor address" callback

... for easier monitoring of funds sent to (a) certain address(es).

Currently the best you can do is subscribe to the "monitor output" callback and check every output against the list of addresses you are interested in. It would be nice if we could just pass the node a (list of) address(es) and only receive outputs related to that.

Generating a public key from a private key raises error

On windows 7 using Ruby 1.9.3:
I can generate a new key (which suggests public key code works). But if I provide a private key and ask for the public key I get an error. Note that all methods using regenerate_key fail in the same way:

C:\Ruby193\code>ruby address.rb
7c73d5a2a38202157b8fd4b2902bfd825b629876
C:/Ruby193/lib/ruby/gems/1.9.1/gems/ffi-1.9.0-x86-mingw32/lib/ffi/library.rb:123
:in `block in ffi_lib': Could not open library 'ssl': The specified module could
 (LoadError)d.

.
Could not open library 'ssl.dll': The specified module could not be found.
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/ffi-1.9.0-x86-mingw32/lib/ffi/l
ibrary.rb:90:in map' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/ffi-1.9.0-x86-mingw32/lib/ffi/l ibrary.rb:90:inffi_lib'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bitcoin-ruby-0.0.1/lib/bitcoin/
ffi/openssl.rb:10:in <module:OpenSSL_EC>' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bitcoin-ruby-0.0.1/lib/bitcoin/ ffi/openssl.rb:8:inmodule:Bitcoin'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bitcoin-ruby-0.0.1/lib/bitcoin/
ffi/openssl.rb:7:in <top (required)>' from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bitcoin-ruby-0.0.1/lib/bitcoin/ key.rb:60:inpub'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bitcoin-ruby-0.0.1/lib/bitcoin/
key.rb:75:in hash160' from address.rb:9:in

'

C:\Ruby193\code>

The code I am using (address.rb) is:
require 'bitcoin'
require 'openssl'

newkey1 = Bitcoin::Key.generate
puts newkey1.hash160
# this works

myprivkey="5HrX5NfCKZJPRiKWPdokHxZSrpqEZNR5uyWg3DSkS5BcbnXmSEM"
newkey2 = Bitcoin::Key.from_base58(myprivkey)
puts newkey2.hash160
#this doesn't

Postgres storage spec failing when run via bacon on 2.1.1

There seems to be a problem with the postgres storage specs when run via rake bacon on ruby-2.1.1.

NoMethodError: undefined method `check' for #<PGresult:0x000000031ae228>
        .../gems/sequel-4.5.0/lib/sequel/adapters/postgres.rb:401:in `block (2 levels) in copy_into': transaction rules (sequel - postgres) - 16. Reject if the sum of input values < sum of output values
        .../gems/sequel-4.5.0/lib/sequel/adapters/postgres.rb:504:in `check_database_errors'
        .../gems/sequel-4.5.0/lib/sequel/adapters/postgres.rb:401:in `block in copy_into'
        .../gems/sequel-4.5.0/lib/sequel/database/connecting.rb:229:in `block in synchronize'
        .../gems/sequel-4.5.0/lib/sequel/connection_pool/threaded.rb:91:in `hold'
        .../gems/sequel-4.5.0/lib/sequel/database/connecting.rb:229:in `synchronize'
        .../gems/sequel-4.5.0/lib/sequel/adapters/postgres.rb:385:in `copy_into'
        .../bitcoin-ruby/lib/bitcoin/storage/sequel/sequel_store.rb:490:in `block in fast_insert'
        .../gems/sequel-4.5.0/lib/sequel/database/transactions.rb:91:in `block in transaction'
        .../gems/sequel-4.5.0/lib/sequel/database/connecting.rb:229:in `block in synchronize'
        .../gems/sequel-4.5.0/lib/sequel/connection_pool/threaded.rb:91:in `hold'
        .../gems/sequel-4.5.0/lib/sequel/database/connecting.rb:229:in `synchronize'
        .../gems/sequel-4.5.0/lib/sequel/database/transactions.rb:86:in `transaction'
        .../bitcoin-ruby/lib/bitcoin/storage/sequel/sequel_store.rb:481:in `fast_insert'
        .../bitcoin-ruby/lib/bitcoin/storage/sequel/sequel_store.rb:74:in `block in persist_block'
        .../gems/sequel-4.5.0/lib/sequel/database/transactions.rb:118:in `_transaction'
        .../gems/sequel-4.5.0/lib/sequel/database/transactions.rb:93:in `block in transaction'
        .../gems/sequel-4.5.0/lib/sequel/database/connecting.rb:229:in `block in synchronize'
        .../gems/sequel-4.5.0/lib/sequel/connection_pool/threaded.rb:104:in `hold'
        .../gems/sequel-4.5.0/lib/sequel/database/connecting.rb:229:in `synchronize'
        .../gems/sequel-4.5.0/lib/sequel/database/transactions.rb:86:in `transaction'
        .../bitcoin-ruby/lib/bitcoin/storage/sequel/sequel_store.rb:44:in `persist_block'
        .../bitcoin-ruby/lib/bitcoin/storage/storage.rb:181:in `store_block'
        spec/bitcoin/storage/validation_spec.rb:178:in `block (3 levels) in <main>'
        spec/bitcoin/storage/validation_spec.rb:270:in `block (2 levels) in <main>'
        spec/bitcoin/storage/validation_spec.rb:166:in `block in <main>'
        spec/bitcoin/storage/validation_spec.rb:18:in `each'
        spec/bitcoin/storage/validation_spec.rb:18:in `<main>'
  • It works on 1.9.3/2.0
  • It works with export TEST_DB_POSTGRES= empty
  • It works when run with ruby spec/bitcoin/storage/storage_spec.rb

I'm using postgres 9.1.12 and the pg gem 0.17.1.

Trying to support dogecoin

I'm trying to re-use the litecoin support to add support for dogecoin, but I can't figure out where in the dogecoin codebase to look for these magic constants:

      :magic_head => "\xfb\xc0\xb6\xdb",
      :address_version => "30",
      :p2sh_version => "05",
      :privkey_version => "b0",

I found all the rest of them :P Fucking cryptocurrency, how does it work?

Fix DoS issues in protocol parser

Whenever we unpack a var int and try to parse this many things from the payload, we need to make sure there's a break once the payload has ended. Otherwise someone can put a huge varint in a little bit of data, and have our code iterate on it a bazillion times.

Examples:

  • AuxPow hashes
  • tx inputs/outputs
  • possibly others?

1:1 port of bitcoind scripting engine

Lian's script implementation started out very clean and simple, but problems keep popping up, and with every fix it gets more complicated and looses some of its appeal. As lian suggests, we should probably just do a 1:1 port of the bitcoind C++ code and avoid this whole area of potential issues altogether.

Spec failure due to reliance on timestamps

https://travis-ci.org/lian/bitcoin-ruby/jobs/22364291

 5. Block timestamp must not be more than two hours in the future [FAILED]

Bacon::Error: [:max_timestamp, [1396757559, 1396753960]].==([:max_timestamp, [1396757559, 1396753959]]) failed
    spec/bitcoin/storage/validation_spec.rb:51:in `check_block': block rules (utxo - postgres) - 5. Block timestamp must not be more than two hours in the future
    spec/bitcoin/storage/validation_spec.rb:76:in `block (3 levels) in <main>'
    spec/bitcoin/storage/validation_spec.rb:74:in `block (2 levels) in <main>'
    spec/bitcoin/storage/validation_spec.rb:22:in `block in <main>'
    spec/bitcoin/storage/validation_spec.rb:18:in `each'
    spec/bitcoin/storage/validation_spec.rb:18:in `<main>'

Stuck at testnet block 205847 after restarting sequel+postgres node after long hiatus

I'm running a sequel+postgres node on testnet that had been down for a couple of weeks. Upon restart it began syncing but after some time stopped updating at block 205847. It is repeatedly requesting blocks from attached nodes and gets "getblocks: 0000000000048aa605ae3c7b24195bd54dda2c92dce8b5ba65dbe793664a3902" replies but has not moved past the stalled block in over eight hours.

Trouble reading addresses from transactions

Running simple_network_monitor_and_util.rb, adding the following to the on_tx function:

tx_details = tx.to_hash :with_address => true
puts field['address']

I get the address for each transaction for nearly all transactions, but sometimes the address field is empty.

This happened for the following transactions:
1c2fe8157a21f4d6a69507b063d20082bdca4fb0dca4a45227c2f90fdc42979e
2e0ed9dba8d191bba729270b31109cc622579c6df0a9b0d604c46f7fa31406ef
53bd976282e76dce14ad2cd403635c25e03421f58708001c26875be58ffa81e3
eb000c6f68b9d72c5b4b0e7b7263b8fefff5ec483eebf856a9600a9d6f3429f2
6f89ce5fff250e19d128e001185f5b359965a424af840b43eef6ced69b28eece

Details from my output log:
INFO network: 127.0.0.1:8834 received transaction: 6f89ce5fff250e19d128e001185f5b359965a424af840b43eef6ced69b28eece
{"hash"=>"6f89ce5fff250e19d128e001185f5b359965a424af840b43eef6ced69b28eece", "ver"=>1, "vin_sz"=>1, "vout_sz"=>1, "lock_time"=>0, "size"=>202, "in"=>[{"prev_out"=>{"hash"=>"57f68bf9cfe5a2f8ee6e9c2c5cd8e621955174e39abb4364f3b136ba7cbf0ad7", "n"=>131}, "scriptSig"=>"304502210096f96fdbcc64068731e60a0a534675bd5d4116089f56c64e32f8defb896e4a8402206d25e34e012935c57aa5424e848053308201290efeaee88be32a2bc7a0c10e2801 035823ba1c9c28a11bc284f213a95823c0906e4d8ec08d9ce82d76c8201af6af0e"}], "out"=>[{"value"=>"0.05070601", "scriptPubKey"=>"02e31ab94d21a0785844fa65e1c4916dd620e4773f477543550b7f12ef4288e520 OP_CHECKSIG"}]}
"Register deposit of 5070601 to "

Log validation errors

Provide a better way to see what went wrong, and a starting point for debugging.

Related: Maybe add a --die-on-orphan option that kills the node when it received an orphan block, to prevent the log getting spammed with them when debugging.

Name Conflict

Hi all.

First, thank you for this awesome library. It's ton of work!

I was using this library, then I started using "sinisterchipmunk/bitcoin-client" and this library stopped working. :|

I realized that the two most important ruby libraries about bitcoin, use the same Module name, so they conflict! :(

I don't know any way of fixing this without renaming one of the two libraries. In my opinion both libraries should change the name as soons as is possible to another no so generic option. This could use "BitcoinRuby" and the other one "BitcoinClient".

Thank you!
ton

Some operations are blocked when storing blocks

I run a sequel::postgres node and it appears that some operations are blocked when the storage backend is validating and storing a block. With verbose output set I see lots of lines like:

DEBUG storage: validating tx context 817e1e2b6a26f87620a5247a4146c39dd170364b636ae49c46425615ae4d32d8 (6369 bytes)

During this time postgresql is consuming 100% CPU and some operations hang for a long time. For example, running bin/bitcoin_node info will not return until the block has been stored and new CommandClient instances cannot subscribe to notification channels. It doesn't look like the main EM loop is blocked though because Ctrl-C still puts the node into shutdown mode.

Send our own addr to peers

Apparently other peers don't add us to their addr pool when we just send them the version message. So after a completed handshake, and on every received getaddr message, we should send our own address first.

Add support for MongoDB

I would like to try and make this library work with MongoDB as a storage backend (likely through Mongoid).

Is this something anyone else is interested in seeing?

NoMethodError: undefined method `[]' for nil:NilClass in Bitcoin::Network::ConnectionHandler::on_getblocks

I'm running a node against a postgresql sequel backend and receiving occasional exceptions like the following when working with data from other nodes. IPADDR is a peer's address and HEXSTRING is a long hex string (I presume a block). They don't seem to affect the operation of the node at all, however. Example stacktrace:

WARN  network: <IPADDR>:18333 Error handling data: <HEXSTRING>
#<NoMethodError: undefined method `[]' for nil:NilClass>
/home/USERNAME/projects/bitcoin-ruby-vanilla/lib/bitcoin/network/connection_handler.rb:228:in `block in on_getblocks'
/home/USERNAME/projects/bitcoin-ruby-vanilla/lib/bitcoin/network/connection_handler.rb:228:in `map'
/home/USERNAME/projects/bitcoin-ruby-vanilla/lib/bitcoin/network/connection_handler.rb:228:in `on_getblocks'
/home/USERNAME/projects/bitcoin-ruby-vanilla/lib/bitcoin/protocol/parser.rb:93:in `process_pkt'
/home/USERNAME/projects/bitcoin-ruby-vanilla/lib/bitcoin/protocol/parser.rb:163:in `parse_buffer'
/home/USERNAME/projects/bitcoin-ruby-vanilla/lib/bitcoin/protocol/parser.rb:135:in `parse'
/home/USERNAME/projects/bitcoin-ruby-vanilla/lib/bitcoin/network/connection_handler.rb:70:in `block in receive_data'
/home/USERNAME/.rbenv/versions/2.1.0/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/home/USERNAME/projects/bitcoin-ruby-vanilla/lib/bitcoin/network/connection_handler.rb:70:in `receive_data'
/home/USERNAME/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run_machine'
/home/USERNAME/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:187:in `run'
/home/USERNAME/projects/bitcoin-ruby-vanilla/lib/bitcoin/network/node.rb:218:in `run'
bin/bitcoin_node:170:in `<main>'

Possibly to override table names used by Sequel store?

I would like to be able to override the default table names used by the Sequel Store for one or more of the following reasons:

  • prefer less cryptic names (block vs blk)
  • want to isolate/identify bitcoin-ruby tables via some kind of namespace, either with table name prefixing or a PostgreSQL sub-schema
  • want to match Rails naming conventions for easier access within Rails app

I see in the sequel/migrations.rb file where the tables get created and what their names are, and I see in the sequel_store.rb that tables are then reference by symbols passed to the Sequel store (@db[:blk]). It's not clear to me what changes to make and where.

What's the easiest/most recommended way of accomplishing this?

Testnet sometimes fails to reorg

Sometimes the testnet fails to reorg properly and as a result treats every new incoming block as an orphan. Deleting a few of the most recent blocks and restarting the node usually solves this. Unfortunately, I haven't been able to reproduce the issue in a repeatable way.
We should have a log of incoming blocks, that we can replay to debug what's going wrong in situations like this.

Incompatible Character Encodings with mysql2 gem

I'm trying to import BitcoinD block files.

Create DB with any of the following

mysqladmin -u root create bitcoin_ruby
mysqladmin -u root --default-character-set=utf8 create bitcoin_ruby
mysqladmin -u root --default-character-set=ascii create bitcoin_ruby

This is the snippet of output for the FATAL network error I'm getting...

ruby -Ilib bin/bitcoin_node --import ~/.bitcoin/blocks/ --skip-validation
 INFO storage: opened sequel store mysql2://root@localhost/bitcoin_ruby
 INFO storage: Importing /home/byron/.bitcoin/blocks/blk00000.dat
 INFO network: Initialized 176 addrs from $HOME/.bitcoin-ruby/bitcoin/peers.json.
 INFO network: Using Linux epoll
 INFO network: EPOLL: Available file descriptors: 1024
 INFO network: Command socket listening on 127.0.0.1:9999
 INFO network: Server socket listening on 0.0.0.0:8333
 INFO network: Querying addresses from DNS seed: dnsseed.bitcoin.dashjr.org
FATAL network: incompatible character encodings: ASCII-8BIT and UTF-8
$USER/git/bitcoin-ruby/lib/bitcoin/protocol/txin.rb:66:in `to_payload'
$USER/git/bitcoin-ruby/lib/bitcoin/protocol/tx.rb:93:in `block in to_payload'
$USER/git/bitcoin-ruby/lib/bitcoin/protocol/tx.rb:93:in `each'
$USER/git/bitcoin-ruby/lib/bitcoin/protocol/tx.rb:93:in `to_payload'
$USER/git/bitcoin-ruby/lib/bitcoin/storage/sequel/sequel_store.rb:384:in `wrap_tx'
$USER/git/bitcoin-ruby/lib/bitcoin/storage/sequel/sequel_store.rb:361:in `block in wrap_block'

Wallet rework

The wallet should be reworked to interact with the storage differently. Currently, it relies on having access to the whole blockchain, when it could just receive notifications about relevant transactions, and keep them in its own little DB.

Also keep in mind SPV support (#92).

Unable to run bitcoin node after using taking database snapshot from webbtc

$ ruby node.rb
INFO  storage: Running migration /home/ubuntu/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bitcoin-ruby-0.0.4/lib/bitcoin/storage/sequel/migrations/004_change_txin_prev_out_to_blob.rb
/home/ubuntu/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bitcoin-ruby-0.0.4/lib/bitcoin/storage/storage.rb:118:in `check_metadata': Error: DB postgres://[database_credentials_on_aws_rds] was created for 'testnet3' network! (RuntimeError)

The above error occurred after I took a snapshot from webbtc:

I first did the snapshot for testnet

psql --host=[aws_database] --port=5432 --username=[rds_user] --password --dbname=[db_name] < testnet3_2013-12-16.sql

node.rb

require 'bitcoin'
node = Bitcoin::Network::Node.new(network: :testnet3, storage: "sequel::postgres://[aws_database_credentials]")
node.run

I would be very happy to share the credentials to the database instance for debugging if you would like that

I'm namesquatting on your gem!

Hi @lian

A couple of years ago I started a Bitcoin client implementation in Ruby, it's published as the bitcoin gem. I didn't get very far with it. I made it read and write some data from unencrypted BDB wallets (in fact it's partly my fault the organisation https://github.com/ruby-bdb/ exists, as I started hacking on the bdb gem to update it).

I got too busy to work on this and never returned to it. I stumbled on your gem recently, which looks pretty polished. In fact I used it in a demo in a Bitcoin Addresses I gave last night, in fact.

Let me know if you'd like to take over use of this gem name. I guess the only difference would be people adding gem 'bitcoin' instead of gem 'bitcoin-ruby' to their Gemfiles, but there's no point me sitting on it any longer.

(Edit: if you don't want it, I might just nuke it anywayโ€ฆ)

Cheers
Ash

Create Transaction with prev_output rather than the whole tx

Below is from README and is the current way of constructing a transaction

prev_tx = Bitcoin::P::Tx.from_json(open("http://test.webbtc.com/tx/#{prev_hash}.json"))

# the key needed to sign an input that spends the previous output
key = Bitcoin::Key.from_base58("92ZRu28m2GHSKaaF2W7RswJ2iJYpTzVhBaN6ZLs7TENCs4b7ML8")

# create a new transaction (and sign the inputs)
new_tx = build_tx do |t|

  # add the input you picked out earlier
  t.input do |i|
    i.prev_out prev_tx
    i.prev_out_index prev_out_index
    i.signature_key key
  end

This requires the entire transaction object to create an input although we only need i.prev_out_tx_hash AND i.prev_out_script. Could you add an endpoint so that we don't need to make api calls to get the whole transaction and only need the tx_hash ?

But basically, we only need the prev output object rather than the whole transaction

TX decode failed when parsing hex output of examples/generate_tx with JSON-RPC

I'm using the second input of transaction 0f740444...42d57cbe54d3 as the input and the private key for 14DCzMesa..... I added a second transaction output to the example to return change and tried to send 0.01 BTC to another address I own.

I wasn't sure how to use simple_nework_monitor_and_util to fetch a specific transaction, so I used to it fetch a random transaction, saved the json and modified it to reflect my own previous transaction.

I uncommented the hex binary line at the end and tried to submit the transaction:

curl --user USERNAME --data-binary '{"id":"t0", "method": "decoderawtransaction", "params": ["10000000...88ca00000000"]}' http://127.0.0.1:8332/

This returns {"result":null,"error":{"code":-22,"message":"TX decode failed"},"id":"t0"}.

Am I doing something wrong?

Just to make sure: have you been able to successfully submit a transaction made using this script?

I'm working on a simple script myself to build and sign transactions (for educative purposes) and I'm stuck at the point of signing it. If I know for sure that this example should have worked, that would help me solve my own problem.

GetBalance extremely slow

I am testing get balance on testnet data. It is taking 38 seconds to get balance for a single address. Is this speed normal (I am surprised by how slow it is given that it is indexed)? If not, what should be the expected query speed for getting the balance for a single address?

Hardware:
I am running the database on a AWS RDS hosted database, query is made from a small EC2 instance in the same data center (US-East)

I also did a manual schema dump. The indexes are definitely in place, so not sure why look ups are so slow
https://gist.github.com/sidazhang/a735d334a68a6e00d335

Downloading the block chain extremely slow

Importing the blockchain from a file seems to be about as slow. It seems to only get a few blocks per minute, is this to be expected? Any chances of a speedup in coming releases?

bitcoin-node loads from blk*.dat fine on first run, but won't load on restart from blk0002.dat onward

Detected on Ubuntu 12.04.

Running

 ruby bitcoin-node.rb --skip-validation --import ./

works fine initially, and on restart when the block being imported from is blk0001.dat it works too. It also succesfully starts importing from blk0002.dat for the first time (i.e. if the transition occurs during run time it continues correctly).

However, once blk0002.dat is being loaded, if bitcoin-node is stopped and then restarted import doesn't continue. The command

 ruby bitcoin-node.rb --skip-validation

does still work in this case though.

Missing Methods on Bitcoin::Protocol::Version ?

/Users/jbardin/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bitcoin-ruby-0.0.1/lib/bitcoin/network/connection_handler.rb:257:in addr': undefined methodservices' for #Bitcoin::Protocol::Version:0x007f8a142fc1a0 (NoMethodError)

It looks like Bitcoin::Protocol::Version was updated to contain all the data in the :fields attribute?

Unable to create transaction using JRuby 1.7.8

I want to you your gem for a project that is utilizing JRuby, but there seems to be a problem loading some of the crypto libraries in JRuby.

This is the create transaction example on the project homepage (with a slight change when reading the data from webbtc).

~/myprojects/tmp $ ruby --version
jruby 1.7.8 (1.9.3p392) 2013-11-14 0ce429e on Java HotSpot(TM) 64-Bit Server VM 1.6.0_65-b14-462-11M4609 [darwin-x86_64]
~/myprojects/tmp $ irb
>> require 'bitcoin'
=> true
>> require 'net/http'
=> true
>> Bitcoin.network = :testnet3
=> :testnet3
>> include Bitcoin::Builder
=> Object
>> prev_hash = "6c44b284c20fa22bd69c57a9dbff91fb71deddc8c54fb2f5aa41fc78c96c1ad1"
=> "6c44b284c20fa22bd69c57a9dbff91fb71deddc8c54fb2f5aa41fc78c96c1ad1"
>> prev_out_index = 0
=> 0
>> prev_tx = Bitcoin::P::Tx.from_json(Net::HTTP.get(URI.parse("http://test.webbtc.com/tx/#{prev_hash}.json")))
=> #<Bitcoin::Protocol::Tx:0x4d75650e @out=[#<Bitcoin::Protocol::TxOut:0x684d9ebf @pk_script_length=25, @pk_script="v\xA9\x14\xAA\xDF]T\xED\xA10p\xD3\x9A\xF7.\xB5\xCE@\xB1\xD3\xB8(%\x88\xAC", @value=100000000>, #<Bitcoin::Protocol::TxOut:0x3ff14318 @pk_script_length=25, @pk_script="v\xA9\x14\xB4\xB6\x9E_NQz\xFC\xBAjB\xCF\xFC\f\xCE\xA7$\x83\xC4\xB0\x88\xAC", @value=13000000>], hash"6c44b284c20fa22bd69c57a9dbff91fb71deddc8c54fb2f5aa41fc78c96c1ad1", ver1, lock_time0, payload"\x01\x00\x00\x00\x01\xDF\xD1\b\x7F\x03\xEF\x9EM\xEE\x9A\xED\xB9\xD4\xDF^\xDA\xF1\xD7\xC1\xD3\xB71\xDA]\xB8-"\x18=!\xD3]\x00\x00\x00\x00\x8CI0F\x02!\x00\xD0\fr\xDE\xFC\xEBs\xD1=\x05\xC0\x96\e\xFF\x87\xEE\xC1w\x17\xC3\x90"@\xD3p\xF9N\x94c\x94H\x19\x02!\x00\xFE\x1A'u\x060Y\xF2[\x03\xCA\xD7A6\xF7\xF7L'\xF1#\xC0\x87\x18\xDEh\xE2\x17\xC9\xE4s\xA8\xE8\x01A\x04\v#[\x86\x83\xC40'\xAF\x9BY\x14\x8D\xD3_\x93\xEA\xE6/\xE8c\xC5:\xFB\x03H_Ih~\xE5Fb\x14,\xD4\xECk\x94\xD2,\xB4\xB0\xFA\xA4\xA47a2\x8Dl\xED\x9A\xBE\xF3|\xB8 q\xBF\xF8\x94D\xB8\xFF\xFF\xFF\xFF\x02\x00\xE1\xF5\x05\x00\x00\x00\x00\x19v\xA9\x14\xAA\xDF]T\xED\xA10p\xD3\x9A\xF7.\xB5\xCE@\xB1\xD3\xB8(%\x88\xAC@]\xC6\x00\x00\x00\x00\x00\x19v\xA9\x14\xB4\xB6\x9E_NQz\xFC\xBAjB\xCF\xFC\f\xCE\xA7$\x83\xC4\xB0\x88\xAC\x00\x00\x00\x00", in[#<Bitcoin::Protocol::TxIn:0x730eb2f0 @script_sig="I0F\x02!\x00\xD0\fr\xDE\xFC\xEBs\xD1=\x05\xC0\x96\e\xFF\x87\xEE\xC1w\x17\xC3\x90\"@\xD3p\xF9N\x94c\x94H\x19\x02!\x00\xFE\x1A'u\x060Y\xF2[\x03\xCA\xD7A6\xF7\xF7L'\xF1#\xC0\x87\x18\xDEh\xE2\x17\xC9\xE4s\xA8\xE8\x01A\x04\v#[\x86\x83\xC40'\xAF\x9BY\x14\x8D\xD3_\x93\xEA\xE6/\xE8c\xC5:\xFB\x03H_Ih~\xE5Fb\x14,\xD4\xECk\x94\xD2,\xB4\xB0\xFA\xA4\xA47a2\x8Dl\xED\x9A\xBE\xF3|\xB8 q\xBF\xF8\x94D\xB8", @sequence="\xFF\xFF\xFF\xFF", @prev_out="\xDF\xD1\b\x7F\x03\xEF\x9EM\xEE\x9A\xED\xB9\xD4\xDF^\xDA\xF1\xD7\xC1\xD3\xB71\xDA]\xB8-\"\x18=!\xD3]", @script_sig_length=140, @prev_out_index=0>]
>> key = Bitcoin::Key.from_base58("92ZRu28m2GHSKaaF2W7RswJ2iJYpTzVhBaN6ZLs7TENCs4b7ML8")
ArgumentError: wrong number of arguments calling `initialize` (1 for 0)
    from /Users/mpearce/.rvm/gems/jruby-1.7.8@tmp/gems/bitcoin-ruby-0.0.2/lib/bitcoin.rb:189:in `bitcoin_elliptic_curve'
    from /Users/mpearce/.rvm/gems/jruby-1.7.8@tmp/gems/bitcoin-ruby-0.0.2/lib/bitcoin/key.rb:36:in `initialize'
    from /Users/mpearce/.rvm/gems/jruby-1.7.8@tmp/gems/bitcoin-ruby-0.0.2/lib/bitcoin/key.rb:24:in `from_base58'
    from (irb):8:in `evaluate'
    from org/jruby/RubyKernel.java:1123:in `eval'
    from org/jruby/RubyKernel.java:1519:in `loop'
    from org/jruby/RubyKernel.java:1284:in `catch'
    from org/jruby/RubyKernel.java:1284:in `catch'
    from /Users/mpearce/.rvm/rubies/jruby-1.7.8/bin/irb:13:in `(root)'

Fuzz testing the protocol parser

See #75 - this actually happened to me by accident (I was feeding it a block with the magic bytes still in front).

Maybe we should add some fuzz-testing for the protocol parser that just feeds it (semi?) random data and makes sure it doesn't fail in unexpected ways.

Any thoughts?

I think I have heard about such a thing for bitcoind once, but I can't find it anymore..

prev out missing?

Hi!

I am downloading the blockchain with bitcoin_node into PostgreSQL.

I got the following error today:

INFO network: 5.10.73.2:8333 << getblocks: 000000000000004fd577c4781a8f1b887af9f5ae276dbc849566350243925901
 INFO network: querying blocks from 5.10.73.2:8333
 WARN storage: prev out 6f5073c1ebf36e77d404a931d6a83ca352ebc77c0aabaff4f7ecbc00a4217b5f:25 missing
 INFO storage: tx error: context check 0 - prev_out failed
 WARN network: ValiationError storing block 00000000000001d31c7f4430d52a1a0e8187c8072152c639797a5f48d75bdd2f: block error: context check 4 - transactions_context failed
 INFO storage: block 00000000000002d359678de7973090dd9ceffe54c26749fa48865698563f723f [0, orphan] (0.0541s, 230.634kb)
 INFO storage: block 000000000000024515b8c873bafb3bf05105ab3c24fca16b9326c7ceda01bcc2 [0, orphan] (0.0253s, 130.272kb)
 INFO storage: block 0000000000000043b5d8b2698363d0c7864f5d0d05638e06df888d191ed79991 [0, orphan] (0.0995s, 203.675kb)
 INFO storage: block 0000000000000135aeabf9666fc9f1d5b8573685db070a5f1dfdd78f728a167a [0, orphan] (0.0150s, 149.054kb)
 INFO storage: block 00000000000000a86c0a6d7b3445ff9e64908d6417cd6b256dbc23efd01de26f [0, orphan] (0.0016s, 0.227kb)
 INFO storage: block 00000000000000bb6cf643f8de348a378dcc10f383fc3c0a4aa4134b5f76f6ee [0, orphan] (0.0158s, 149.037kb)
 INFO storage: block 00000000000000f1c32b160d7a66ee1d9194a023fd05f1a063d0881ceadb19b9 [0, orphan] (0.0505s, 149.186kb)
 INFO storage: block 00000000000001865a2cd9167daa46780c04fc6309be33c4562e959342733365 [0, orphan] (0.0347s, 161.559kb)
 INFO storage: block 00000000000001434b0e0129cd5cc2c122f8b8cdb0b913cc98b310f1fb77c372 [0, orphan] (0.0925s, 293.619kb)

Then all subsequent blocks are marked as orphan.

Didn't have time to fully analyze how bitcoin_node works, can you help me pointing into a direction in where to look? What's the problem here?

Thank you.

Transaction build gets 'RuntimeError: Signature error'

Hi,
I hope this is a good place for this question.
I'm trying to build a transaction. My code is:

prev_hash = "5358af484c228b50c95df355658a2afb68e9435f305307bfe42637aa32b44a14"

prev_out_index = 1

prev_tx = Bitcoin::P::Tx.from_json(open("http://webbtc.com/tx/#{prev_hash}.json"))

private_key = "private_key_of_address_1MivPo4WqFB8Ddf6VQVdAFj497i7ae84En"
key = Bitcoin::Key.new(private_key)

# create a new transaction (and sign the inputs)
new_tx = build_tx do |t|

  # add the input you picked out earlier
  t.input do |i|
    i.prev_out prev_tx
    i.prev_out_index prev_out_index
    i.signature_key key
  end

  t.output do |o|
    o.value 1000 # satoshis
    o.script {|s| s.recipient "1KyXm7xs8xc74FqByFDdpNjyKA3nFeQxAf" }
  end

  t.output do |o|
    o.value 488000
    o.script {|s| s.recipient "1MivPo4WqFB8Ddf6VQVdAFj497i7ae84En" }
  end

end

puts new_tx.to_json

I don't understand why but I get a ' 'RuntimeError: Signature error'. It seems to fail in one of the chunks in Bitcoin::Script#run
Is something wrong with my parameters?
(This is my second try, so I'm just trying to create an already existing transaction so I already know the expected output. The transaction is http://webbtc.com/tx/b664581720363a64e25fc5108e122092c6aceea4f423a9e9e6aa81b13ef49cba.json)

Thanks!

Block Storage; Difficulty taken into consideration when dealing with side branches

I could be more then wrong; probably the case but I cant see where block difficulty is used to determine whether a block is a main or side block when at the same depth;

"Add block into the tree. There are three cases: 1. block further extends the main branch; 2. block extends a side branch but does not add enough difficulty to make it become the new main branch; 3. block extends a side branch and makes it the new main branch."

Tests not all passing

There are numerous failing tests. I'm not sure if there is something wrong with the bundle (maybe a different version of minitest needs to be used in the development bundle??).

~/projects/bitcoin-ruby[master] $ which ruby
/Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
~/projects/bitcoin-ruby[master] $ bundle exec rake
   1/27: spec/bitcoin/bitcoin_spec.rb                           29 passed
   2/27: spec/bitcoin/protocol/addr_spec.rb                      5 passed
   3/27: spec/bitcoin/protocol/alert_spec.rb                     1 passed
   4/27: spec/bitcoin/protocol/aux_pow_spec.rb                   4 passed
   5/27: spec/bitcoin/protocol/block_spec.rb                    14 passed
   6/27: spec/bitcoin/protocol/getblocks_spec.rb                 2 passed
   7/27: spec/bitcoin/protocol/inv_spec.rb                       6 passed
   8/27: spec/bitcoin/protocol/notfound_spec.rb                  2 passed
   9/27: spec/bitcoin/protocol/ping_spec.rb                      6 passed
  10/27: spec/bitcoin/protocol/tx_spec.rb                       16 passed
  11/27: spec/bitcoin/protocol/txin_spec.rb                      1 passed
  12/27: spec/bitcoin/protocol/version_spec.rb                   2 passed
  13/27: spec/bitcoin/script/opcodes_spec.rb                    62 passed
  14/27: spec/bitcoin/script/script_spec.rb                     24 passed
  15/27: spec/bitcoin/wallet/coinselector_spec.rb                  failed
Bitcoin::Wallet::SimpleCoinSelector
  - should select only txouts which have not been spent [FAILED]
  - should select only txouts which are in a block [FAILED]

Bacon::Error: [#<MiniTest::Mock:0x000001008c90a0 @expected_calls={:value=>{:retval=>1000, :args=>[]}, :get_next_in=>{:retval=>nil, :args=>[]}, :get_address=>{:retval=>"addr", :args=>[]}, :get_tx=>{:retval=>#<MiniTest::Mock:0x000001008c91e0 @expected_calls={:get_block=>{:retval=>true, :args=>[]}}, @actual_calls={}>, :args=>[]}}, @actual_calls={:get_next_in=>[{:retval=>nil, :args=>[]}], :get_address=>[{:retval=>"addr", :args=>[]}], :get_tx=>[{:retval=>#<MiniTest::Mock:0x000001008c3678 @expected_calls={:get_block=>{:retval=>true, :args=>[]}}, @actual_calls={:get_block=>[{:retval=>true, :args=>[]}]}>, :args=>[]}], :value=>[{:retval=>3000, :args=>[]}]}>].==([#<MiniTest::Mock:0x000001008c90a0 @expected_calls={:value=>{:retval=>1000, :args=>[]}, :get_next_in=>{:retval=>nil, :args=>[]}, :get_address=>{:retval=>"addr", :args=>[]}, :get_tx=>{:retval=>#<MiniTest::Mock:0x000001008c91e0 @expected_calls={:get_block=>{:retval=>true, :args=>[]}}, @actual_calls={}>, :args=>[]}}, @actual_calls={:get_next_in=>[{:retval=>nil, :args=>[]}], :get_address=>[{:retval=>"addr", :args=>[]}], :get_tx=>[{:retval=>#<MiniTest::Mock:0x000001008c3678 @expected_calls={:get_block=>{:retval=>true, :args=>[]}}, @actual_calls={:get_block=>[{:retval=>true, :args=>[]}]}>, :args=>[]}], :value=>[{:retval=>3000, :args=>[]}]}>, #<MiniTest::Mock:0x000001008c81a0 @expected_calls={:value=>{:retval=>2000, :args=>[]}, :get_next_in=>{:retval=>nil, :args=>[]}, :get_address=>{:retval=>"addr", :args=>[]}, :get_tx=>{:retval=>#<MiniTest::Mock:0x000001008c8358 @expected_calls={:get_block=>{:retval=>true, :args=>[]}}, @actual_calls={}>, :args=>[]}}, @actual_calls={}>]) failed
    spec/bitcoin/wallet/coinselector_spec.rb:26:in `block (2 levels) in <main>': Bitcoin::Wallet::SimpleCoinSelector - should select only txouts which have not been spent
    spec/bitcoin/wallet/coinselector_spec.rb:22:in `block in <main>'
    spec/bitcoin/wallet/coinselector_spec.rb:8:in `<main>'

Bacon::Error: [#<MiniTest::Mock:0x000001008b9d08 @expected_calls={:value=>{:retval=>1000, :args=>[]}, :get_next_in=>{:retval=>nil, :args=>[]}, :get_address=>{:retval=>"addr", :args=>[]}, :get_tx=>{:retval=>#<MiniTest::Mock:0x000001008b9dd0 @expected_calls={:get_block=>{:retval=>false, :args=>[]}}, @actual_calls={}>, :args=>[]}}, @actual_calls={:get_next_in=>[{:retval=>nil, :args=>[]}], :get_address=>[{:retval=>"addr", :args=>[]}], :get_tx=>[{:retval=>#<MiniTest::Mock:0x000001008b1ae0 @expected_calls={:get_block=>{:retval=>true, :args=>[]}}, @actual_calls={:get_block=>[{:retval=>true, :args=>[]}]}>, :args=>[]}], :value=>[{:retval=>3000, :args=>[]}]}>].==([#<MiniTest::Mock:0x000001008b8e30 @expected_calls={:value=>{:retval=>2000, :args=>[]}, :get_next_in=>{:retval=>nil, :args=>[]}, :get_address=>{:retval=>"addr", :args=>[]}, :get_tx=>{:retval=>#<MiniTest::Mock:0x000001008b8ef8 @expected_calls={:get_block=>{:retval=>true, :args=>[]}}, @actual_calls={}>, :args=>[]}}, @actual_calls={}>]) failed
    spec/bitcoin/wallet/coinselector_spec.rb:34:in `block (2 levels) in <main>': Bitcoin::Wallet::SimpleCoinSelector - should select only txouts which are in a block
    spec/bitcoin/wallet/coinselector_spec.rb:30:in `block in <main>'
    spec/bitcoin/wallet/coinselector_spec.rb:8:in `<main>'

2 specifications (2 requirements), 2 failures, 0 errors
Coverage report generated for RSpec to /Users/mpearce/projects/bitcoin-ruby/coverage. 182 / 419 LOC (43.44%) covered.
  16/27: spec/bitcoin/wallet/keygenerator_spec.rb                6 passed
  17/27: spec/bitcoin/wallet/keystore_spec.rb                   25 passed
  18/27: spec/bitcoin/wallet/txdp_spec.rb                        6 passed
  19/27: spec/bitcoin/wallet/wallet_spec.rb                        failed
Bitcoin::Wallet::Wallet
  - should get total balance [ERROR: NameError]
  - should get all addrs
  - should list all addrs with balances
  Bitcoin::Wallet::Wallet#tx
    - should have hash [ERROR: NameError]
    - should have correct inputs [ERROR: NameError]
    - should have correct outputs [ERROR: NameError]
    - should have change output [ERROR: NameError]
    - should leave tx fee [ERROR: NameError]
    - should send change to specified address [ERROR: NameError]
    - should send change to new address [ERROR: NameError]
    - should raise exception if insufficient balance [ERROR: NameError]
    - should create unsigned tx [ERROR: NameError]

NameError: method `class' not defined in MiniTest::Mock
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `remove_method': Bitcoin::Wallet::Wallet - should get total balance
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `expect'
    spec/bitcoin/wallet/wallet_spec.rb:67:in `block (2 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:66:in `block in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:21:in `<main>'

NameError: method `hash' not defined in MiniTest::Mock
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `remove_method': Bitcoin::Wallet::Wallet#tx - should have hash
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `expect'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `block in txout_mock'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `times'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `txout_mock'
    spec/bitcoin/wallet/wallet_spec.rb:115:in `block (3 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:131:in `block (2 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:112:in `block in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:21:in `<main>'

NameError: method `hash' not defined in MiniTest::Mock
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `remove_method': Bitcoin::Wallet::Wallet#tx - should have correct inputs
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `expect'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `block in txout_mock'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `times'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `txout_mock'
    spec/bitcoin/wallet/wallet_spec.rb:115:in `block (3 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:135:in `block (2 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:112:in `block in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:21:in `<main>'

NameError: method `hash' not defined in MiniTest::Mock
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `remove_method': Bitcoin::Wallet::Wallet#tx - should have correct outputs
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `expect'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `block in txout_mock'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `times'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `txout_mock'
    spec/bitcoin/wallet/wallet_spec.rb:115:in `block (3 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:141:in `block (2 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:112:in `block in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:21:in `<main>'

NameError: method `hash' not defined in MiniTest::Mock
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `remove_method': Bitcoin::Wallet::Wallet#tx - should have change output
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `expect'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `block in txout_mock'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `times'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `txout_mock'
    spec/bitcoin/wallet/wallet_spec.rb:115:in `block (3 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:148:in `block (2 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:112:in `block in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:21:in `<main>'

NameError: method `hash' not defined in MiniTest::Mock
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `remove_method': Bitcoin::Wallet::Wallet#tx - should leave tx fee
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `expect'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `block in txout_mock'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `times'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `txout_mock'
    spec/bitcoin/wallet/wallet_spec.rb:115:in `block (3 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:154:in `block (2 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:112:in `block in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:21:in `<main>'

NameError: method `hash' not defined in MiniTest::Mock
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `remove_method': Bitcoin::Wallet::Wallet#tx - should send change to specified address
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `expect'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `block in txout_mock'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `times'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `txout_mock'
    spec/bitcoin/wallet/wallet_spec.rb:115:in `block (3 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:159:in `block (2 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:112:in `block in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:21:in `<main>'

NameError: method `hash' not defined in MiniTest::Mock
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `remove_method': Bitcoin::Wallet::Wallet#tx - should send change to new address
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `expect'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `block in txout_mock'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `times'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `txout_mock'
    spec/bitcoin/wallet/wallet_spec.rb:115:in `block (3 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:166:in `block (2 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:112:in `block in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:21:in `<main>'

NameError: method `hash' not defined in MiniTest::Mock
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `remove_method': Bitcoin::Wallet::Wallet#tx - should raise exception if insufficient balance
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `expect'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `block in txout_mock'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `times'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `txout_mock'
    spec/bitcoin/wallet/wallet_spec.rb:115:in `block (3 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:172:in `block (2 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:112:in `block in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:21:in `<main>'

NameError: method `hash' not defined in MiniTest::Mock
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `remove_method': Bitcoin::Wallet::Wallet#tx - should create unsigned tx
    /Users/mpearce/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/minitest/mock.rb:19:in `expect'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `block in txout_mock'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `times'
    spec/bitcoin/wallet/wallet_spec.rb:15:in `txout_mock'
    spec/bitcoin/wallet/wallet_spec.rb:115:in `block (3 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:178:in `block (2 levels) in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:112:in `block in <main>'
    spec/bitcoin/wallet/wallet_spec.rb:21:in `<main>'

12 specifications (10 requirements), 0 failures, 10 errors
Coverage report generated for RSpec to /Users/mpearce/projects/bitcoin-ruby/coverage. 566 / 1435 LOC (39.44%) covered.
  20/27: spec/bitcoin/storage/storage_spec.rb                   87 passed
  21/27: spec/bitcoin/storage/reorg_spec.rb                     14 passed
  22/27: spec/bitcoin/storage/validation_spec.rb                46 passed
  23/27: spec/bitcoin/node/command_api_spec.rb                  25 passed
  24/27: spec/bitcoin/builder_spec.rb                            6 passed
  25/27: spec/bitcoin/key_spec.rb                               19 passed
  26/27: spec/bitcoin/namecoin_spec.rb                          12 passed
  27/27: spec/bitcoin/network_spec.rb                            4 passed
438 specifications (1780 requirements), 2 failures, 10 errors
~/projects/bitcoin-ruby[master] $ 

Merkle root n invalid! (RuntimeError) upon restarting bitcoin_node

Every time I stop the node and restart it, this happens.

--check-blocks 0 option works, but I don't know if the consistency check is wrong, or if database is actually corrupted.

$ bitcoin_node --network testnet3 --storage sequel::postgres://localhost/pari_bitcoin_development

...

^c
$ bitcoin_node --network testnet3 --storage sequel::postgres://localhost/pari_bitcoin_development
INFO  storage: opened sequel store postgres://localhost/pari_bitcoin_development
INFO  storage: Checking consistency of last 1000 blocks...
/Users/zacstewart/.gem/ruby/2.0.0/gems/bitcoin-ruby-0.0.2/lib/bitcoin/storage/sequel/sequel_store.rb:427:in `block in check_consistency': Merkle root 3448 invalid! (RuntimeError)
        from /Users/zacstewart/.gem/ruby/2.0.0/gems/bitcoin-ruby-0.0.2/lib/bitcoin/storage/sequel/sequel_store.rb:423:in `upto'
        from /Users/zacstewart/.gem/ruby/2.0.0/gems/bitcoin-ruby-0.0.2/lib/bitcoin/storage/sequel/sequel_store.rb:423:in `each'
        from /Users/zacstewart/.gem/ruby/2.0.0/gems/bitcoin-ruby-0.0.2/lib/bitcoin/storage/sequel/sequel_store.rb:423:in `check_consistency'
        from /Users/zacstewart/.gem/ruby/2.0.0/gems/bitcoin-ruby-0.0.2/lib/bitcoin/network/node.rb:112:in `set_store'
        from /Users/zacstewart/.gem/ruby/2.0.0/gems/bitcoin-ruby-0.0.2/lib/bitcoin/network/node.rb:93:in `initialize'
        from /Users/zacstewart/.gem/ruby/2.0.0/gems/bitcoin-ruby-0.0.2/bin/bitcoin_node:169:in `new'
        from /Users/zacstewart/.gem/ruby/2.0.0/gems/bitcoin-ruby-0.0.2/bin/bitcoin_node:169:in `<top (required)>'
        from /Users/zacstewart/.gem/ruby/2.0.0/bin/bitcoin_node:23:in `load'
        from /Users/zacstewart/.gem/ruby/2.0.0/bin/bitcoin_node:23:in `<main>'

testnet3 stuck blockchain

I'm downloading testnet3's blockchain and it seems to be stuck at height 96464 and the timestamp of the last block is July 21. My satoshi client's testnet3 height is 98539, which is the same as what i'm seeing on this explorer site http://testnet.btclook.com/

Unknown script type during --import

Not sure if this is important or not as it's only a WARN, but thought I'd put it here just in case...

 INFO storage: block 000000000000084a837eb844d17f828d460749d3bea65c7d1a17b1d72314c2ef [173037, main] (0.4869s,  66tx, 30.666kb)
 INFO storage: block 00000000000003a892d097feaff0b0df42c49f5f7747078febdb71fa90eefda0 [173038, main] (2.1427s, 107tx, 83.738kb)
 INFO storage: block 00000000000003b1e8eb147d9e7bd99ca9a58d1611ff1de1d02d54790159f1c2 [173039, main] (0.1616s,   1tx, 0.223kb)
 INFO storage: block 000000000000037d25bb6c063a254d97f7b3b0d88146981e7d5e1ba08058a8cc [173040, main] (0.7628s,  67tx, 37.463kb)
 WARN storage: Unknown script type
 WARN storage: Unknown script type
 INFO storage: block 0000000000000a3b7bdb1bf8ca526199281317ab3fabb3ad311b698cbc7fc36f [173041, main] (1.5727s,  44tx, 37.187kb)
 INFO storage: block 000000000000095ddd1d8a793e2645af960764e1561953bfd3d63b2c024d1de5 [173042, main] (0.3270s,  31tx, 17.180kb)
 INFO storage: block 00000000000001796c31a1f5a86cea6be8fd732f707337701b80687e63a9fef1 [173043, main] (1.0913s, 142tx, 45.780kb)
 INFO storage: block 0000000000000af148d536defb8b3bcb760026fc53a590ea311c1eb7522a4a33 [173044, main] (1.0714s, 110tx, 32.321kb)
 INFO storage: block 00000000000006c1ae2e3de4e82f2fac49681e4d697a3b41b2275552f8bc9f13 [173045, main] (0.1612s,   1tx, 0.217kb)
 INFO storage: block 0000000000000891e5472251578b2667d400ee51afefd1438aba42d07d86b490 [173046, main] (0.7489s,  88tx, 31.885kb)
 INFO storage: block 0000000000000a0c7eaf11a449cd4e9ebc7af3211dc14cc7bede8a01e7c88c3e [173047, main] (1.7358s,  73tx, 55.634kb)
 INFO storage: block 0000000000000338d081e859db7014c85ddc69fd36db5d30f21905b01128e607 [173048, main] (0.1588s,   3tx, 3.069kb)
 INFO storage: block 00000000000002efdeab0c7f4739c6c425eee75e70b4605616af85c3048f84fa [173049, main] (0.2215s,  28tx, 11.453kb)
 INFO storage: block 000000000000026443106d6eb5eab51e534715764acd1ab770bb03dfc70af69b [173050, main] (0.1761s,  24tx, 8.576kb)
 INFO storage: block 000000000000058c64378f1800535e62a80926fc4494409c054a2eb77f11578f [173051, main] (0.0987s,  11tx, 3.203kb)
 INFO storage: block 000000000000045cfd9c35f28c982272e03189c4ee080a5d366ab13a033bb6e0 [173052, main] (0.2444s,  24tx, 11.739kb)
 INFO storage: block 00000000000004f39bdb3356041d27e6171ba154a5286b20b51eeb91a22afe82 [173053, main] (0.2120s,  22tx, 12.525kb)
 INFO storage: block 0000000000000b06c2101891ba81ab68559b37c992fd8b882bc9afa402ef746e [173054, main] (0.4863s,  66tx, 20.848kb)
 WARN storage: Unknown script type
 WARN storage: Unknown script type
 INFO storage: block 0000000000000626a92f14c5a0d8fd233012a2c953e49916ce63e5fbe5f3c2e4 [173055, main] (0.9034s,  47tx, 32.484kb)
 INFO storage: block 0000000000000110842b24861badb1e7f92d6303f20b4b234e2af56655fee1e9 [173056, main] (0.3373s,  29tx, 17.853kb)
 INFO storage: block 0000000000000ac52c1ec9c5598f2a4fec9b2abd9d679cbc164d780968309d1b [173057, main] (0.1172s,   9tx, 8.139kb)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.