區塊鏈錢包開發 - USDT - 一、Omni本地錢包安裝


背景

Tether(USDT)中文又叫泰達幣,是一種加密貨幣,是Tether公司推出的基於穩定價值貨幣美元(USD)的代幣Tether USD,也是目前數字貨幣中最穩定的幣,USDT目前發行了兩種代幣,一種是基於以太坊標准的ERC20 Token,另一種是基於Omni Layer協議的代幣,在omni上,USDT代幣ID為31。omni上的代幣也是目前交易所支持最廣泛的代幣,而ERC20的USDT Token使用的較少;這里的內容以omni版本展開。

Omni

Omni是一個創建和交易自定義數字資產和貨幣的平台。 Omni協議底層基於比特幣, Omni Core是一個增強的比特幣核心,提供比特幣的所有功能以及進化版的Omni Layer功能。數字貨幣交易的的相關開發都離不開要了解這些有的沒的了。

Omni Core

Omni Core is a fast, portable Omni Layer implementation that is based off the Bitcoin Core codebase (currently 0.13). This implementation requires no external dependencies extraneous to Bitcoin Core, and is native to the Bitcoin network just like other Bitcoin nodes. It currently supports a wallet mode and is seamlessly available on three platforms: Windows, Linux and Mac OS. Omni Layer extensions are exposed via the JSON-RPC interface. Development has been consolidated on the Omni Core product, and it is the reference client for the Omni Layer.

Omni Core是基於Bitcoin Core代碼庫(當前為0.13)的快速,便攜式Omni Layer實現。此實現不需要任何與比特幣核心無關的外部依賴關系,並且像其他比特幣節點一樣是比特幣網絡固有的。它目前支持錢包模式,並且可以在三個平台上無縫使用:Windows,Linux和Mac OS。Omni Layer擴展通過JSON-RPC接口公開。開發已整合到Omni Core產品上,它是Omni Layer的參考客戶端。

推薦學習前先了解下區塊鏈,比特幣,怎么開發比特幣錢包,了解基於比特幣的彩色幣開發流程,就可以更好地開始接下來的學習和開發。

下載omnilayer錢包,官方提供了客戶端下載和core項目下載;

https://www.omnilayer.org/download.html

windows

官網下載安裝 進入qt目錄
命令行:
1.開始客戶端

> omnicore-qt.exe -testnet -server  -rpcbind=127.0.0.1 -rpcport=18332 -rpcuser=RPCuser -rpcpassword=RPCpasswd -datadir=“f:xxx”

如果安裝了其他節點
需要指定data目錄

> -datadir=“f:xxx”

指定錢包文件

> -wallet= “”

2. mac/linux/unix 這里使用core核心包

進入數據庫目錄:

// 下載
wget https://bintray.com/artifact/download/omni/OmniBinaries/omnicore-0.3.0-x86_64-linux-gnu.tar.gz
// 解壓后記錄對應目錄
cd omnicore-0.3.0/bin
./omnicored -testnet 連接test3測試網絡,會同步test3網絡的區塊數據(約20G)
./omnicored          連接比特幣主網網絡,會同步真實區塊數據, 電腦需要至少50G容量,同步很久,塊很重,耐心等待,

關閉提示:

在命令行窗口 command+c退出,最好別強退

啟動:

// ./bin/omnicored 無效則切換到qt啟動
./bin/omnicore-qt  -testnet -server -rpcbind=127.0.0.1 -rpcport=18332 -rpcuser=RPCUser -rpcpassword=RPCPassword

啟動2:(其他電腦訪問)

 ./bin/omnicore-qt  -testnet -server -rpcallowip=192.168.18.35   -rpcport=18332  -rpcuser=omnicorerpc -rpcpassword=Bngj987Ncid9893 -rpcallowip=192.168.16.113

測試api:

./bin/omnicore-cli -rpcconnect=127.0.0.1 -rpcport=18332 -rpcuser=RPCUser -rpcpassword=RPCPassword getinfo

查看私鑰:

./bin/omnicore-cli -rpcconnect=127.0.0.1 -rpcport=18332 -rpcuser=RPCUser -rpcpassword=RPCPassword dumpprivkey n1dnFGMxuxkDf1Ns5G2uYhaqk2ETWPuYQG

查看到賬:

./bin/omnicore-cli -rpcconnect=127.0.0.1 -rpcport=18332 -rpcuser=RPCUser -rpcpassword=RPCPassword getbalance

獲取交易信息:

./bin/omnicore-cli -rpcconnect=127.0.0.1 -rpcport=18332 -rpcuser=RPCUser -rpcpassword=RPCPassword omni_listtransactions

根據發送方獲取返回USDT信息:

./bin/omnicore-cli -rpcconnect=127.0.0.1 -rpcport=18332 -rpcuser=RPCUser -rpcpassword=RPCPassword omni_getbalance n1dnFGMxuxkDf1Ns5G2uYhaqk2ETWPuYQG 1

在omni節點發送給

moneyqMan7uh8FqdCA2BV5yZ8qVrc9ikLP

btc可返還omni

查看入賬:

./bin/omnicore-cli -rpcconnect=127.0.0.1 -rpcport=18332 -rpcuser=RPCUser -rpcpassword=RPCPassword omni_getbalance mhf2ibPWMoeyibR2jS3jPLZQYTJsFSoG5r 1

測試網絡進入QT桌面端

./bin/omnicore-qt -testnet -server -rpcbind=127.0.0.1 -rpcport=18332 -rpcuser=RPCUser -rpcpassword=RPCPassword

獲取指定地址交易列表listUnspent

./bin/omnicore-cli -rpcconnect=127.0.0.1 -rpcport=18332 -rpcuser=RPCUser -rpcpassword=RPCPassword listunspent  0 999999 '["mhf2ibPWMoeyibR2jS3jPLZQYTJsFSoG5r"]'

發送usdt

./bin/omnicore-cli -rpcconnect=127.0.0.1 -rpcport=18332 -rpcuser=RPCUser -rpcpassword=RPCPassword  omni_sendrawtx "mhf2ibPWMoeyibR2jS3jPLZQYTJsFSoG5r" "000000000000001f000000000000000a" "msis3b45PQriomes1zCAfNJpobggP1yusr"

導入特定地址到節點:

./bin/omnicore-cli -rpcconnect=127.0.0.1 -rpcport=18332 -rpcuser=RPCUser -rpcpassword=RPCPassword importprivkey cVKMjDVaWevxmRCrNXjTPpz77SSjWvQWp1eCj5zKBpEcaASK7Gib '' false ('': account false:rescan)
如果(btc/usdt)要通過api查詢余額,rescan需要設置為true

./bin/omnicore-cli -rpcconnect=192.168.16.11 -rpcport=8332 -rpcuser=RPCuser -rpcpassword=RPCpasswd importprivkey cR8rJpmWAkRPdPFUPjUjstNqf8mkqQMkEDEpDe3Q485JtaXUbu15

查詢余額:

./bin/omnicore-cli -rpcconnect=127.0.0.1 -rpcport=18332 -rpcuser=RPCUser -rpcpassword=RPCPassword omni_getbalance mhRPUxrDxL7unBauvgqKkGvsVqnJ3Jx6kU 2

以上僅作為參考,總結不是很到位。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM