# Monero Python serialization library
[![Build Status](https://travis-ci.org/ph4r05/monero-serialize.svg?branch=master)](https://travis-ci.org/ph4r05/monero-serialize)
The library provides basic serialization logic for the Monero types,
used in transaction processing and transaction signing.
- Mainly supports binary serialization equivalent to Monero `BEGIN_SERIALIZE_OBJECT()`.
This serialization mechanism is used in the blockchain entity serialization.
- Boost portable serialization added.
- Support for `BEGIN_KV_SERIALIZE_MAP` is mainly supported. JSON and binary wire format.
The binary wire formats use streaming dumping / parsing for better memory efficiency.
For usage please take a look at [tests](https://github.com/ph4r05/monero-serialize/tree/master/monero_serialize/tests).
```
pip install monero-serialize
```
## Example usage:
```python
import binascii
from monero_serialize import xmrserialize as x
from monero_serialize import xmrtypes as xmr
msg = xmr.TxinToKey(amount=123, key_offsets=[1, 2, 3, 2**76], k_image=bytearray(range(32)))
# Serialize
writer = x.MemoryReaderWriter()
await x.dump_message(writer, msg)
print(binascii.hexlify(writer.buffer))
# Deserialize
test_deser = await x.load_message(x.MemoryReaderWriter(writer.buffer), xmr.TxinGen)
```
### Archive interface
```python
import binascii
from monero_serialize import xmrserialize as x
from monero_serialize import xmrtypes as xmr
msg = xmr.TxinGen(height=42)
# Serialize
writer = x.MemoryReaderWriter()
ar1 = x.Archive(writer, True)
await ar1.message(msg)
# Deserialize
msg2 = xmr.TxinGen()
ar2 = x.Archive(x.MemoryReaderWriter(writer.buffer), False)
await ar2.message(msg2)
```
### Symmetric Boost archive
```python
import binascii
from monero_serialize import xmrserialize as x
from monero_serialize import xmrtypes as xmr
from monero_serialize import xmrboost as xmrb
data_hex = b'011673657269616c697a6174696f6e3a3a61726368697665000000000134'
data_bin = base64.b16decode(data_hex, True)
reader = x.MemoryReaderWriter(bytearray(data_bin))
ar = xmrb.Archive(reader, False)
msg = xmr.TxinGen()
await ar.root_message(msg)
self.assertEqual(msg.height, 0x34)
```
## XMR classes
```python
class Hash(x.BlobType): pass;
class ECKey(x.BlobType): pass;
class ECPoint(x.BlobType): pass;
class SecretKey(ECKey): pass;
class ECPublicKey(ECPoint): pass;
class KeyImage(ECPoint): pass;
class KeyDerivation(ECPoint): pass;
class TxoutToScript(x.MessageType): pass;
class TxoutToKey(x.MessageType): pass;
class TxoutToScriptHash(x.MessageType): pass;
class TxoutTargetV(x.VariantType): pass;
class TxinGen(x.MessageType): pass;
class TxinToKey(x.MessageType): pass;
class TxinToScript(x.MessageType): pass;
class TxinToScriptHash(x.MessageType): pass;
class TxInV(x.VariantType): pass;
class TxOut(x.MessageType): pass;
class TransactionPrefix(x.MessageType): pass;
class TransactionPrefixExtraBlob(TransactionPrefix): pass;
#
# rctTypes.h
#
class Key64(x.ContainerType): pass;
class KeyV(x.ContainerType): pass;
class KeyM(x.ContainerType): pass;
class KeyVFix(x.ContainerType): pass;
class KeyMFix(x.ContainerType): pass;
class CtKey(x.MessageType): pass;
class CtkeyV(x.ContainerType): pass;
class CtkeyM(x.ContainerType): pass;
class MultisigKLRki(x.MessageType): pass;
class MultisigOut(x.MessageType): pass;
class EcdhTuple(x.MessageType): pass;
class BoroSig(x.MessageType): pass;
class MgSig(x.MessageType): pass;
class RangeSig(x.MessageType): pass;
class Bulletproof(x.MessageType): pass;
class EcdhInfo(x.ContainerType): pass;
class RctSigBase(x.MessageType): pass;
class RctSigPrunable(x.MessageType): pass;
class RctSig(RctSigBase): pass;
class Signature(x.MessageType): pass;
class SignatureArray(x.ContainerType): pass;
class Transaction(TransactionPrefix): pass;
class BlockHeader(x.MessageType): pass;
class HashVector(x.ContainerType): pass;
class Block(BlockHeader): pass;
class AccountPublicAddress(x.MessageType): pass;
class SubaddressIndex(x.MessageType): pass;
class MultisigLR(x.MessageType): pass;
class MultisigInfo(x.MessageType): pass;
class MultisigStruct(x.MessageType): pass;
class TxExtraPadding(x.MessageType): pass;
class TxExtraPubKey(x.MessageType): pass;
class TxExtraNonce(x.MessageType): pass;
class TxExtraMergeMiningTag(x.MessageType): pass;
class TxExtraAdditionalPubKeys(x.MessageType): pass;
class TxExtraMysteriousMinergate(x.MessageType): pass;
class TxExtraField(x.VariantType): pass;
class TxExtraFields(x.ContainerType): pass;
class OutputEntry(x.TupleType): pass;
class TxSourceEntry(x.MessageType): pass;
class TxDestinationEntry(x.MessageType): pass;
class TransferDetails(x.MessageType): pass;
class TxConstructionData(x.MessageType): pass;
class PendingTransaction(x.MessageType): pass;
class PendingTransactionVector(x.ContainerType): pass;
class UnsignedTxSet(x.MessageType): pass;
class SignedTxSet(x.MessageType): pass;
class MultisigTxSet(x.MessageType): pass;
```
没有合适的资源?快使用搜索试试~ 我知道了~
PyPI 官网下载 | monero-serialize-2.0.3.tar.gz
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 95 浏览量
2022-01-13
08:11:21
上传
评论
收藏 106KB GZ 举报
温馨提示
资源来自pypi官网。 资源全名:monero-serialize-2.0.3.tar.gz
资源推荐
资源详情
资源评论
收起资源包目录
monero-serialize-2.0.3.tar.gz (56个子文件)
monero-serialize-2.0.3
MANIFEST.in 99B
PKG-INFO 7KB
test.sh 81B
LICENSE 1KB
test-travis.sh 43B
monero_serialize
xmrrpc.py 44KB
xmrjson.py 3KB
core
message_types.py 5KB
erefs.py 2KB
readwriter.py 3KB
__init__.py 0B
obj_helper.py 1KB
int_serialize.py 2KB
base_types.py 775B
messages
tx_dest_entry.py 508B
tx_ecdh.py 353B
tx_src_entry.py 1KB
addr.py 507B
tx_rsig_boro.py 497B
tx_sig.py 1012B
__init__.py 0B
tx_rsig.py 114B
tx_rsig_bulletproof.py 654B
tx_prefix.py 3KB
ct_keys.py 897B
tx_extra.py 3KB
tx_full.py 9KB
base.py 567B
tx_construct.py 3KB
xmrtypes.py 27KB
xmrboost.py 26KB
tests
test_data.py 2KB
data
tx_metadata_01.txt 30KB
tx_prefix_01.txt 466B
tx_01.txt 28KB
tx_unsigned_01.txt 28KB
__init__.py 0B
test_xmr_boost.py 10KB
test_base.py 1KB
test_xmr_archive.py 1KB
test_xmr_json.py 2KB
test_xmr_base.py 70KB
test_xmr_rpc.py 3KB
helpers.py 918B
__init__.py 0B
protobuf.py 2KB
xmrobj.py 10KB
xmrserialize.py 25KB
setup.cfg 88B
monero_serialize.egg-info
PKG-INFO 7KB
requires.txt 110B
SOURCES.txt 2KB
top_level.txt 17B
dependency_links.txt 1B
setup.py 1KB
README.md 5KB
共 56 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 14w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- C++核心编程.zip
- vivado hls教程 ug871中文版
- 日志系统创建的一些资源
- 一些python用的note文档
- 基于python实现的人工智能聊天机器人.zip
- chatbot.zip
- 071223330付承雪.docx
- Chatbot-main.zip
- 基于springboot+vue服装销售系统(不含论文)
- 自动发货教程2024最新版.doc
- 2023-04-06-项目笔记 - 第三百五十四阶段 - 4.4.2.352全局变量的作用域-352 -2025.12.21
- 2023-04-06-项目笔记 - 第三百五十四阶段 - 4.4.2.352全局变量的作用域-352 -2025.12.21
- 第三届全国技能大赛上海市选拔赛(世赛选拔项目)网站技术项目试题与素材.zip
- 防火墙组网设计配置文件
- 417832817635033okx-android.apk
- Python编程入门基础教程:从零到一
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功