Pages:
Author

Topic: [ANNOUNCE] Abe 0.7: Open Source Block Explorer Knockoff - page 42. (Read 220986 times)

legendary
Activity: 1261
Merit: 1000
OK, thank you! I understand.

How can i convert the address to a public key hash?
hero member
Activity: 481
Merit: 529
andrehorta,

I appreciate your goal!

To extend Abe with new page types and HTTP-API functions, I suggest you follow the model of ecdsa.org.  See contrib/ecdsa.py for sample code.  It subclasses Abe and defines methods named with a "handle_" prefix.  Abe calls handle_* when it gets a request for /*/... .  Unfortunately, the structure of the "page" argument is not currently documented and may change, so you will have to figure it out from the existing handlers in abe.py and ecdsa.py.  Likewise, Abe maps /q/* and /chain/.../q/* to the q_* method with "page" and "chain" arguments; chain is None when /chain/ does not appear in the URL.

Pasted from doc/FAQ.html:
Quote
Where in the database are bitcoin addresses?

A bitcoin address is an encoding of the hash of the public part of a keypair in someone's wallet. Abe stores only the public key hash, in pubkey.pubkey_hash. Abe converts hash values to bitcoin addresses as needed using the hash_to_address function in abe.py.

To find an address history in the database, you must first convert the address to a public key hash and look up its pubkey_id in the pubkey table.  As an example, the SQL for /address/ pages is in Abe/abe.py: handle_address.  pubkey_id links to the txout table, where txout_value is the amount received.  Abe internally uses units of 1 satoshi (.00000001 BTC), so it would store 1 BTC as txout_value=100000000 (1e8).

When money leaves an address, there will be a row in txin referencing an older txout row (via txin.txout_id) where txout.pubkey_id refers to the address.

To find when transactions entered the block chain, you must follow the joins from txin/txout to tx, block_tx, block, and chain_candidate.  Abe stores blocks that are on side-chains, and you should normally ignore those by restricting results to where chain_candidate.in_longest=1.  Abe is designed to support multiple currencies in one database, so you should also restrict by chain_id, where the values are listed in the chain table, and BTC is chain_id=1 by default.  block.block_nTime is the time recorded in the block header in units of seconds since 1 Jan 1970 UTC.

I hope this helps you get started.
legendary
Activity: 1261
Merit: 1000
OK, thank you.

For my application, i need to know how can i make selects on the database to get some information, like:

How much some address send to another addres?

Hom many transactions was done between address? Filter by date and value?

Thank you a lot!

I´m making a opensource and free website to use bitcoin abe (in english, spanish, portugues and chinese)
newbie
Activity: 58
Merit: 0
How can I call a function like: getreceivedbyaddress???

For some API calls such as getreceivedbyaddress, you have to specify which block chain (Bitcoin, Namecoin, etc.) to query in the URL. Example usage for Bitcoin:

Code:
https://hostname/abe/chain/Bitcoin/q/getreceivedbyaddress/1HZRowLTkmF6M8V11vj2dmVf2r9VK7dVfo

Namecoin example:

Code:
https://hostname/abe/chain/Namecoin/q/getreceivedbyaddress/MxT6tjJZcYZeWUGNgsAMxJ7wpDgKMdub4y

Other API calls can be used for addresses on any block chain. Example:

Code:
https://hostname/abe/q/addresstohash/1HZRowLTkmF6M8V11vj2dmVf2r9VK7dVfo

The following URL shows the API calls currently supported by the Abe installation and provides links to documentation for each API call.

Code:
https://hostname/abe/q
legendary
Activity: 1261
Merit: 1000
How can I call a function like: getreceivedbyaddress???
legendary
Activity: 1261
Merit: 1000
Why when i use bitcoin-abe (http://abe.john-edwin-tobey.org/), is showing the message:

Address 14K9E8xNBgn1ZomQYPcUVXbmnW2CjHkQCk

Address not seen on the network.

That site is now six days behind, and your address appeared on the network only after the site stopped updating.  I have messaged the site maintainer but had no response yet.  If you (or anyone) would like to host the site with an up-to-date block chain and get free monitoring from me via PM Smiley I will happily switch the DNS record to your server.

After i install the bitcoin-abe on my server, the same message is show: Address not seen on the network.

This address is of my wallet on bitcoin client official. At bitcoin explorer this addess is showing corret.

Please, help me to understand!

On your server's home page, what block number does it show for BTC?  Are you running the latest bitcoind?  Can you post the last few lines of Abe's output?


OK, i will prepare my server to make visible for everyone.
sr. member
Activity: 459
Merit: 250
Checked it against my install and you're showing with 0.006 BTC.

http://blockexplorer.funkymonkey.org/address/14K9E8xNBgn1ZomQYPcUVXbmnW2CjHkQCk

(It's an older box so it's quite slow on pages with lots of addresses to hash out.  Give it time. Smiley)
hero member
Activity: 481
Merit: 529
Why when i use bitcoin-abe (http://abe.john-edwin-tobey.org/), is showing the message:

Address 14K9E8xNBgn1ZomQYPcUVXbmnW2CjHkQCk

Address not seen on the network.

That site is now six days behind, and your address appeared on the network only after the site stopped updating.  I have messaged the site maintainer but had no response yet.  If you (or anyone) would like to host the site with an up-to-date block chain and get free monitoring from me via PM Smiley I will happily switch the DNS record to your server.

After i install the bitcoin-abe on my server, the same message is show: Address not seen on the network.

This address is of my wallet on bitcoin client official. At bitcoin explorer this addess is showing corret.

Please, help me to understand!

On your server's home page, what block number does it show for BTC?  Are you running the latest bitcoind?  Can you post the last few lines of Abe's output?
legendary
Activity: 1261
Merit: 1000
Dears

Why when i use bitcoin-abe (http://abe.john-edwin-tobey.org/), is showing the message:

Address 14K9E8xNBgn1ZomQYPcUVXbmnW2CjHkQCk

Address not seen on the network.

After i install the bitcoin-abe on my server, the same message is show: Address not seen on the network.

This address is of my wallet on bitcoin client official. At bitcoin explorer this addess is showing corret.

Please, help me to understand!



sr. member
Activity: 459
Merit: 250
Sweet, thanks!

That'll help my 3 box setup - 1 for clients to download chains and import to db, 1 for the db, and 1 for the web interface.  Smiley

For now I think I'm going to leave CLC and try not to remove it.  Once everything is up and running decently I'm going to see if I can figure out the addressing and update Abe to support CoiledCoin.  I'll post the code for you to add if you want but don't expect it to happen any time soon as I'm still learning things.
hero member
Activity: 481
Merit: 529
@tiker

Regarding address_version in datadir configuration, I've added the following documentation:

Quote
For address_version, if you have a valid address for the new chain, append it to http://abe.john-edwin-tobey.org/q/decode_address/. For example, Testnet address mgnQ32RSjvmTLB3jVZ9L2xUTT512cCX9b8 gives
http://abe.john-edwin-tobey.org/q/decode_address/mgnQ32RSjvmTLB3jVZ9L2xUTT512cCX9b8, which shows 6f:0de3da453bfd284cd1c94902dbb9bc28bbed139f. Take the part to the left of the colon (Smiley (6f for Testnet) and replace "XX" with it in "\u00XX" ("\u006f" for Testnet) That is the value for address_version in the config file's JSON format.

address_version comes from the first byte of the input to SHA256 used in address computation. In Bitcoin as of this writing, this information is in src/base58.h:

    enum
    {
        PUBKEY_ADDRESS = 0,
        SCRIPT_ADDRESS = 5,
        PUBKEY_ADDRESS_TEST = 111,
        SCRIPT_ADDRESS_TEST = 196,
    };

The byte is 111 for Testnet and 0 for regular Bitcoin. You would translate byte 111 to a JSON string as follows: 111 = '6f' (hexadecimal). In JSON, a 1-byte string is encoded as "\u00XX" where XX are the hex digits. So Testnet would be "\u006f".

If you get the wrong address_version value, everything will work except for address display. You could look up addresses, but they would appear different on web pages.

To prevent the web process from reading blk*, I give it an empty directory in datadir.

To remove a chain would be a nice feature.  If I remember right, the steps are:

1. Find chain_id in the chain table.  (SELECT chain_id FROM chain WHERE chain_code3='CLC')
2. Delete from chain_candidate where chain_id = ?(value found in #1)
3. Delete from datadir where chain_id = ?(value found in #1)
4. Delete from chain where chain_id = ?(value found in #1)

This does not delete the chain's block data, which is harmless apart from taking space.  You could delete all rows from block, block_tx, tx, txin, block_txin, txout, and pubkey that relate only to the deleted chain.  That would be a nice function to have. Smiley
sr. member
Activity: 459
Merit: 250
Is there an easy way to remove a block chain from Abe?

I tried to bring in Coiledcoin to play with but it didn't seem to work. Addresses show as "UNKNOWN" and transaction hashes are messed up.. then I noticed the bold text from the original announcement https://bitcointalksearch.org/topic/dead-coiledcoin-yet-another-cryptocurrency-but-with-opeval-56675 so I'm looking for an uninstall option for that chain.  Smiley

That or a way to make it work with Abe.
sr. member
Activity: 459
Merit: 250
Also, is there any way to setup Abe so that the web process doesn't trigger an update of data from the blk* files?  My current testing environment isn't exactly the latest hardware and if there new blocks to import for multiple chains at once it times out and spits back a 500 internal error page.  I've got a cron job setup that updates on a regular basis.
sr. member
Activity: 459
Merit: 250
Removed my previous post.. figured it out...  now I need to find a reliable way to determine what the address_version is...

full member
Activity: 127
Merit: 100
Got this after MySQL was restarted, maybe while Abe was using it.

Code:
Failed to catch up {'blkfile_number': 1, 'dirname': '/home/bitcoin/.bitcoin', 'chain_id': None, 'id': Decimal('1'), 'blkfile_offset': 945735848}
Traceback (most recent call last):
  File "Abe/DataStore.py", line 2141, in catch_up
    store.catch_up_dir(dircfg)
  File "Abe/DataStore.py", line 2162, in catch_up_dir
    store.import_blkdat(dircfg, ds)
  File "Abe/DataStore.py", line 2277, in import_blkdat
    store.import_block(b, chain_ids = chain_ids)
  File "Abe/DataStore.py", line 1479, in import_block
    tx['tx_id'] = store.import_and_commit_tx(tx, pos == 0)
  File "Abe/DataStore.py", line 1866, in import_and_commit_tx
    tx_id = store.import_tx(tx, is_coinbase)
  File "Abe/DataStore.py", line 1798, in import_tx
    store.intin(tx['lockTime']), len(tx['tx'])))
  File "Abe/DataStore.py", line 403, in sql
    store.cursor.execute(cached, params)
  File "/usr/lib/pymodules/python2.6/MySQLdb/cursors.py", line 166, in execute
    self.errorhandler(self, exc, value)
  File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 35, in defaulterrorhandler
    raise errorclass, errorvalue
IntegrityError: (1062, "Duplicate entry '1474' for key 'PRIMARY'")
ROLLBACK

1474 seems to refer to the tx table, which is ofcause at a much higher id than that (2.2m+)

Any suggestion as how to reset the id Abe will use ?
I will look more into it, hopefully getting it working again Smiley



[UPDATE] Ran the SQL to reset seq numbers from last page, and its running again.
Seems to be happy, at least no errors Smiley
donator
Activity: 2772
Merit: 1019
ok, I did this:

Quote
litecoin=> update block set block_satoshi_seconds=1335443292248335697512, block_total_ss=1750296912974188663950, block_ss_destroyed=218178294634342867 where block_id=68442;

which I think is correct (values from another instance). back to operational state.
donator
Activity: 2772
Merit: 1019
Had that happen to me. I tried whatnot, I had to start ALL OVER again.

clearly the reason is missing value for "block_satoshi_seconds". here are the last 2 blocks:

Quote
litecoin=> select * from block where block_id >= 68441;
-[ RECORD 1 ]---------+-----------------------------------------------------------------------------
block_id              | 68441
block_hash            | 32b88211213afa2967292d62d9ef7062701c0eefba5fc93357150007475f48f0
block_version         | 1
block_hashmerkleroot  | 479d09b39383373e6966073d9a5d36fbe7daf844f6a69305e959850449f84331
block_ntime           | 1326989099
block_nbits           | 486596529
block_nnonce          | 32342
block_height          | 67997
prev_block_id         | 68440
block_chain_work      | 00000000000000000000000000000000000000000000000000000000000000008cf2a594e20c
block_value_in        | 50001000270
block_value_out       | 55001000270
block_total_satoshis  | 341354059492795
block_total_seconds   | 9016434
block_satoshi_seconds | 1341706815903229013235
block_total_ss        | 1752272617217106557696

block_num_tx          | 2
block_ss_destroyed    | 203189392579199160
-[ RECORD 2 ]---------+-----------------------------------------------------------------------------
block_id              | 68442
block_hash            | 36228438219fb8599bcdd96163c025e1930b97383c025f9b4950636f9875c3d9
block_version         | 1
block_hashmerkleroot  | 3803d4347db77a2277e484f06f2043f643e8cc1914fbcbc7b344b959744f3b8b
block_ntime           | 1326989519
block_nbits           | 486596529
block_nnonce          | 32838
block_height          | 67998
prev_block_id         | 68441
block_chain_work      | 00000000000000000000000000000000000000000000000000000000000000008cf3ca8e7ea6
block_value_in        | 56233821563
block_value_out       | 61233821563
block_total_satoshis  | 341359059492795
block_total_seconds   | 9016854
block_satoshi_seconds |
block_total_ss        |

block_num_tx          | 4
block_ss_destroyed    |

now trying to fix this somehow, I can see 2 options:

  • remove that last block (block_id 68442) from db and have it be reinserted (don't know how exactly)
  • fill block 68442 (last block) block_satoshi_seconds and block_total_ss with correct values

ideas?
legendary
Activity: 1862
Merit: 1011
Reverse engineer from time to time
Had that happen to me. I tried whatnot, I had to start ALL OVER again.
donator
Activity: 2772
Merit: 1019
I'm experiencing a problem I can't quite put my finger on:

Quote
litecoin@void:~/bitcoin-abe$ Abe/abe.py --config=abe_pg.conf --no-serve
block_tx 69604 230654
block_tx 69604 230655
Failed to catch up {'blkfile_number': 1, 'dirname': '/home/litecoin/.litecoin', 'chain_id': None, 'id': Decimal('2'), 'blkfile_offset': 393411764}
Traceback (most recent call last):
  File "/home/litecoin/bitcoin-abe/Abe/DataStore.py", line 2141, in catch_up
    store.catch_up_dir(dircfg)
  File "/home/litecoin/bitcoin-abe/Abe/DataStore.py", line 2162, in catch_up_dir
    store.import_blkdat(dircfg, ds)
  File "/home/litecoin/bitcoin-abe/Abe/DataStore.py", line 2277, in import_blkdat
    store.import_block(b, chain_ids = chain_ids)
  File "/home/litecoin/bitcoin-abe/Abe/DataStore.py", line 1597, in import_block
    b['ss'] = prev_ss + ss_created - b['ss_destroyed']
TypeError: unsupported operand type(s) for +: 'NoneType' and 'long'

any idea?
legendary
Activity: 1862
Merit: 1011
Reverse engineer from time to time
Here is an offset for you guys to use if you indexed above block 93,000(I rounded this), and you screwed ABE somehow.

Change the offset to 52169990 and abe will not start from 0, and offset 930044092 for 163k or so.
Pages:
Jump to: