Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Cedric write a manual for node operator to withdraw XIN bonus to Messenger ID
首先构造一个基本的 raw transaction 格式如下
{
"version": 1,
"asset": "a99c2e0e2b1da4d648755ef19bd95139acbbe6564cfb06dec7cd34931ca72cdc",
"extra": "34366362393932382d653636632d343966392d386165632d366462366137346666663638",
"outputs": [
{
"type": 0,
"amount": "115.06849309",
"script": "fffe01",
"accounts": [
"XINPXu5NBXszhpZDRJ8iA26TbQ2oWTSq1tXqKKeVeYWgLSz8yXGTtVhMogynYytoMewYVFR541wauLhy1YV33zg445E49YA7"
]
}
],
"inputs": [
{
"hash": "20001842d6eff5129c11f7c053bf1209f0267bf223f1681c9cb9d19fc773a692",
"index": 11
}
]
}
其中 version,asset,type,script 和 accounts 都不需要修改。解释下这几个不需要改的参数现在的内容分别是
1. asset a99c2e0e2b1da4d648755ef19bd95139acbbe6564cfb06dec7cd34931ca72cdc 代表 XIN
2. type 0 代表普通转账
3. script fffe01 代表需要 1 个收款人签名就能使用这笔钱
4. accounts XINPXu5NBXszhpZDRJ8iA26TbQ2oWTSq1tXqKKeVeYWgLSz8yXGTtVhMogynYytoMewYVFR541wauLhy1YV33zg445E49YA7 代表只有一个收款人也就是我们的机器人
需要修改的是如下几个
1. extra,这个是用 hex 编码你们在 Mixin Messenger 里面等待收款的用户的 UUID 字符串。
2. amount,代表你们想要转账的数量,需要跟收到的分红数量一致
3. hash,这个是你们收到分红的那个交易的 transaction hash
4. index,这个是分红交易中属于你们的交易的 index
构造好这个交易后,用下面的命令发送给任何一个节点都可以。
mixin signrawtransaction -n mixin-node:8239 -key 0d48c96d383d325a97eea5295cbf3afa7766c49db477b68fd8032ff7f59b0b00d77e434f96f3f42c2d1796662c7cc90497feaf3863a5815f27ba49fd5e29b906 -raw '{"version":1,"asset":"a99c2e0e2b1da4d648755ef19bd95139acbbe6564cfb06dec7cd34931ca72cdc","extra":"34366362393932382d653636632d343966392d386165632d366462366137346666663638","outputs":[{"type":0,"amount":"115.06849309","script":"fffe01","accounts":["XINPXu5NBXszhpZDRJ8iA26TbQ2oWTSq1tXqKKeVeYWgLSz8yXGTtVhMogynYytoMewYVFR541wauLhy1YV33zg445E49YA7"]}],"inputs":[{"hash":"20001842d6eff5129c11f7c053bf1209f0267bf223f1681c9cb9d19fc773a692","index":11}]}'
其中这个 key 参数是当时提交的 payee 的 view + spend 拼接起来的。上面这条命令不会把 key 发送到节点,可以放心使用,之所以要指定节点访问,是为了从节点中得到完整的交易信息来帮助签名。
这个 signrawtransaction 命令执行成功后,会收到一个 hex 字符类似下面这样
86a756657273696f6e01a54173736574c420a99c2e0e2b1da4d648755ef19bd95139acbbe6564cfb06dec7cd34931ca72cdca6496e707574739185a448617368c42020001842d6eff5129c11f7c053bf1209f0267bf223f1681c9cb9d19fc773a692a5496e6465780ba747656e65736973c0a74465706f736974c0a44d696e74c0a74f7574707574739185a45479706500a6416d6f756e74c7050002addc961da44b65797391c4202902d1f57276eb32882066de06c0d70fc17a3cd8dc801c1c50e6d4918e39344fa6536372697074c403fffe01a44d61736bc4209515d480e6f28b79228c32db33718e1ca03750bbe7748cd3968a5d450cd743d1a54578747261c400aa5369676e6174757265739190
然后使用下面的命令把这个字符发送给节点就可以了
mixin sendrawtransaction -n mixin-node:8239 -raw 86a756657273696f6e01a54173736574c420a99c2e0e2b1da4d648755ef19bd95139acbbe6564cfb06dec7cd34931ca72cdca6496e707574739185a448617368c42020001842d6eff5129c11f7c053bf1209f0267bf223f1681c9cb9d19fc773a692a5496e6465780ba747656e65736973c0a74465706f736974c0a44d696e74c0a74f7574707574739185a45479706500a6416d6f756e74c7050002addc961da44b65797391c4202902d1f57276eb32882066de06c0d70fc17a3cd8dc801c1c50e6d4918e39344fa6536372697074c403fffe01a44d61736bc4209515d480e6f28b79228c32db33718e1ca03750bbe7748cd3968a5d450cd743d1a54578747261c400aa5369676e6174757265739190
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.