android - 安卓应用程序中的 Tron 钱包集成
问题描述
我正在为 TRON 区块链开发一个安卓应用程序。我正在使用 Trust 钱包库。
implementation 'com.trustwallet:wallet-core:2.3.9'
签署交易几乎完成,但广播我需要raw_data_hex
数据。我怎样才能得到它。
代码
val privateStr = "privatekey"
val privateBytes: ByteArray = fromHexString(privateStr)
val trc = Tron.TransferContract.newBuilder()
.setOwnerAddress("owner_address")
.setToAddress("toadress")
.setAmount(1000000L)
val transaction = Tron.Transaction.newBuilder()
.setTransfer(trc)
.build()
val signingInput = Tron.SigningInput.newBuilder()
.setTransaction(transaction)
.setPrivateKey(ByteString.copyFrom(privateBytes))
val output = AnySigner.sign(signingInput.build(), CoinType.TRON, Tron.SigningOutput.parser())
println("*****signing_output${output.json}")
输出 json 是
{"raw_data":{"contract":[{"parameter":{"type_url":"type.googleapis.com/protocol.TransferContract","value":{"amount":1000000,"owner_address":"419c84ec90ef46e68530893cf3229a1dd695b8b457","to_address":"41105e58ce5d754034475f24149ab910f9602bc141"}},"type":"TransferContract"}],"expiration":1608078105411,"ref_block_bytes":"0000","ref_block_hash":"9afbf4c8996fb924","timestamp":1608042105411},"signature":["7204dd578e610164d415f30e57eeb07cab2028a82992c6986f932271796d14b810f85e7b634e0606eefcfe9c76a85663f68a076be8efe7f2355fdb2dc5986f2801"],"txID":"6f3027995c380950442a0f9479ccf31948c7d1134314e333d4b3688799f3d4d1"}
解决方案
推荐阅读
- angular2-services - 如何屏蔽在 AG-GRID 列值上显示 xxxx-last 4 digit(9 digit ssn)的 SSN
- python - 在 pytest.mark.parametrize 中使用夹具
- content-management-system - Typo3:尝试添加扩展,然后我的网站崩溃并显示 HTTP ERROR 500
- arcore - 两帧之间的立体基线
- amazon-s3 - AWS Macie 中的行为分析是否跟踪从 AWS Athena 对 S3 中敏感数据的调用?
- python - 使用图表从 docx 的 python 调用 libreoffice 生成 pdf 时出现问题
- python-3.x - TensorFlow Logits 和 Labels 必须是可广播的
- ios - React Native - 链接 - 在 Iphone 的 FB 应用程序中打开 FB 页面
- ios - Google Map iOS - 缩放动画在两部不同的手机(iPhone X 与 iPhone 7)上的工作方式不同
- python-3.x - 使用 GridSearchCV 进行网格搜索 - 使用 ImageDataGenerator(keras)的 scikit-learn(超参数调整)?