def do_import(self, arguments): item = get_arg(arguments) if item: if item == 'wif': if not self.Wallet: print("Please open a wallet before importing WIF") return wif = get_arg(arguments, 1) if wif: prikey = KeyPair.PrivateKeyFromWIF(wif) if prikey: key = self.Wallet.CreateKey(prikey) print("imported key %s " % wif) print("Pubkey: %s \n" % key.PublicKey.encode_point(True).hex()) print("Wallet: %s " % json.dumps(self.Wallet.ToJson(), indent=4)) else: print("invalid wif") return elif item == 'contract': return self.load_smart_contract(arguments) elif item == 'contract_addr': return ImportContractAddr(self.Wallet, arguments[1:]) print("please specify something to import") return
def execute(self, arguments): wallet = PromptData.Wallet if len(arguments) != 2: print("Please specify the required parameters") return try: contract_hash = UInt160.ParseString(arguments[0]).ToBytes() except Exception: print(f"Invalid contract hash: {arguments[0]}") return pubkey = arguments[1] if not PromptUtils.is_valid_public_key(pubkey): print(f"Invalid pubkey: {arguments[1]}") return pubkey_script_hash = Crypto.ToScriptHash(pubkey, unhex=True) return ImportContractAddr(wallet, contract_hash, pubkey_script_hash)
def do_import(self, arguments): item = get_arg(arguments) if not item: print("please specify something to import") return if item == 'wif': if not self.Wallet: print("Please open a wallet before importing WIF") return wif = get_arg(arguments, 1) if not wif: print("Please supply a valid WIF key") return try: prikey = KeyPair.PrivateKeyFromWIF(wif) key = self.Wallet.CreateKey(prikey) print("Imported key %s " % wif) print("Pubkey: %s \n" % key.PublicKey.encode_point(True).hex()) print("Wallet: %s " % json.dumps(self.Wallet.ToJson(), indent=4)) except ValueError as e: print(str(e)) except Exception as e: print(str(e)) return elif item == 'nep2': if not self.Wallet: print("Please open a wallet before importing a NEP2 key") return nep2_key = get_arg(arguments, 1) if not nep2_key: print("Please supply a valid nep2 encrypted private key") return nep2_passwd = prompt("[Key Password]> ", is_password=True) try: prikey = KeyPair.PrivateKeyFromNEP2(nep2_key, nep2_passwd) key = self.Wallet.CreateKey(prikey) print("Imported nep2 key: %s " % nep2_key) print("Pubkey: %s \n" % key.PublicKey.encode_point(True).hex()) print("Wallet: %s " % json.dumps(self.Wallet.ToJson(), indent=4)) except ValueError as e: print(str(e)) except Exception as e: print(str(e)) return elif item == 'contract': return self.load_smart_contract(arguments) elif item == 'contract_addr': return ImportContractAddr(self.Wallet, arguments[1:]) elif item == 'watch_addr': return ImportWatchAddr(self.Wallet, get_arg(arguments, 1)) elif item == 'multisig_addr': return ImportMultiSigContractAddr(self.Wallet, arguments[1:]) elif item == 'token': return ImportToken(self.Wallet, get_arg(arguments, 1)) else: print("Import of '%s' not implemented" % item)
def importContract(self): print(self.neo_fund_sc) self.contract_addr = ImportContractAddr( self.Wallet, [self.neo_fund_sc, self.wallet_pub]).Address