Bitcoin Forum
September 27, 2018, 10:05:16 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: How to read wallet.dat in PHP?  (Read 776 times)
codler
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

Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1538085916
Hero Member
*
Offline Offline

Posts: 1538085916

View Profile Personal Message (Offline)

Ignore
1538085916
Reply with quote  #2

1538085916
Report to moderator
1538085916
Hero Member
*
Offline Offline

Posts: 1538085916

View Profile Personal Message (Offline)

Ignore
1538085916
Reply with quote  #2

1538085916
Report to moderator
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:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!