MCPcopy Create free account
hub / github.com/canopy-network/canopy / get_sign_bytes

Function get_sign_bytes

plugin/python/tutorial/rpc_test.py:168–199  ·  view source on GitHub ↗

Get sign bytes for a transaction using protobuf.

(
    msg_type: str,
    msg_type_url: str,
    msg_bytes: bytes,
    tx_time: int,
    created_height: int,
    fee: int,
    memo: str,
    network_id: int,
    chain_id: int
)

Source from the content-addressed store, hash-verified

166
167
168def get_sign_bytes(
169 msg_type: str,
170 msg_type_url: str,
171 msg_bytes: bytes,
172 tx_time: int,
173 created_height: int,
174 fee: int,
175 memo: str,
176 network_id: int,
177 chain_id: int
178) -> bytes:
179 """Get sign bytes for a transaction using protobuf."""
180 # Create the Any message
181 any_msg = any_pb2.Any()
182 any_msg.type_url = msg_type_url
183 any_msg.value = msg_bytes
184
185 # Create the transaction without signature for signing
186 tx = tx_pb2.Transaction()
187 tx.message_type = msg_type
188 tx.msg.CopyFrom(any_msg)
189 # signature is not set for sign bytes
190 tx.created_height = created_height
191 tx.time = tx_time
192 tx.fee = fee
193 if memo:
194 tx.memo = memo
195 tx.network_id = network_id
196 tx.chain_id = chain_id
197
198 # Serialize to bytes (deterministic)
199 return tx.SerializeToString()
200
201
202def build_sign_and_send_tx(

Callers 1

build_sign_and_send_txFunction · 0.85

Calls 1

TransactionMethod · 0.65

Tested by

no test coverage detected