-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AIP 8: An improvement of transaction protocol #7
Comments
@Moustikitos check here: https://github.com/ArkEcosystem/ark-js/blob/mainnet/lib/transactions/crypto.js#L166 I have managed to parse toonsbuf to retrieve tx. Might be good to have it in python as well |
Okay... On it |
BTW are you sure requesterPublicKey field is needed ? Maybe a good thing to get rid of it. |
done. def fromBytes(data):
tx = Transaction()
buf = StringIO(data)
tx.type, tx.timestamp = unpack("<bi", buf)
object.__setattr__(tx, "key_one", ArkyDict(public=unpack_bytes(buf, 33)))
rid = unpack_bytes(buf, 21).replace(b"\x00", b"")
if rid != "" : tx.recipientId = base58.b58encode_check(rid)
tx.vendorField = unpack_bytes(buf, 64).replace(b"\x00", b"").decode()
tx.amount, fee = unpack("<QQ", buf)
idx = []
for i in range(len(data)):
if data[i] == 0x30:
j = i+data[i+1]+2
if j <= len(data):
try:
object.__setattr__(tx, "signature" if not hasattr(tx, "signature") else "signSignature", _hexlify(checkStrictDER(data[i:j])))
idx.append(i)
except StrictDerSignatureError:
pass
asset = data[buf.tell():min(idx)]
if tx.type == 1:
tx.asset = ArkyDict(signature=ArkyDict(public=_hexlify(asset)))
elif tx.type == 2:
tx.asset = ArkyDict(delegate=ArkyDict(username=asset.decode()))
elif tx.type == 3:
tx.asset = ArkyDict(votes=[asset[i:i+34].decode() for i in range(0, len(asset), 34)])
elif tx.type == 4:
pass
if hasattr(tx, "signature"):
object.__setattr__(tx, "id", _hexlify(hashlib.sha256(getBytes(tx)).digest()))
return tx |
how do you quantify network improvement using toonsbuf ? |
ahah bravo, i should switch type only after parsing the tx... |
no idea, only heuristic: improvement is proportional to size reduction... |
actually i trap asset data between fees and signature, so i can't switch type. |
This probably should be closed and pointed to AIP11 ? @fix |
yes, AIP11 simpfies the way to access signatures and id |
https://github.com/ArkEcosystem/AIPs/blob/master/AIPS/aip-8.md
The text was updated successfully, but these errors were encountered: