def iter_transaction_history(self): # see wallet.cpp:448 GetAmounts for hash, wallet_tx in self.wallet_database.get_wallet_txs().iteritems(): debit = self.get_debit_tx(wallet_tx) for txout in wallet_tx.merkle_tx.tx.out_list: address = extract_txout_address(txout, self.runmode) name = "" #print self.get_names() #print encode_base58check(chr(ADDRESSVERSION[self.runmode]) + address) if address and address in self.get_names(): name = self.get_names()[address].name if debit > 0 and self.is_change(txout): pass elif debit > 0: yield (wallet_tx, hash, wallet_tx.time_received, address, name, -txout.value) elif self.is_mine(txout): yield (wallet_tx, hash, wallet_tx.time_received, address, name, txout.value)
def iter_transaction_history(self): # see wallet.cpp:448 GetAmounts for hash, wallet_tx in self.wallet_database.get_wallet_txs().iteritems( ): debit = self.get_debit_tx(wallet_tx) for txout in wallet_tx.merkle_tx.tx.out_list: address = extract_txout_address(txout, self.runmode) name = "" #print self.get_names() #print encode_base58check(chr(ADDRESSVERSION[self.runmode]) + address) if address and address in self.get_names(): name = self.get_names()[address].name if debit > 0 and self.is_change(txout): pass elif debit > 0: yield (wallet_tx, hash, wallet_tx.time_received, address, name, -txout.value) elif self.is_mine(txout): yield (wallet_tx, hash, wallet_tx.time_received, address, name, txout.value)
def is_change(self, txout): # Fix to be implemented in main client, see wallet.cpp:390 # current bad assumption is that any payment to a TX_PUBKEYHASH that # is mine but isn't in the address book is change. address = extract_txout_address(txout, self.runmode) return self.is_mine(txout) and (address not in self.get_names())
def is_mine(self, txout): address = extract_txout_address(txout, self.runmode) if not address: # if unknown script type, return False return False return self.have_key_for_addresss(address)
def get_txout_private_key_secret(self, txout): address = extract_txout_address(txout, self.runmode) public_key, is_crypted = self.addresses[address] return self.get_private_key_secret(public_key)
def is_passphrase_required(self, txout): address = extract_txout_address(txout, self.runmode) _, is_crypted = self.addresses[address] return is_crypted
return self.wallet_database.get_block_locator().highest() def is_change(self, txout): # Fix to be implemented in main client, see wallet.cpp:390 # current bad assumption is that any payment to a TX_PUBKEYHASH that # is mine but isn't in the address book is change. address = extract_txout_address(txout, self.runmode) return self.is_mine(txout) and (address not in self.get_names()) def get_master_keys(self): return self.wallet_database.get_master_keys() if __name__ == '__main__': from coinpy.model.protocol.runmode import MAIN, TESTNET, TESTNET3 from coinpy.lib.wallet.formats.bitcoinqt.bsddb_wallet_database import BSDDBWalletDatabase dbenv = BSDDBEnv(r"C:\bitcoin-0.7.2\data\testnet\testnet3") wallet_db = BSDDBWalletDatabase(dbenv, "wallet.dat") wallet = Wallet(wallet_db, TESTNET3) wallet.open() for tx, outpoint, txout in wallet.iter_my_outputs(): print extract_txout_address(txout, TESTNET3), (txout.value / COIN) for date, address, name, amount in wallet.iter_transaction_history(): print date, address, name, amount for (public_key, is_crypted, address, description) in wallet.iterkeys(): print hexstr(public_key) #print wallet.get_balance() * 1.0 / COIN # encode_base58check(chr(ADDRESSVERSION[runmode]) + hash160(public_key))
def is_change(self, txout): # Fix to be implemented in main client, see wallet.cpp:390 # current bad assumption is that any payment to a TX_PUBKEYHASH that # is mine but isn't in the address book is change. address = extract_txout_address(txout, self.runmode) return self.is_mine(txout) and (address not in self.get_names())
def is_mine(self, txout): address = extract_txout_address(txout, self.runmode) if not address: # if unknown script type, return False return False return self.have_key_for_addresss(address)
def get_txout_private_key_secret(self, txout): address = extract_txout_address(txout, self.runmode) public_key, is_crypted = self.addresses[address] return self.get_private_key_secret(public_key)
def is_passphrase_required(self, txout): address = extract_txout_address(txout, self.runmode) _, is_crypted = self.addresses[address] return is_crypted
if locator: return self.wallet_database.get_block_locator().highest() def is_change(self, txout): # Fix to be implemented in main client, see wallet.cpp:390 # current bad assumption is that any payment to a TX_PUBKEYHASH that # is mine but isn't in the address book is change. address = extract_txout_address(txout, self.runmode) return self.is_mine(txout) and (address not in self.get_names()) def get_master_keys(self): return self.wallet_database.get_master_keys() if __name__ == '__main__': from coinpy.model.protocol.runmode import MAIN, TESTNET, TESTNET3 from coinpy.lib.wallet.formats.bitcoinqt.bsddb_wallet_database import BSDDBWalletDatabase dbenv = BSDDBEnv(r"C:\bitcoin-0.7.2\data\testnet\testnet3") wallet_db = BSDDBWalletDatabase(dbenv, "wallet.dat") wallet = Wallet(wallet_db, TESTNET3) wallet.open() for tx, outpoint, txout in wallet.iter_my_outputs(): print extract_txout_address(txout, TESTNET3), (txout.value / COIN) for date, address, name, amount in wallet.iter_transaction_history(): print date, address, name, amount for (public_key, is_crypted, address, description) in wallet.iterkeys(): print hexstr(public_key) #print wallet.get_balance() * 1.0 / COIN # encode_base58check(chr(ADDRESSVERSION[runmode]) + hash160(public_key))