def __init__(self, public, is_mainnet): self._path = 'main123' if is_mainnet else 'test123' self.AddressVersion = 23 self._lock = RLock() self._indexedDB = Blockchain.Default() self.BuildDatabase() self._keys = {} self._contracts = self.LoadContracts() for key, contract in self._contracts.items(): print('contract ScriptHash', contract.ScriptHash) print('initializing', flush=True) kp = OnlyPublicKeyPair(public) self._keys[kp.PublicKeyHash.ToBytes()] = kp contract = WalletContract.CreateSignatureContract(kp.PublicKey) if contract.ScriptHash.ToBytes() not in self._contracts.keys(): self._contracts[contract.ScriptHash.ToBytes()] = contract sh = bytes(contract.ScriptHash.ToArray()) address, created = Address.get_or_create(ScriptHash=sh) address.IsWatchOnly = False address.save() db_contract = Contract.create(RawData=contract.ToArray(), ScriptHash=contract.ScriptHash.ToBytes(), PublicKeyHash=contract.PublicKeyHash.ToBytes(), Address=address, Account=None ) self.LoadNamedAddresses() self._watch_only = self.LoadWatchOnly() self._tokens = self.LoadNEP5Tokens() self._coins = self.LoadCoins() # self.initialize_holds() self._holds = VINHold.filter(IsComplete=False) # Handle EventHub events for SmartContract decorators @events.on(SmartContractEvent.RUNTIME_NOTIFY) def call_on_event(sc_event): # Make sure this event is for this specific smart contract self.on_notify_sc_event(sc_event) try: self._current_height = int(self.LoadStoredData('Height')) except: print('setting height to 0') self._current_height = 0 self.SaveStoredData('Height', self._current_height)
def LoadCompletedHolds(self): return VINHold.filter(IsComplete=True)
def LoadHolds(self): self._holds = VINHold.filter(IsComplete=False) return self._holds