コード例 #1
0
 def getAddressWallet(self, idx):
     contract = self.contracts[idx]
     if "address" in contract.keys():
         storage = WalletStorage(contract['addrWalletFile'])
         if storage.file_exists():
             wallet = Wallet(storage)
             return wallet
     else:
         return None
コード例 #2
0
    def create_multisig_addr(self,
                             idx,
                             partner_x_pubkey,
                             generated_by_me=True):
        wallet = self.getContractWallet(idx)
        c = commands.Commands(None, wallet, None)
        contract = self.contracts[idx]

        if 'address' in contract:
            print_msg(
                "Cash Rip**********************************Overwriting old contract. It will be saved in contracts-bkp.txt"
            )
            backupContract(contract)

        (partner_pubkey,
         partner_address) = keystore.xpubkey_to_address(partner_x_pubkey)
        if generated_by_me:
            multiaddress = c.createmultisig(
                2, [contract["my_pubkey"], partner_pubkey])
        else:
            multiaddress = c.createmultisig(
                2, [partner_pubkey, contract["my_pubkey"]])
        multiaddress["address"] = Address.from_string(
            multiaddress["address"]).to_ui_string()
        partner_address = partner_address.to_ui_string()

        contract.update(multiaddress)
        contract["partner_addr"] = partner_address
        contract["partner_x_pubkey"] = partner_x_pubkey
        contract["partner_pubkey"] = partner_pubkey
        contract["gen_by_me"] = generated_by_me

        addrWalletFile = contract["walletFile"][:-7] + "-address.wallet"
        #print("addrWalletFile: {}".format(addrWalletFile))
        storage = WalletStorage(addrWalletFile)
        if storage.file_exists():
            os.remove(addrWalletFile)
            storage = WalletStorage(addrWalletFile)
        #wal = ImportedAddressWallet.from_text(storage, contract["address"].to_ui_string())
        wal = ImportedAddressWallet.from_text(storage, contract["address"])
        wal.synchronize()
        wal.storage.write()
        print_msg("Wallet saved in '%s'" % wal.storage.path)
        contract["addrWalletFile"] = addrWalletFile
        #print_msg("contracts now: %s" % contracts)
        self.updateContracts()
        self.multiWallets[idx] = wal
        return contract
コード例 #3
0
ファイル: console.py プロジェクト: shphrd/coinsplitter
    def load_wallet(self, name, password=None):
        """Load a wallet"""
        self._assert_daemon_running()
        path = self._wallet_path(name)
        wallet = self.daemon.get_wallet(path)
        if not wallet:
            storage = WalletStorage(path)
            if not storage.file_exists():
                raise FileNotFoundError(path)
            if storage.is_encrypted():
                if not password:
                    raise util.InvalidPassword()
                storage.decrypt(password)

            wallet = Wallet(storage)
            wallet.start_threads(self.network)
            self.daemon.add_wallet(wallet)

        self.wallet = wallet
        self.network.notify("updated")
        return wallet
コード例 #4
0
                "Protocol execution Time Out"
                done = True
        for pThread in pThreads:
            pThread.join()
    else:
        basic_logger.send("[CashShuffle Bot] Nobody in the pools")


basic_logger = SimpleLogger()
args = parse_args()
# Get network
config = SimpleConfig({})
password = args.password
wallet_path = args.wallet
storage = WalletStorage(wallet_path)
if not storage.file_exists():
    basic_logger.send("Error: Wallet file not found.")
    sys.exit(0)
if storage.is_encrypted():
    storage.decrypt(password)
if args.testnet:
    NetworkConstants.set_testnet()
    config = SimpleConfig({'server': "bch0.kister.net:51002:s"})
network = Network(config)
network.start()
wallet = Wallet(storage)
wallet.start_threads(network)
coin = Coin(network)
# # setup server
port = args.port
host = args.server
コード例 #5
0
 def getContractWallet(self, idx):
     storage = WalletStorage(self.contracts[idx]['walletFile'])
     if storage.file_exists():
         wallet = Wallet(storage)
         return wallet