def getVoteForce(address, **kw): # determine timestamp balance = kw.pop("balance", False)/100000000. if not balance: balance = float(api.GET.accounts.getBalance(address=address, returnKey="balance"))/100000000. delta = slots.datetime.timedelta(**kw) if delta.total_seconds() < 86400: return balance now = slots.datetime.datetime.now(slots.pytz.UTC) timestamp_limit = slots.getTime(now - delta) # get transaction history history = getHistory(address, timestamp_limit) # if no transaction over periode integrate balance over delay and return it if not history: return balance*delta.total_seconds()/3600 # else end = slots.getTime(now) sum_ = 0. brk = False for tx in history: delta_t = (end - tx["timestamp"])/3600 sum_ += balance * delta_t balance += ((tx["fee"]+tx["amount"]) if tx["senderId"] == address else -tx["amount"])/100000000. if tx["type"] == 3: brk = True break end = tx["timestamp"] if not brk: sum_ += balance * (end - timestamp_limit)/3600 return sum_
def __init__(self, **kwargs): # the four minimum attributes that defines a transaction self.type = kwargs.pop("type", 0) self.amount = kwargs.pop("amount", 0) self.timestamp = slots.getTime() - 60 # get backward 60s to avoid error:Invalid transaction timestamp self.asset = kwargs.pop("asset", ArkyDict()) for attr,value in kwargs.items(): setattr(self, attr, value)
def __init__(self, **kwargs): """ >>> Transaction(amount=100000000, secret="secret") <unsigned type-0 transaction(A1.00000000) from a3T1iRdHFt35bKY8RX1bZBGbenmmKZ12yR to "No one"> """ # the four minimum attributes that defines a transaction self.type = kwargs.pop("type", 0) self.amount = kwargs.pop("amount", 0) self.timestamp = slots.getTime( ) - 60 # get backward 60s to avoid error:Invalid transaction timestamp self.asset = kwargs.pop("asset", ArkyDict()) for attr, value in kwargs.items(): setattr(self, attr, value)
def bakeTransaction(**kw): if "publicKey" in kw and "privateKey" in kw: public, private = kw["publicKey"], kw["privateKey"] elif "secret" in kw: public, private = getKeys(kw["secret"]) else: raise Exception("Can not initialize transaction (no secret or keys given)") # put mandatory data payload = { "timestamp": int(slots.getTime()), "type": int(kw.get("type", 0)), "amount": int(kw.get("amount", 0)), "fee": cfg.fees.get({ 0: "send", 1: "secondsignature", 2: "delegate", 3: "vote", # 4: "multisignature", # 5: "dapp" }[kw.get("type", 0)]) } payload["senderPublicKey"] = public # add optional data for key in (k for k in ["requesterPublicKey", "recipientId", "asset"] if k in kw): payload[key] = kw[key] # sign payload payload["signature"] = getSignature(payload, private) if kw.get("secondSecret", None): secondPublic, secondPrivate = getKeys(kw["secondSecret"]) payload["signSignature"] = getSignature(payload, secondPrivate) elif kw.get("secondPrivateKey", None): payload["signSignature"] = getSignature(payload, kw["secondPrivateKey"]) # identify payload payload["id"] = getId(payload) return payload