def GetUnclaimed(self, hash): tx, height = self.GetTransaction(hash) if tx is None: return None out = {} coins = DBCollection(self._db, DBPrefix.ST_SpentCoin, SpentCoinState) state = coins.TryGet(keyval=hash.ToBytes()) if state: for item in state.Items: out[item.index] = SpentCoin(tx.outputs[item.index], height, item.height) return out
def CalculateBonus(inputs, height_end): unclaimed = [] for hash, group in groupby(inputs, lambda x: x.PrevHash): tx, height_start = Blockchain.Default().GetTransaction(hash) if tx is None: raise Exception("Could Not calculate bonus") if height_start == height_end: continue for coinref in group: if coinref.PrevIndex >= len(tx.outputs) or tx.outputs[coinref.PrevIndex].AssetId != Blockchain.SystemShare().Hash: raise Exception("Invalid coin reference") spent_coin = SpentCoin(output=tx.outputs[coinref.PrevIndex], start_height=height_start, end_height=height_end) unclaimed.append(spent_coin) return Blockchain.CalculateBonusInternal(unclaimed)