def __init__(self, wallet, db=None, blockchain=None, zeroconf=False, sync_period=600, db_dir=None): """Initialize the payment server. Args: wallet (two1.wallet.Wallet): wallet instance. db (.models.ChannelDataManager): a database wrapper to manage the payment channel server's interface with a persistent store of data. blockchain (two1.blockchain.provider): a blockchain data provider capable of broadcasting raw transactions. zeroconf (boolean): whether or not to use a payment channel before the deposit transaction has been confirmed by the network. sync_period (integer): how often to sync channel status (in sec). """ if blockchain is None: url = PaymentServer.DEFAULT_TWENTYONE_BLOCKCHAIN_URL if wallet.testnet: url = PaymentServer.DEFAULT_TWENTYONE_TESTNET_BLOCKCHAIN_URL blockchain = TwentyOneBlockchain(url) self.zeroconf = zeroconf self._wallet = Two1WalletWrapper(wallet, blockchain) self._blockchain = blockchain self._db = db if db is None: self._db = DatabaseSQLite3(db_dir=db_dir) self._sync_stop = threading.Event() self._sync_thread = threading.Thread( target=self._auto_sync, args=(sync_period, self._sync_stop), daemon=True) self._sync_thread.start()
def __init__(self, wallet, db=None, account='default', testnet=False, blockchain=None, zeroconf=False, sync_period=600, db_dir=None): """Initalize the payment server. Args: wallet (.wallet.Two1WalletWrapper): a two1 wallet wrapped with payment server functionality. db (.models.ChannelDataManager): a database wrapper to manage the payment channel server's interface with a persistent store of data. account (string): which account within the wallet to use (e.g. 'merchant', 'customer', 'default', etc). testnet (boolean): whether or not the server should broadcast and verify transactions against the bitcoin testnet blockchain. blockchain (two1.blockchain.provider): a blockchain data provider capable of broadcasting raw transactions. zeroconf (boolean): whether or not to use a payment channel before the deposit transaction has been confirmed by the network. sync_period (integer): how often to sync channel status (in sec). """ self.zeroconf = zeroconf self._wallet = Two1WalletWrapper(wallet, account) self._blockchain = blockchain self._db = db if db is None: self._db = DatabaseSQLite3(db_dir=db_dir) if blockchain is None: self._blockchain = TwentyOneBlockchain( PaymentServer.DEFAULT_TWENTYONE_BLOCKCHAIN_URL if not self._wallet._wallet.testnet else PaymentServer.DEFAULT_TWENTYONE_TESTNET_BLOCKCHAIN_URL) self._sync_stop = threading.Event() self._sync_thread = threading.Thread(target=self._auto_sync, args=(sync_period, self._sync_stop), daemon=True) self._sync_thread.start()