Skip to content

Ability to get unsigned encoded RLP transaction #325

Description

@antazoey

What feature should we add?

I am struggling to get the unsigned encoded RLP transaction, before hash and before signing.
Like

02f843827a698080808094000000000000000000000000000000000000000080a4c8c57ba6eb886a56f9f0efa64432678cebf1270e9314a758e6eb697a606202a451e3e82ec0

this level of detail is just so hidden and abstracted away it becomes nearly impossible to find a decent API to get it without having to re-do everything this library does

looking at the hash method from dynamic tx

    def hash(self) -> bytes:
        """
        Hashes this DynamicFeeTransaction to prepare it for signing.
        As per the EIP-1559 specifications, the signature is a secp256k1 signature over
        ``keccak256(0x02 || rlp([chainId, nonce, maxPriorityFeePerGas,
        maxFeePerGas, gasLimit, to, value, data, accessList]))``
        """
        # Remove signature fields.
        transaction_without_signature_fields = dissoc(self.dictionary, "v", "r", "s")
        # RPC-structured transaction to rlp-structured transaction
        rlp_structured_txn_without_sig_fields = transaction_rpc_to_rlp_structure(
            transaction_without_signature_fields
        )
        rlp_serializer = self.__class__._unsigned_transaction_serializer
        hash = pipe(
            rlp_serializer.from_dict(rlp_structured_txn_without_sig_fields),  # type: ignore  # noqa: E501
            lambda val: rlp.encode(val),  # rlp([...])
            lambda val: bytes([self.__class__.transaction_type])
            + val,  # (0x02 || rlp([...]))
            keccak,  # keccak256(0x02 || rlp([...]))
        )
        return cast(bytes, hash)

i can see the value is need is buried in there somewhere, would be nice to have access to this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions