Bitcoin Forum
June 18, 2025, 03:36:23 AM *
News: Latest Bitcoin Core release: 29.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: How to read wallet.dat in PHP?  (Read 873 times)
codler (OP)
Full Member
***
Offline Offline

Activity: 191
Merit: 100



View Profile
March 23, 2014, 05:23:38 PM
 #1

I am trying to read content of wallet.dat in PHP and I have search around and it seems surprisingly no one has mention it before.

I have this code which I am trying to loop around all the key/values in wallet.dat but I only get one key, "main". I guess main seems to be logical db name. ( https://github.com/bitcoin/bitcoin/blob/v0.9.0/src/db.cpp#L260 ) Do anyone know why it only finds main and not other key/values? The wallet is unencrypted.

Code
Code:
<?php
print_r
(dba_handlers(true));

$id dba_popen("wallet.dat""r""db4");

if (!
$id) {
    echo 
"dba_open failed\n";
    exit;
}

$key dba_firstkey($id);
$keys = array();
while (
$key != false) {
    
$value dba_fetch($key$id);
    
$keys[] = array($key$value);
    
$key dba_nextkey($id);
}

print_r($keys);

dba_close($id);

Output
Code:
Array
(
    [db4] => Berkeley DB 4.8.24: (August 14, 2009)
)
Array
(
    [0] => Array
        (
            [0] => main
            [1] => 
        )

)

I ran this in XAMPP 1.7.3 which has PHP 5.3.1 and php_dba.dll

Ditto
Sr. Member
****
Offline Offline

Activity: 330
Merit: 250


View Profile
April 03, 2014, 10:36:19 PM
 #2

You should probably check out the source of PyWallet. Or the client.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!