Пример #1
0
 def open_wallet(self, filename):
     directory, basename = os.path.split(filename)
     dbenv = self.get_dbenv_handle(directory)
     
     uid = bsddb_read_file_uid(filename)
     if uid in dbenv.open_file_uids:
         raise Exception("Multiple wallets with the same uid unsupported in the same directory.")
     wallet_db = BSDDBWalletDatabase(dbenv, basename)
     wallet = Wallet(wallet_db, self.clientparams.runmode)
     wallet.open()
     account = WalletAccount(self.log, basename, wallet, self.blockchain)
     TransactionPublisher(self.node, account)
     self.account_set.add_account(account)
     self.account_infos[account] = (dbenv, directory, basename)
     #add uid last in case something went wrong before
     dbenv.open_file_uids.add(uid)
Пример #2
0
    def new_wallet(self, filename, passphrase):
        directory, basename = os.path.split(filename)
        dbenv = self.get_dbenv_handle(directory)

        wallet_db = BSDDBWalletDatabase(dbenv, basename)
        wallet_db.create()

        wallet = Wallet(wallet_db, self.clientparams.runmode)
        wallet.create(passphrase)
        #add file uid to list
        dbenv.open_file_uids.add(bsddb_read_file_uid(filename))

        account = WalletAccount(self.log, basename, wallet, self.blockchain)
        TransactionPublisher(self.node, account)
        self.account_set.add_account(account)
        self.account_infos[account] = (dbenv, directory, basename)
Пример #3
0
 def new_wallet(self, filename, passphrase):
     directory, basename = os.path.split(filename)
     dbenv = self.get_dbenv_handle(directory)
     
     wallet_db = BSDDBWalletDatabase(dbenv, basename)
     wallet_db.create()
     
     wallet = Wallet(wallet_db, self.clientparams.runmode)
     wallet.create(passphrase)
     #add file uid to list
     dbenv.open_file_uids.add(bsddb_read_file_uid(filename))
     
     
     account = WalletAccount(self.log, basename, wallet, self.blockchain)
     TransactionPublisher(self.node, account)
     self.account_set.add_account(account)
     self.account_infos[account] = (dbenv, directory, basename)
Пример #4
0
    def open_wallet(self, filename):
        directory, basename = os.path.split(filename)
        dbenv = self.get_dbenv_handle(directory)

        uid = bsddb_read_file_uid(filename)
        if uid in dbenv.open_file_uids:
            raise Exception(
                "Multiple wallets with the same uid unsupported in the same directory."
            )
        wallet_db = BSDDBWalletDatabase(dbenv, basename)
        wallet = Wallet(wallet_db, self.clientparams.runmode)
        wallet.open()
        account = WalletAccount(self.log, basename, wallet, self.blockchain)
        TransactionPublisher(self.node, account)
        self.account_set.add_account(account)
        self.account_infos[account] = (dbenv, directory, basename)
        #add uid last in case something went wrong before
        dbenv.open_file_uids.add(uid)
Пример #5
0
    from coinpy_tests.mock import Mock
    from coinpy.model.protocol.runmode import MAIN, TESTNET
    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,
Пример #6
0
if __name__ == '__main__':
    #n4MsBRWD7VxKGsqYRSLaFZC6hQrsrKLaZo
    import wx
    from coinpy_client.view.wallet.wallet_panel import WalletPanel
    from coinpy.tools.bsddb.bsddb_env import BSDDBEnv
    from coinpy_tests.mock import Mock
    from coinpy.model.protocol.runmode import MAIN, TESTNET
    from coinpy_client.view.message_view import MessageView

    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)
    balance = Mock(
        {
            "get_confirmed": 175877,
            "get_unconfirmed": 2828727,
            "get_height": 3
        },
        accept_all_methods=True)

    wallet_account = Mock(attributes={})

    app = wx.App(False)
    frame = wx.Frame(None, size=(600, 500))
    wallet_view = WalletPanel(None, frame)
    AccountPresenter(wallet_account, wallet_view, MessageView(None))
Пример #7
0
    from coinpy_tests.mock import Mock
    from coinpy.model.protocol.runmode import MAIN, TESTNET
    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()