Skip to content
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

Closed
Doweig opened this issue Feb 2, 2017 · 10 comments
Closed

AIP 8: An improvement of transaction protocol #7

Doweig opened this issue Feb 2, 2017 · 10 comments

Comments

@Doweig
Copy link
Contributor

Doweig commented Feb 2, 2017

https://github.com/ArkEcosystem/AIPs/blob/master/AIPS/aip-8.md

Doweig added a commit that referenced this issue Feb 2, 2017
@fix
Copy link
Contributor

fix commented Jun 29, 2017

@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

@Moustikitos
Copy link
Contributor

Okay... On it

@Moustikitos
Copy link
Contributor

BTW are you sure requesterPublicKey field is needed ? Maybe a good thing to get rid of it.

@Moustikitos
Copy link
Contributor

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

@Moustikitos
Copy link
Contributor

how do you quantify network improvement using toonsbuf ?

@fix
Copy link
Contributor

fix commented Jul 1, 2017

ahah bravo, i should switch type only after parsing the tx...

@fix
Copy link
Contributor

fix commented Jul 1, 2017

no idea, only heuristic: improvement is proportional to size reduction...

@Moustikitos
Copy link
Contributor

actually i trap asset data between fees and signature, so i can't switch type.

@axenter
Copy link

axenter commented Oct 24, 2017

This probably should be closed and pointed to AIP11 ? @fix

@Moustikitos
Copy link
Contributor

yes, AIP11 simpfies the way to access signatures and id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants