💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
Omni Core是Bitcoin Core的一个分支,其Omni协议功能支持作为顶层的新功能层添加。因此,与API的交互以与Bitcoin Core相同的方式(JSON-RPC)完成,只需使用额外的RPC即可使用Omni协议功能。 ## 第三方接口 ``` curl -X POST -H "Content-Type: application/x-www-form-urlencoded" -H "Content-Type: application/x-www-form-urlencoded" -d "signedTransaction=0200000001f1923b0bafbf68a6ecdbfe65f7d8e0ca86c23280cb96eeaeecfa7aea038950ae000000006a47304402203cbdbd15368856db08adffb22110cadb9b343af5b3c610b9af63bd8fd792c11202203a5b1916d4cd638619a4d3614a22b1cf339d88201a934f2ed1610ac9d36714b2012103fe44259b70361912a21eb12e300df2bb9b7933381ed338989b28c6a01c8d2431ffffffff0322020000000000001976a9142047c920791ae2b8e764ff51a684134dccb67f6e88ac0000000000000000166a146f6d6e69000000000000001f0000000005f5e1001e811900000000001976a91494687e55ebc2d011f5bf7825adaaa15e8a7c383288ac00000000" "https://api.omniexplorer.info/v1/transaction/pushtx/" ``` ## 交易 最近几天在对接USDT钱包,遇到一个问题就是根本没办法通过omni 钱包提供的API来实现钱包归集,因为API提供的接口都需要发送USDT的地址有一定的BTC数量才可以发送交易,所以没办只能找其他方案替代,请教了其他人后才知道只能通过创建BTC的原生交易才能达到这个效果,折腾了好几天,终于把这个流程给整理通顺了,估计还有很多人会遇到这个问题,所以记录下来为后面的人节省一些时间。 ### 1、准备两个地址 首先两个地址, 发送USDT(地址里面要有USDT,这里通常可能是交易所用户的USDT钱包地址)地址和付手续费的地址(地址里面要有足够的BTC,这里通常可能是热钱包地址) 本次案例中 发送USDT地址为: mn7w1M4fwJzRr4zYy5dMSSfBg1ZC9e4xH4 付手续费地址为: muPuXyRqLBRf8Xyj28d2As8ya4iaw8XWGe 接收USDT地址为:muPuXyRqLBRf8Xyj28d2As8ya4iaw8XWGe ### 2、分别找到发送地址 和热钱包地址的一笔UXTO 作为发送USDT交易的载体 指令:listunspent 0 999999 '["mn7w1M4fwJzRr4zYy5dMSSfBg1ZC9e4xH4"]' ```json { "txid": "7ef4ca48422fbd055eb7375145cb59bdadaba13caf29b4279c506a7ba846a33e", "vout": 0, "address": "mn7w1M4fwJzRr4zYy5dMSSfBg1ZC9e4xH4", "scriptPubKey": "76a914486e3cf761cc47642135140da02669c04dd2451088ac", "amount": 0.00081189, "confirmations": 31103, "spendable": true, "solvable": true } ``` 指令:listunspent 0 999999 '["muPuXyRqLBRf8Xyj28d2As8ya4iaw8XWGe"]' 得到UXTO: ```json { "txid": "0b381b15082156911ca8db2761910fe9545356778d70dd09be30fc0bece9ed9d", "vout": 1, "address": "muPuXyRqLBRf8Xyj28d2As8ya4iaw8XWGe", "account": "sys", "scriptPubKey": "76a914983c8b990aef5747bdef1f2bf3a49d29b19ae15788ac", "amount": 0.00992750, "confirmations": 4137, "spendable": true, "solvable": true } ``` ### 3、创建负载 > 指令: ```js 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来查看当前构建的交易信息情况。 > **参考地址** https://www.zhihu.com/people/duan-pan-ykjym/activities <!--more--> - [使用原始事务API创建简单发送事务](https://github.com/OmniLayer/omnicore/wiki/Use-the-raw-transaction-API-to-create-a-Simple-Send-transaction) ## 命令 常用基础命令 ```sh omnicore-cli listaccounts "coinrise" omnicore-cli getaddressesbyaccount "" omnicore-cli getaddressesbyaccount "coinrise" omnicore-cli omni_getbalance "1EXiBj8pkxmsPb6dNAMLFcZYTRSNsUUesS" 31 omnicore-cli omni_getbalance "129sqfPm5uKYH3a1W4n5y1PbSkta8MthcH" 1 omnicore-cli listunspent 0 999999 "[\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]" omnicore-cli listunspent 0 999999 "[\"1K6JtSvrHtyFmxdtGZyZEF7ydytTGqasNc\",\"13GJVDVyXNPA24vnGPkeZccboRsdpscWkX\"]" omnicore-cli omni_send "1EXiBj8pkxmsPb6dNAMLFcZYTRSNsUUesS" "1JzMWUKnHgMaXXEqiau1ktAFr2hevLsZPw" 1 "0.1" ``` ### omnicore-cli getinfo ```json { "version": 130200, "protocolversion": 70015, "walletversion": 130000, "balance": 0.00000000, "blocks": 584885, "timeoffset": -1, "connections": 110, "proxy": "", "difficulty": 9064159826491.41, "testnet": false, "keypoololdest": 1558404031, "keypoolsize": 100, "paytxfee": 0.00000000, "relayfee": 0.00001000, "errors": "Warning: Unknown block versions being mined! It's possible unknown rules are in effect" } ``` ### importaddress `omnicore-cli importaddress "1EXiBj8pkxmsPb6dNAMLFcZYTRSNsUUesS"` 由于所有现有的比特币核心功能都是Omni Core固有的,因此默认情况下RPC端口保持8332与每个比特币核心一样。如果您希望与比特币核心一起运行Omni Core(例如,通过单独的数据中心),则可以使用该-rpcport<port>选项提名替代端口号。 ### omni_send 创建并广播一个简单的发送事务。 参数: | 名称 | 类型 | 存在 | 描述 | | --------------- | ------ | ------ | ------------------------------------------ | | fromaddress | string | 需要 | 要发送的地址 | | toaddress | string | 需要 | 接收者的地址 | | propertyid | int | 需要 | 要发送的令牌的标识符 | | amount | string | 需要 | 要发送的金额 | | redeemaddress | string | 可选的 | 一个可以花费交易粉尘的地址(默认发件人) | | referenceamount | string | 可选的 | 发送给接收方的比特币金额(默认情况下最小) | 例如: ```$ omnicore-cli “ omni_send ” “ 3M9qvHKtgARhqcMtM5cRT9VaiDJ5PSfQGY ” “ 37FaKponF7zqoMLUjEiko25pDiuVH5YLEa ” 1 “ 100.0 ”``` 结果: hash //(字符串)十六进制编码的事务散列 ### omni_sendall Transfers all available tokens in the given ecosystem to the recipient. Arguments: Name Type Presence Description fromaddress string required the address to send from toaddress string required the address of the receiver ecosystem number required the ecosystem of the tokens to send (1 for main ecosystem, 2 for test ecosystem) redeemaddress string optional an address that can spend the transaction dust (sender by default) referenceamount string optional a bitcoin amount that is sent to the receiver (minimal by default) Result: ``` "hash" // (string) the hex-encoded transaction hash ``` Example: $ omnicore-cli "omni_sendall" "3M9qvHKtgARhqcMtM5cRT9VaiDJ5PSfQGY" "37FaKponF7zqoMLUjEiko25pDiuVH5YLEa" 2 ### omni_sendrawtx 广播原始的Omni Layer交易。 参数: 名称 类型 存在 描述 fromaddress 串 需要 要发送的地址 rawtransaction 串 需要 十六进制编码的原始事务 referenceaddress 串 可选的 一个参考地址(默认没有) redeemaddress 串 可选的 一个可以花费交易粉尘的地址(默认发件人) referenceamount 串 可选的 发送给接收方的比特币金额(默认情况下最小) 结果: “ hash ” //(字符串)十六进制编码的事务散列 例: $ omnicore-cli “ omni_sendrawtx ” \ “ 1MCHESTptvd2LnNp7wmr2sGTpRomteAkq8 ” “ 000000000000000100000000017d7840 ” \ “ 1EqTta1Rt8ixAA32DuC29oukbsSWU62qAV ” 数据检索 用于数据检索的RPC可用于获取有关Omni生态系统状态的信息。 ### omni_getinfo Returns various state information of the client and protocol. Arguments: None Result: Result: ``` { "omnicoreversion_int" : xxxxxxx, // (number) client version as integer "omnicoreversion" : "x.x.x.x-xxx", // (string) client version "mastercoreversion" : "x.x.x.x-xxx", // (string) client version (DEPRECIATED) "bitcoincoreversion" : "x.x.x", // (string) Bitcoin Core version "commitinfo" : "xxxxxxx", // (string) build commit identifier "block" : nnnnnn, // (number) index of the last processed block "blocktime" : nnnnnnnnnn, // (number) timestamp of the last processed block "blocktransactions" : nnnn, // (number) Omni transactions found in the last processed block "totaltransactions" : nnnnnnnn, // (number) Omni transactions processed in total "alerts" : [ // (array of JSON objects) active protocol alert (if any) { "alerttype" : n // (number) alert type as integer "alerttype" : "xxx" // (string) alert type (can be "alertexpiringbyblock", "alertexpiringbyblocktime", "alertexpiringbyclientversion" or "error") "alertexpiry" : "nnnnnnnnnn" // (string) expiration criteria (can refer to block height, timestamp or client verion) "alertmessage" : "xxx" // (string) information about the alert }, ... ] } ``` Example: Example: $ omnicore-cli "omni_getinfo" ### omni_getbalance Returns the token balance for a given address and property. Arguments: Name Type Presence Description address string required the address propertyid number required the property identifier Result: ``` { "balance" : "n.nnnnnnnn", // (string) the available balance of the address "reserved" : "n.nnnnnnnn", // (string) the amount reserved by sell offers and accepts "frozen" : "n.nnnnnnnn" // (string) the amount frozen by the issuer (applies to managed properties only) } ``` Example: $ omnicore-cli "omni_getbalance", "1EXoDusjGwvnjZUyKkxZ4UHEf77z6A5S4P" 1 omni_getallbalancesforid Returns a list of token balances for a given currency or property identifier. Arguments: Name Type Presence Description propertyid number required the property identifier Result: ``` [ // (array of JSON objects) { "address" : "address", // (string) the address "balance" : "n.nnnnnnnn", // (string) the available balance of the address "reserved" : "n.nnnnnnnn" // (string) the amount reserved by sell offers and accepts }, ... ] ``` Example: $ omnicore-cli "omni_getallbalancesforid" 1 ### omni_getallbalancesforaddress Returns a list of all token balances for a given address. Arguments: Name Type Presence Description address string required the address Result: ``` [ // (array of JSON objects) { "propertyid" : n, // (number) the property identifier "balance" : "n.nnnnnnnn", // (string) the available balance of the address "reserved" : "n.nnnnnnnn" // (string) the amount reserved by sell offers and accepts }, ... ] ``` Example: $ omnicore-cli "omni_getallbalancesforaddress" "1EXoDusjGwvnjZUyKkxZ4UHEf77z6A5S4P" ### omni_gettransaction Get detailed information about an Omni transaction. Arguments: Name Type Presence Description txid string required the hash of the transaction to lookup Result: ``` { "txid" : "hash", // (string) the hex-encoded hash of the transaction "sendingaddress" : "address", // (string) the Bitcoin address of the sender "referenceaddress" : "address", // (string) a Bitcoin address used as reference (if any) "ismine" : true|false, // (boolean) whether the transaction involes an address in the wallet "confirmations" : nnnnnnnnnn, // (number) the number of transaction confirmations "fee" : "n.nnnnnnnn", // (string) the transaction fee in bitcoins "blocktime" : nnnnnnnnnn, // (number) the timestamp of the block that contains the transaction "valid" : true|false, // (boolean) whether the transaction is valid "positioninblock" : n, // (number) the position (index) of the transaction within the block "version" : n, // (number) the transaction version "type_int" : n, // (number) the transaction type as number "type" : "type", // (string) the transaction type as string [...] // (mixed) other transaction type specific properties } ``` Example: $ omnicore-cli "omni_gettransaction" "1075db55d416d3ca199f55b6084e2115b9345e16c5cf302fc80e9d5fbf5d48d" ### omni_listtransactions List wallet transactions, optionally filtered by an address and block boundaries. Arguments: Name Type Presence Description txid string optional address filter (default: "*") count number optional show at most n transactions (default: 10) skip number optional skip the first n transactions (default: 0) startblock number optional first block to begin the search (default: 0) endblock number optional last block to include in the search (default: 999999) Result: ``` [ // (array of JSON objects) { "txid" : "hash", // (string) the hex-encoded hash of the transaction "sendingaddress" : "address", // (string) the Bitcoin address of the sender "referenceaddress" : "address", // (string) a Bitcoin address used as reference (if any) "ismine" : true|false, // (boolean) whether the transaction involves an address in the wallet "confirmations" : nnnnnnnnnn, // (number) the number of transaction confirmations "fee" : "n.nnnnnnnn", // (string) the transaction fee in bitcoins "blocktime" : nnnnnnnnnn, // (number) the timestamp of the block that contains the transaction "valid" : true|false, // (boolean) whether the transaction is valid "positioninblock" : n, // (number) the position (index) of the transaction within the block "version" : n, // (number) the transaction version "type_int" : n, // (number) the transaction type as number "type" : "type", // (string) the transaction type as string [...] // (mixed) other transaction type specific properties }, ... ] ``` Example: $ omnicore-cli "omni_listtransactions" omni_listblocktransactions Lists all Omni transactions in a block. Arguments: Name Type Presence Description index number required the block height or block index ``` Result: [ // (array of string) "hash", // (string) the hash of the transaction ... ] ``` Example: Example: $ omnicore-cli "omni_listblocktransactions" 279007 ### omni_listpendingtransactions Returns a list of unconfirmed Omni transactions, pending in the memory pool. Note: the validity of pending transactions is uncertain, and the state of the memory pool may change at any moment. It is recommended to check transactions after confirmation, and pending transactions should be considered as invalid. Arguments: Name Type Presence Description address string optional filter results by address (default: "" for no filter) Result: ``` [ // (array of JSON objects) { "txid" : "hash", // (string) the hex-encoded hash of the transaction "sendingaddress" : "address", // (string) the Bitcoin address of the sender "referenceaddress" : "address", // (string) a Bitcoin address used as reference (if any) "ismine" : true|false, // (boolean) whether the transaction involes an address in the wallet "fee" : "n.nnnnnnnn", // (string) the transaction fee in bitcoins "version" : n, // (number) the transaction version "type_int" : n, // (number) the transaction type as number "type" : "type", // (string) the transaction type as string [...] // (mixed) other transaction type specific properties }, ... ] ``` Example: $ omnicore-cli "omni_listpendingtransactions" ## 变更历史 以下调用在Omni Core 0.0.10中被替换,并且使用旧命令的查询被转发。 ``` send_MP 通过 omni_send sendtoowners_MP 通过 omni_sendsto sendrawtx_MP 通过 omni_sendrawtx getinfo_MP 通过 omni_getinfo getbalance_MP 通过 omni_getbalance getallbalancesforid_MP 通过 omni_getallbalancesforid getallbalancesforaddress_MP 通过 omni_getallbalancesforaddress gettransaction_MP 通过 omni_gettransaction listtransactions_MP 通过 omni_listtransactions listblocktransactions_MP 通过 omni_listblocktransactions getactivedexsells_MP 通过 omni_getactivedexsells listproperties_MP 通过 omni_listproperties getproperty_MP 通过 omni_getproperty getactivecrowdsales_MP 通过 omni_getactivecrowdsales getcrowdsale_MP 通过 omni_getcrowdsale getgrants_MP 通过 omni_getgrants getsto_MP通过omni_getsto或omni_gettransaction ``` ## 归集(通过节点) https://www.jianshu.com/p/9a72954d24ea ## 附录 官方网站: https://www.omnilayer.org/ 浏览器: https://omniexplorer.info/ Omni WIKI: https://github.com/OmniLayer/omnicore/wiki JSON-RPC API: https://github.com/OmniLayer/omnicore/blob/master/src/omnicore/doc/rpc-api.md https://api.omniexplorer.info/ # 钱包归集 最近几天在对接USDT钱包,遇到一个问题就是根本没办法通过omni 钱包提供的API来实现钱包归集,因为API提供的接口都需要发送USDT的地址有一定的BTC数量才可以发送交易,所以没办只能找其他方案替代,请教了其他人后才知道只能通过创建BTC的原生交易才能达到这个效果,折腾了好几天,终于把这个流程给整理通顺了,估计还有很多人会遇到这个问题,所以记录下来为后面的人节省一些时间。 ### 1、准备两个地址 首先两个地址, 发送USDT(地址里面要有USDT,这里通常可能是交易所用户的USDT钱包地址)地址和付手续费的地址(地址里面要有足够的BTC,这里通常可能是热钱包地址) 本次案例中 发送USDT地址为: mn7w1M4fwJzRr4zYy5dMSSfBg1ZC9e4xH4 付手续费地址为: muPuXyRqLBRf8Xyj28d2As8ya4iaw8XWGe 接收USDT地址为:muPuXyRqLBRf8Xyj28d2As8ya4iaw8XWGe ### 2、分别找到发送地址 和热钱包地址的一笔UXTO 作为发送USDT交易的载体 指令:listunspent 0 999999 '["mn7w1M4fwJzRr4zYy5dMSSfBg1ZC9e4xH4"]' ``` { "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来查看当前构建的交易信息情况。 > **参考地址** https://www.zhihu.com/people/duan-pan-ykjym/activities # 参考地址