最近几天在对接USDT钱包,遇到一个问题就是根本没办法通过omni 钱包提供的API来实现钱包归集,因为API提供的接口都需要发送USDT的地址有一定的BTC数量才可以发送交易,所以没办只能找其他方案替代,请教了其他人后才知道只能通过创建BTC的原生交易才能达到这个效果,折腾了好几天,终于把这个流程给整理通顺了,估计还有很多人会遇到这个问题,所以记录下来为后面的人节省一些时间。
1、准备两个地址
首先两个地址, 发送USDT(地址里面要有USDT,这里通常可能是交易所用户的USDT钱包地址)地址和付手续费的地址(地址里面要有足够的BTC,这里通常可能是热钱包地址)
本次案例中
发送USDT地址为: mn7w1M4fwJzRr4zYy5dMSSfBg1ZC9e4xH4
付手续费地址为: muPuXyRqLBRf8Xyj28d2As8ya4iaw8XWGe
接收USDT地址为:muPuXyRqLBRf8Xyj28d2As8ya4iaw8XWGe
2、分别找到发送地址 和热钱包地址的一笔UXTO 作为发送USDT交易的载体
指令:listunspent 0 999999 '["mn7w1M4fwJzRr4zYy5dMSSfBg1ZC9e4xH4"]'
得到UXTO:
{
"txid": "7ef4ca48422fbd055eb7375145cb59bdadaba13caf29b4279c506a7ba846a33e",
"vout": 0,
"address": "mn7w1M4fwJzRr4zYy5dMSSfBg1ZC9e4xH4",
"scriptPubKey": "76a914486e3cf761cc47642135140da02669c04dd2451088ac",
"amount": 0.00081189,
"confirmations": 31103,
"spendable": true,
"solvable": true
}
指令:listunspent 0 999999 '["muPuXyRqLBRf8Xyj28d2As8ya4iaw8XWGe"]'
得到UXTO:
{
"txid": "0b381b15082156911ca8db2761910fe9545356778d70dd09be30fc0bece9ed9d",
"vout": 1,
"address": "muPuXyRqLBRf8Xyj28d2As8ya4iaw8XWGe",
"account": "sys",
"scriptPubKey": "76a914983c8b990aef5747bdef1f2bf3a49d29b19ae15788ac",
"amount": 0.00992750,
"confirmations": 4137,
"spendable": true,
"solvable": true
}
3、创建负载
指令:
createrawtransaction '[{"txid":"7ef4ca48422fbd055eb7375145cb59bdadaba13caf29b4279c506a7ba846a33e","vout":0},{"txid":"0b381b15082156911ca8db2761910fe9545356778d70dd09be30fc0bece9ed9d","vout":1,"scriptPubKey":"76a914983c8b990aef5747bdef1f2bf3a49d29b19ae15788ac","value": 0.00992750}]' '{}'
得到:
01000000023ea346a87b6a509c27b429af3ca1abadbd59cb455137b75e05bd2f4248caf47e0000000000ffffffff9dede9ec0bfc30be09dd708d77565354e90f916127dba81c91562108151b380b0100000000ffffffff0000000000
4、创建USDT交易
指令(代币ID,发送代币数量):omni_createpayload_simplesend 31 2.0
得到:000000000000000100000000001e8480
5、在交易上绑定代币数据
指令:
omni_createrawtx_opreturn 01000000023ea346a87b6a509c27b429af3ca1abadbd59cb455137b75e05bd2f4248caf47e0000000000ffffffff9dede9ec0bfc30be09dd708d77565354e90f916127dba81c91562108151b380b0100000000ffffffff0000000000 000000000000000100000000001e8480
得到(事务hash):
01000000023ea346a87b6a509c27b429af3ca1abadbd59cb455137b75e05bd2f4248caf47e0000000000ffffffff9dede9ec0bfc30be09dd708d77565354e90f916127dba81c91562108151b380b0100000000ffffffff010000000000000000166a146f6d6e69000000000000000100000000001e848000000000
6、在交易上添加接收地址
指令:
omni_createrawtx_reference 01000000023ea346a87b6a509c27b429af3ca1abadbd59cb455137b75e05bd2f4248caf47e0000000000ffffffff9dede9ec0bfc30be09dd708d77565354e90f916127dba81c91562108151b380b0100000000ffffffff010000000000000000166a146f6d6e69000000000000000100000000001e848000000000 muPuXyRqLBRf8Xyj28d2As8ya4iaw8XWGe
得到(事务hash):
01000000023ea346a87b6a509c27b429af3ca1abadbd59cb455137b75e05bd2f4248caf47e0000000000ffffffff9dede9ec0bfc30be09dd708d77565354e90f916127dba81c91562108151b380b0100000000ffffffff020000000000000000166a146f6d6e69000000000000000100000000001e848022020000000000001976a914983c8b990aef5747bdef1f2bf3a49d29b19ae15788ac00000000
7、在交易上指定矿工费用
指令:(事务HASH,交易信息,找零地址,手续费)
omni_createrawtx_change 01000000023ea346a87b6a509c27b429af3ca1abadbd59cb455137b75e05bd2f4248caf47e0000000000ffffffff9dede9ec0bfc30be09dd708d77565354e90f916127dba81c91562108151b380b0100000000ffffffff020000000000000000166a146f6d6e69000000000000000100000000001e848022020000000000001976a914983c8b990aef5747bdef1f2bf3a49d29b19ae15788ac00000000 '[{"txid":"7ef4ca48422fbd055eb7375145cb59bdadaba13caf29b4279c506a7ba846a33e","vout":1,"scriptPubKey":"76a914486e3cf761cc47642135140da02669c04dd2451088ac","value": 0.0002},{"txid":"0b381b15082156911ca8db2761910fe9545356778d70dd09be30fc0bece9ed9d","vout":1,"scriptPubKey":"76a914983c8b990aef5747bdef1f2bf3a49d29b19ae15788ac","value": 0.0002}]' muPuXyRqLBRf8Xyj28d2As8ya4iaw8XWGe 0.0002
得到(事务hash):
01000000023ea346a87b6a509c27b429af3ca1abadbd59cb455137b75e05bd2f4248caf47e0000000000ffffffff9dede9ec0bfc30be09dd708d77565354e90f916127dba81c91562108151b380b0100000000ffffffff020000000000000000166a146f6d6e69000000000000000100000000001e848022020000000000001976a914983c8b990aef5747bdef1f2bf3a49d29b19ae15788ac00000000
8、对交易签名
指令:
signrawtransaction 01000000023ea346a87b6a509c27b429af3ca1abadbd59cb455137b75e05bd2f4248caf47e0000000000ffffffff9dede9ec0bfc30be09dd708d77565354e90f916127dba81c91562108151b380b0100000000ffffffff020000000000000000166a146f6d6e69000000000000000100000000001e848022020000000000001976a914983c8b990aef5747bdef1f2bf3a49d29b19ae15788ac00000000
得到(区块信息):
{
"hex": "01000000023ea346a87b6a509c27b429af3ca1abadbd59cb455137b75e05bd2f4248caf47e000000006b483045022100d790995554bbda790f44db19a6e59e84ab5c2ab27577be1c406f09e76d6e7fe402204db6ef71c96a22fd91e230787a521c47e3acc0a9b66dae2b08151ef74c1a0e5e012103ad3414464aec8d4f0cdc3fd2540a255c0bc8f20d157f6aa39ce67564e92d3077ffffffff9dede9ec0bfc30be09dd708d77565354e90f916127dba81c91562108151b380b010000006a473044022073d01e964d0a94540adc5d9db778d2b768043ba071cf5f49af2c2b07a99f6db702202e9870ac127e0ba06226c69242016255e9230816d6eab96ca89ad968111a49a7012103e6f952da72a83b16443d70dbb2e30473b25d6c71a6fdc01fbfbf0638805b4218ffffffff020000000000000000166a146f6d6e69000000000000000100000000001e848022020000000000001976a914983c8b990aef5747bdef1f2bf3a49d29b19ae15788ac00000000",
"complete": true
}
9、广播交易
指令:
Sendrawtransaction 01000000023ea346a87b6a509c27b429af3ca1abadbd59cb455137b75e05bd2f4248caf47e000000006b483045022100d790995554bbda790f44db19a6e59e84ab5c2ab27577be1c406f09e76d6e7fe402204db6ef71c96a22fd91e230787a521c47e3acc0a9b66dae2b08151ef74c1a0e5e012103ad3414464aec8d4f0cdc3fd2540a255c0bc8f20d157f6aa39ce67564e92d3077ffffffff9dede9ec0bfc30be09dd708d77565354e90f916127dba81c91562108151b380b010000006a473044022073d01e964d0a94540adc5d9db778d2b768043ba071cf5f49af2c2b07a99f6db702202e9870ac127e0ba06226c69242016255e9230816d6eab96ca89ad968111a49a7012103e6f952da72a83b16443d70dbb2e30473b25d6c71a6fdc01fbfbf0638805b4218ffffffff020000000000000000166a146f6d6e69000000000000000100000000001e848022020000000000001976a914983c8b990aef5747bdef1f2bf3a49d29b19ae15788ac00000000
得到(交易ID):
ab28fcd449d1f8e57ead070d798d80fe8f962168341b383adf5bf07fe80e652d
注意:每次操作后可用指令:
decoderawtransaction 事务ID 和 omni_decodetransaction 事务ID来查看当前构建的交易信息情况。
网友评论