Pages:
Author

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

legendary
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
Donation sent!


Hope everyone will appreciate Bitcoinchipin when its released this weekend Smiley

Hey wheres the "Powered by Bitcoin-Abe" logo at?  Wink
legendary
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
For anyone who was curious. I ended up using bitcoin-php library to convert address to hash160 using the (almost obvious name) addressToHash160() function. It worked like a charm.
hero member
Activity: 481
Merit: 529
Is this donation address still valid?: 1PWC7PNHL1SgvZaN7xEtygenKjWobWsCuf
Yes, it is.  Thanks.
legendary
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
Oh yeah I forgot to ask, what needs to be changed to this query to get the "total over all received" balance?
Take out the first sub-select and simplify, leaving this:
Code:
    SELECT SUM(txout.txout_value) / 100000000
      FROM pubkey
      JOIN txout ON txout.pubkey_id=pubkey.pubkey_id
      JOIN block_tx ON block_tx.tx_id=txout.tx_id
      JOIN block b ON b.block_id=block_tx.block_id
      JOIN chain_candidate cc ON cc.block_id=b.block_id
      WHERE
          pubkey.pubkey_hash = LOWER('11B366EDFC0A8B66FEEBAE5C2E25A7B6A5D1CF31') AND
          cc.chain_id = 1 AND
          cc.in_longest = 1


Excellent worked again!

Is this donation address still valid?: 1PWC7PNHL1SgvZaN7xEtygenKjWobWsCuf
hero member
Activity: 481
Merit: 529
Oh yeah I forgot to ask, what needs to be changed to this query to get the "total over all received" balance?
Take out the first sub-select and simplify, leaving this:
Code:
    SELECT SUM(txout.txout_value) / 100000000
      FROM pubkey
      JOIN txout ON txout.pubkey_id=pubkey.pubkey_id
      JOIN block_tx ON block_tx.tx_id=txout.tx_id
      JOIN block b ON b.block_id=block_tx.block_id
      JOIN chain_candidate cc ON cc.block_id=b.block_id
      WHERE
          pubkey.pubkey_hash = LOWER('11B366EDFC0A8B66FEEBAE5C2E25A7B6A5D1CF31') AND
          cc.chain_id = 1 AND
          cc.in_longest = 1
legendary
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
This seems to work.  Note that the database has no function to translate an address into a public key hash.  I assume you can do this in PHP.  The example uses address 12cbQLTFMXRnSzktFkuoG3eHoMeFtpTu3S, whose hash is 11b366edfc0a8b66feebae5c2e25a7b6a5d1cf31.  The hash appears in two places in the query.
Code:
SELECT SUM(value) / 100000000 AS balance FROM (
    SELECT -txout.txout_value AS value
      FROM pubkey
      JOIN txout ON txout.pubkey_id=pubkey.pubkey_id
      JOIN txin ON txin.txout_id=txout.txout_id
      JOIN block_tx ON block_tx.tx_id=txout.tx_id
      JOIN block b ON b.block_id=block_tx.block_id
      JOIN chain_candidate cc ON cc.block_id=b.block_id
      WHERE
          pubkey.pubkey_hash = LOWER('11B366EDFC0A8B66FEEBAE5C2E25A7B6A5D1CF31') AND
          cc.chain_id = 1 AND
          cc.in_longest = 1
    UNION ALL
    SELECT txout.txout_value AS value
      FROM pubkey
      JOIN txout ON txout.pubkey_id=pubkey.pubkey_id
      JOIN block_tx ON block_tx.tx_id=txout.tx_id
      JOIN block b ON b.block_id=block_tx.block_id
      JOIN chain_candidate cc ON cc.block_id=b.block_id
      WHERE
          pubkey.pubkey_hash = LOWER('11B366EDFC0A8B66FEEBAE5C2E25A7B6A5D1CF31') AND
          cc.chain_id = 1 AND
          cc.in_longest = 1
) a;
Oh yeah I forgot to ask, what needs to be changed to this query to get the "total over all received" balance?
hero member
Activity: 481
Merit: 529
Dude your awsome!, I would have never figured that query out on my own -- works great too
Thanks for confirming.
legendary
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
This seems to work.  Note that the database has no function to translate an address into a public key hash.  I assume you can do this in PHP.  The example uses address 12cbQLTFMXRnSzktFkuoG3eHoMeFtpTu3S, whose hash is 11b366edfc0a8b66feebae5c2e25a7b6a5d1cf31.  The hash appears in two places in the query.
Code:
SELECT SUM(value) / 100000000 AS balance FROM (
    SELECT -txout.txout_value AS value
      FROM pubkey
      JOIN txout ON txout.pubkey_id=pubkey.pubkey_id
      JOIN txin ON txin.txout_id=txout.txout_id
      JOIN block_tx ON block_tx.tx_id=txout.tx_id
      JOIN block b ON b.block_id=block_tx.block_id
      JOIN chain_candidate cc ON cc.block_id=b.block_id
      WHERE
          pubkey.pubkey_hash = LOWER('11B366EDFC0A8B66FEEBAE5C2E25A7B6A5D1CF31') AND
          cc.chain_id = 1 AND
          cc.in_longest = 1
    UNION ALL
    SELECT txout.txout_value AS value
      FROM pubkey
      JOIN txout ON txout.pubkey_id=pubkey.pubkey_id
      JOIN block_tx ON block_tx.tx_id=txout.tx_id
      JOIN block b ON b.block_id=block_tx.block_id
      JOIN chain_candidate cc ON cc.block_id=b.block_id
      WHERE
          pubkey.pubkey_hash = LOWER('11B366EDFC0A8B66FEEBAE5C2E25A7B6A5D1CF31') AND
          cc.chain_id = 1 AND
          cc.in_longest = 1
) a;

Dude your awsome!, I would have never figured that query out on my own -- works great too
hero member
Activity: 481
Merit: 529
This seems to work.  Note that the database has no function to translate an address into a public key hash.  I assume you can do this in PHP.  The example uses address 12cbQLTFMXRnSzktFkuoG3eHoMeFtpTu3S, whose hash is 11b366edfc0a8b66feebae5c2e25a7b6a5d1cf31.  The hash appears in two places in the query.
Code:
SELECT SUM(value) / 100000000 AS balance FROM (
    SELECT -txout.txout_value AS value
      FROM pubkey
      JOIN txout ON txout.pubkey_id=pubkey.pubkey_id
      JOIN txin ON txin.txout_id=txout.txout_id
      JOIN block_tx ON block_tx.tx_id=txout.tx_id
      JOIN block b ON b.block_id=block_tx.block_id
      JOIN chain_candidate cc ON cc.block_id=b.block_id
      WHERE
          pubkey.pubkey_hash = LOWER('11B366EDFC0A8B66FEEBAE5C2E25A7B6A5D1CF31') AND
          cc.chain_id = 1 AND
          cc.in_longest = 1
    UNION ALL
    SELECT txout.txout_value AS value
      FROM pubkey
      JOIN txout ON txout.pubkey_id=pubkey.pubkey_id
      JOIN block_tx ON block_tx.tx_id=txout.tx_id
      JOIN block b ON b.block_id=block_tx.block_id
      JOIN chain_candidate cc ON cc.block_id=b.block_id
      WHERE
          pubkey.pubkey_hash = LOWER('11B366EDFC0A8B66FEEBAE5C2E25A7B6A5D1CF31') AND
          cc.chain_id = 1 AND
          cc.in_longest = 1
) a;
legendary
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
Yeah I don't see how to query mysql for the balance of a Bitcoin address in this thread, I checked every single message. I noticed their is a nice API system but I'm already running a webserver with apache/php so I think it might be cleaner to just query the mysql data straight from php instead of having php call back to the server through python and then to mysql.
hero member
Activity: 481
Merit: 529
Is there documentation on the table setup?

How do I query information on a particular address? (total received balance, transaction history,etc)
No, sorry, no docs on the tables.  Have you searched this thread for the answer?
legendary
Activity: 980
Merit: 1003
I'm not just any shaman, I'm a Sha256man
Is there documentation on the table setup?

How do I query information on a particular address? (total received balance, transaction history,etc)
donator
Activity: 308
Merit: 250
I'm very interested in seeing Firstbits support.

what exactly do you have in mind?

an api call "/q/firstbits/15ArtC" that returns "15ArtCgi3wmpQAAfYx4riaFmo4prJA4VsK"?

Yes. I'd prefer some SQL code, but I know that Abe doesn't store addresses in base58 form for now, so that'd be difficult to implement. What you describe is adequate.
donator
Activity: 2772
Merit: 1019
I'm very interested in seeing Firstbits support.

what exactly do you have in mind?

an api call "/q/firstbits/15ArtC" that returns "15ArtCgi3wmpQAAfYx4riaFmo4prJA4VsK"?
donator
Activity: 308
Merit: 250
I'm very interested in seeing Firstbits support.
sr. member
Activity: 459
Merit: 250
Might be a bit more than just a change in the header hashing..

During the import I noticed every 2nd block reported "Ignored bit8 in version 0x00000100 of chain_id 22".  Seemed a bit odd that every 2 blocks had a different header...

Reading the MMMCoin forum today through google's translator it turns out that the block chain links blocks differently. - http://mmmcoin.org/forum/viewtopic.php?f=8&t=84&start=20#p447

Every 2nd block put into the chain comes from the miners connected to the clients and the blocks in between are created by "trusted nodes".  If someone solves a block and it gets put into the chain, no one else can solve another block until one of the trusted nodes puts a block in.

miner block -> trusted node block -> miner block -> trusted node block  ... etc.

Seeing how every 2nd import by Abe reports ignoring bit8 I'd guess that there are 2 different block headers to process depending on the source of the block.
hero member
Activity: 481
Merit: 529
The import completed.

SQL results:
Code:
SELECT block_id FROM block WHERE block_hash LIKE '000003b4ef02c872071895b0308232%';

gave me empty results...
Thanks.  It looks as if MMMCoin uses a scrypt-like hash function.  Abe relies on the block header containing the previous block's Bitcoin hash (double SHA256).  Other scrypt-using chains apparently still use SHA256 for the previous-block pointer, or otherwise Abe couldn't link their blocks together.  If this is right, I actually prefer MMM's design, although it breaks Abe.

To fix it, we will need a Python implementation of MMMCoin's hashing algorithm.  Probably one exists, we just have to find and test it, and I'll think about how to support it compatibly.
sr. member
Activity: 459
Merit: 250
The import completed.

SQL results:
Code:
SELECT block_id FROM block WHERE block_hash LIKE '000003b4ef02c872071895b0308232%';

gave me empty results...
sr. member
Activity: 459
Merit: 250
Current status:

I had to enable the "ignore-bit8-chains" flag for MMMCoin.  It failed with the same error I had with the bitcoin testnet.

Import resumed.

Code:

commit
block_tx 1982463 5051769
commit
Ignored bit8 in version 0x00000100 of chain_id 22
block_tx 1982464 5051770
block_tx 1982464 5051771
commit
block_tx 1982465 5051772
block_tx 1982465 5051773
commit
Ignored bit8 in version 0x00000100 of chain_id 22
block_tx 1982466 5051774
block_tx 1982466 5051775
commit
block_tx 1982467 5051776
block_tx 1982467 5051777
commit
Ignored bit8 in version 0x00000100 of chain_id 22
block_tx 1982468 5051778
block_tx 1982468 5051779
commit
sr. member
Activity: 459
Merit: 250
Here's how a new import to a new db goes:

Code:
:~/apps/bitcoin-abe$ python -m Abe.abe --config imports/abe-mmcoin-test.conf
ddl_implicit_commit=true
create_table_epilogue=' ENGINE=InnoDB'
Abe/DataStore.py:418: Warning: Converting column 'a' from VARCHAR to TEXT
  store.cursor.execute(stmt)
Abe/DataStore.py:418: Warning: Converting column 'b' from VARCHAR to TEXT
  store.cursor.execute(stmt)
max_varchar=4294967295
clob_type=LONGTEXT
binary_type=hex
int_type=int
Created silly table abe_dual
sequence_type=mysql
limit_style=native
Assigned chain_id 8 to MMMCoin
block_tx 1 1
commit
block_tx 2 2
commit
block_tx 3 3
commit
block_tx 4 4
commit
block_tx 5 5
commit
block_tx 6 6
commit
block_tx 7 7
commit
block_tx 8 8
commit
block_tx 9 9
commit
block_tx 10 10

Config file:
Code:
:~/apps/bitcoin-abe$ cat imports/abe-mmcoin-test.conf
    dbtype MySQLdb
    connect-args {"host":"removedserver","user":"removedusername","db":"abe-test","passwd":"removedpassword"}
    no-serve
    commit-bytes = 0

datadir = [{
        "dirname":"/home/ed/.mmm",
        "chain":"MMMCoin",
        "code3":"MMM",
        "address_version":"\u0000"}]

And the same result when viewing through the web interface.
http://i147.photobucket.com/albums/r300/lethaltiker/F4D42AF6A0326EB5EB858F2D4510FB78.jpg
Pages:
Jump to: