convert.py 391 B

1234567891011
  1. from solders.transaction import Transaction
  2. from .generated.packet_pb2 import Meta, Packet
  3. def tx_to_protobuf_packet(tx: Transaction) -> Packet:
  4. """
  5. Converts a transaction to a packet
  6. Note: setting packet.meta.size is required, the rest are optional
  7. """
  8. return Packet(data=bytes(tx), meta=Meta(size=len(bytes(tx)), addr="0.0.0.0", port=0, flags=None, sender_stake=0))