USDT offline signature transaction

Author: Chen Jinjian
personal blog: HTTPS: //jian1098.github.io
CSDN blog: https: //blog.csdn.net/c_jian
Jane book: https: //www.jianshu.com/u/8ba9ac5706b6
Contact: jian1098 @qq.com

USDTThe offline transaction requires the following 8 steps

1. Check unspent transactions

Parameters: minimum number of confirmed blocks, maximum number of confirmed blocks, wallet address array (separated by commas)

omnicore-cli -conf=/root/.omnicore/bitcoin.conf "listunspent" 0 999999 '["mu5vgTeuMRbGDAYZuvnYcebuky7bte2XNr","mxbL6VyXG4AJXD8ncrgRRgQY2GhbjTizSC"]'

Return result:

转出钱包:mq8FvvycAHw8zzwarYbk8SQ8uTY3GN493u  转入3.33333000usdt

  {
    "txid": "7a8614c268c3113bb5bdefd2d85c092960c957053f2abf1fb2a7f81b7a8ab72d",
    "vout": 2,
    "address": "mq8FvvycAHw8zzwarYbk8SQ8uTY3GN493u",
    "account": "usdt-test",
    "scriptPubKey": "76a9146966699024c310c454049a6eaac9c58fee02081c88ac",
    "amount": 0.00000546,
    "confirmations": 1,
    "spendable": false,
    "solvable": true
  }


手续费钱包:  miLt8eZ85Z4S4sDXAVbK2R1E49RgnRasgK  转入20btc
  {
    "txid": "7a8614c268c3113bb5bdefd2d85c092960c957053f2abf1fb2a7f81b7a8ab72d",
    "vout": 0,
    "address": "miLt8eZ85Z4S4sDXAVbK2R1E49RgnRasgK",
    "account": "usdt-test",
    "scriptPubKey": "76a9141f00be4aee1d4534870b65c9b6c2e5276ffff0c888ac",
    "amount": 19.99960000,
    "confirmations": 1,
    "spendable": false,
    "solvable": true
  }, 

2. Build the payload

Parameters:, propertyidthe usdtnumber of transactions

omnicore-cli -conf=/root/.omnicore/bitcoin.conf "omni_createpayload_simplesend" 1 "2.22222"

Return result:

0000000000000001000000000d3ed6b0

3. Create an unsigned transaction

Parameters: Step 1 input集合(ie one or more inputs),{转出地址:0.00000546}

This is 0.00000546a Bitcoin is btcthe minimum number of trading transactions, USDTthe nature of the transaction is btcincidental transaction data, no btc, usdt no input can not be transferred out

omnicore-cli -conf=/root/.omnicore/bitcoin.conf "createrawtransaction" '[{"txid":"7a8614c268c3113bb5bdefd2d85c092960c957053f2abf1fb2a7f81b7a8ab72d","vout":2},{"txid":"7a8614c268c3113bb5bdefd2d85c092960c957053f2abf1fb2a7f81b7a8ab72d","vout":0}]' '{"mq8FvvycAHw8zzwarYbk8SQ8uTY3GN493u":0.00000546}'

Return result:

01000000022db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a0200000000ffffffff2db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a0000000000ffffffff0122020000000000001976a9146966699024c310c454049a6eaac9c58fee02081c88ac00000000

4. Add a payload to the transaction

Parameters: the result of step 3, the result of step 2

omnicore-cli -conf=/root/.omnicore/bitcoin.conf "omni_createrawtx_opreturn" "01000000022db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a0200000000ffffffff2db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a0000000000ffffffff0122020000000000001976a9146966699024c310c454049a6eaac9c58fee02081c88ac00000000" "0000000000000001000000000d3ed6b0"

Return result:

01000000022db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a0200000000ffffffff2db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a0000000000ffffffff0222020000000000001976a9146966699024c310c454049a6eaac9c58fee02081c88ac0000000000000000166a146f6d6e690000000000000001000000000d3ed6b000000000

5. Set the payment address

Parameters: the result of step 4, the address of the receiving wallet

omnicore-cli -conf=/root/.omnicore/bitcoin.conf "omni_createrawtx_reference" "01000000022db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a0200000000ffffffff2db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a0000000000ffffffff0222020000000000001976a9146966699024c310c454049a6eaac9c58fee02081c88ac0000000000000000166a146f6d6e690000000000000001000000000d3ed6b000000000" "mtsZjfgk6mb2wKqzt76rsybANpys25dcmi"

Return result:

01000000022db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a0200000000ffffffff2db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a0000000000ffffffff0322020000000000001976a9146966699024c310c454049a6eaac9c58fee02081c88ac0000000000000000166a146f6d6e690000000000000001000000000d3ed6b022020000000000001976a914927f8a23044bf2f4d2231ec0d40c844da44216fe88ac00000000

6. Set up change and handling fees

The change and handling fee here refer to Bitcoin

Parameters: the result of step 5, the input list of the first step ( jsonformat, pay attention amountto change value), btcchange address (can be set to the address in the first step), transaction fee (setting too low will be regarded as dust Transaction and discarded)

omnicore-cli -conf=/root/.omnicore/bitcoin.conf "omni_createrawtx_change" "01000000022db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a0200000000ffffffff2db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a0000000000ffffffff0322020000000000001976a9146966699024c310c454049a6eaac9c58fee02081c88ac0000000000000000166a146f6d6e690000000000000001000000000d3ed6b022020000000000001976a914927f8a23044bf2f4d2231ec0d40c844da44216fe88ac00000000" '[{"txid":"7a8614c268c3113bb5bdefd2d85c092960c957053f2abf1fb2a7f81b7a8ab72d","vout":2,"scriptPubKey":"76a9146966699024c310c454049a6eaac9c58fee02081c88ac","value":0.00000546},{"txid":"7a8614c268c3113bb5bdefd2d85c092960c957053f2abf1fb2a7f81b7a8ab72d","vout":0,"scriptPubKey":"76a9141f00be4aee1d4534870b65c9b6c2e5276ffff0c888ac","value":19.99960000}]' "miLt8eZ85Z4S4sDXAVbK2R1E49RgnRasgK" 0.0004

Return result:

01000000022db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a0200000000ffffffff2db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a0000000000ffffffff045e593477000000001976a9141f00be4aee1d4534870b65c9b6c2e5276ffff0c888ac22020000000000001976a9146966699024c310c454049a6eaac9c58fee02081c88ac0000000000000000166a146f6d6e690000000000000001000000000d3ed6b022020000000000001976a914927f8a23044bf2f4d2231ec0d40c844da44216fe88ac00000000

7. Signature transaction

The last two steps directly Bitcoin can be ordered, but even the latest version of the omnicoredprogram is based on the old version bitcoind(0.13.2), you can not use signrawtransactionwithkey, you can only use the old signrawtransactionmethod

Parameters: the result of step 6, the input list, and the private key corresponding to the address in the input list

omnicore-cli -conf=/root/.omnicore/bitcoin.conf "signrawtransaction" "01000000022db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a0200000000ffffffff2db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a0000000000ffffffff045e593477000000001976a9141f00be4aee1d4534870b65c9b6c2e5276ffff0c888ac22020000000000001976a9146966699024c310c454049a6eaac9c58fee02081c88ac0000000000000000166a146f6d6e690000000000000001000000000d3ed6b022020000000000001976a914927f8a23044bf2f4d2231ec0d40c844da44216fe88ac00000000" '[{"txid":"7a8614c268c3113bb5bdefd2d85c092960c957053f2abf1fb2a7f81b7a8ab72d","vout":2,"scriptPubKey":"76a9146966699024c310c454049a6eaac9c58fee02081c88ac","value":0.00000546},{"txid":"7a8614c268c3113bb5bdefd2d85c092960c957053f2abf1fb2a7f81b7a8ab72d","vout":0,"scriptPubKey":"76a9141f00be4aee1d4534870b65c9b6c2e5276ffff0c888ac","value":19.99960000}]'  '["92a4LrHSVUqvFSn6fxQKgoEL6wRJjkYy54vqNXVe5tRupQusmHZ","93QsgtSBGBih7bGYCPvkuig9wKaMDpQXLsVYCWnD6aLovP2yXLn"]'

Return result:

{
  "hex": "01000000022db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a020000008b48304502210093ee76029c94f4d25c1e31f03940ab2eb4144a5a064d6088f33e3b0190e2f7ee02201724e427fe3158cadb4334f9ea90d279dfbe0b0b275ca58db94058ee4b76b7a6014104616a75154fb4ee49c6e18900c50c248f96a2b1b92f0233aa2600677390628372914181affbe0e5490c9387f428abc8047499c3034a88eea0f9b5368a2a969004ffffffff2db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a000000008b483045022100dd08f9f493f06f67b363d245bcd2afbe5cb191fc2a7636057d3b7fe6c480968802202dfee669eac6e2e79ea6e645080f5f379b1a5e74d77b6ee3b79524bb737e81dc014104b654748d41d8d81ee6849188c569b6686d22bdf17abfa55a69b8ea40d6e57e5134bbacdcd68bdb668ea2df6428aa5129cd28f04027a18f63066d9952caaf8a09ffffffff045e593477000000001976a9141f00be4aee1d4534870b65c9b6c2e5276ffff0c888ac22020000000000001976a9146966699024c310c454049a6eaac9c58fee02081c88ac0000000000000000166a146f6d6e690000000000000001000000000d3ed6b022020000000000001976a914927f8a23044bf2f4d2231ec0d40c844da44216fe88ac00000000",
  "complete": true
}

8. Broadcast transactions

Parameters: the hexvalue of the result of step 7

omnicore-cli -conf=/root/.omnicore/bitcoin.conf "sendrawtransaction" "01000000022db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a020000008b48304502210093ee76029c94f4d25c1e31f03940ab2eb4144a5a064d6088f33e3b0190e2f7ee02201724e427fe3158cadb4334f9ea90d279dfbe0b0b275ca58db94058ee4b76b7a6014104616a75154fb4ee49c6e18900c50c248f96a2b1b92f0233aa2600677390628372914181affbe0e5490c9387f428abc8047499c3034a88eea0f9b5368a2a969004ffffffff2db78a7a1bf8a7b21fbf2a3f0557c96029095cd8d2efbdb53b11c368c214867a000000008b483045022100dd08f9f493f06f67b363d245bcd2afbe5cb191fc2a7636057d3b7fe6c480968802202dfee669eac6e2e79ea6e645080f5f379b1a5e74d77b6ee3b79524bb737e81dc014104b654748d41d8d81ee6849188c569b6686d22bdf17abfa55a69b8ea40d6e57e5134bbacdcd68bdb668ea2df6428aa5129cd28f04027a18f63066d9952caaf8a09ffffffff045e593477000000001976a9141f00be4aee1d4534870b65c9b6c2e5276ffff0c888ac22020000000000001976a9146966699024c310c454049a6eaac9c58fee02081c88ac0000000000000000166a146f6d6e690000000000000001000000000d3ed6b022020000000000001976a914927f8a23044bf2f4d2231ec0d40c844da44216fe88ac00000000"

Return result:

5c67fc9eb0cdce9af1aa4f4a9f134b1fa98bed68f03a186b2b7065227576afe3

Reference documents:

https://github.com/OmniLayer/omnicore/blob/master/src/omnicore/doc/rpc-api.md

https://gist.github.com/dexX7/352670c990ebf9ea31d6346a1519eb52

http://cw.hubwiz.com/card/c/omni-rpc-api/

Guess you like

Origin blog.csdn.net/C_jian/article/details/103036412