def __init__(self, log, name, wallet, blockchain): super(WalletAccount, self).__init__() self.name = name self.wallet = wallet self.blockchain = blockchain self.blockchain.subscribe(blockchain.EVT_NEW_HIGHEST_BLOCK, self.on_new_highest_block) self.log = log self.lastblock_time = 0 self.last_tx_publish = {} self.confirmed_outputs = [] self.unconfirmed_outputs = [] self.confirmed_transactions = {} self.unconfirmed_transactions = {} #Satoshi wallet format doesn't store confirmations so we have #to recompute confirmations every time. self.blockchain_height = self.blockchain.get_height() self.compute_balances() self.coin_selector = CoinSelector() self.schedule_republish_transactions()
from coinpy.lib.wallet.wallet import Wallet from coinpy.lib.wallet.bsddb.bsddb_wallet_database import BSDDBWalletDatabase from coinpy.lib.wallet.coin_selector import CoinSelector from coinpy.tools.bitcoin.base58check import decode_base58check from coinpy.model.constants.bitcoin import COIN from coinpy.lib.vm.vm import TxValidationVM import os runmode = TESTNET wallet_filename = "D:\\repositories\\coinpy\\coinpy-client\\src\\data\\testnet\\wallet_testnet.dat" directory, filename = os.path.split(wallet_filename) bsddb_env = BSDDBEnv(directory) wallet = Wallet(None, BSDDBWalletDatabase(bsddb_env, filename), runmode) selector = CoinSelector() amount, fee = 145.0065 * COIN, 0 * COIN #list of (txhash, tx, index, txout) outputs = list(wallet.iter_my_outputs()) selected_outputs = selector.select_coins(outputs, amount + fee) tx = create_pubkeyhash_transaction( selected_outputs, decode_base58check("n4MsBRWD7VxKGsqYRSLaFZC6hQrsrKLaZo"), decode_base58check("n4MsBRWD7VxKGsqYRSLaFZC6hQrsrKLaZo"), amount, fee) sign_transaction(tx, selected_outputs) vm = TxValidationVM() print tx print len(selected_outputs) print vm.validate(tx, 0, selected_outputs[0].txout.script, tx.in_list[0].script) print vm.validate(tx, 1, selected_outputs[1].txout.script,