Post
Topic
Board Altcoin Discussion
Re: Bitcoin Protocol OP_RETURN + Omni USDT Tether + CoPay Multisig Help
by
shmali
on 04/12/2017, 21:20:08 UTC
I can provide some insight though i've pinged one of the omnicore dev's to assist with some of the more base line bitcoin protocol details.
For full details on the Omni protocol spec please see: https://github.com/OmniLayer/spec

While all transactions on the OmniProtocol are sent over the Bitcoin network there are a few general rules on the structure of an Omni protocol transaction (and thus a tether send transaction) :

First since it is on the bitcoin network, it will have to be a valid bitcoin tx at the end of the day. So miners fee's signing inputs/outputs etc.. all have to comply with a normal tx.

Next, The sender is determined by the first input in the tx. So you can fund the tx from several address if needed, however only the first input in the tx will signal to the Omni protocol who is sending the Omni Assets.

The receiver is chosen/indicated by the last output address that is not the sender. So if you want to send any extra btc change back to yourself or to a different address specify those first.
Signaling The receiver address only needs a fraction of btc,  right now we're using 0.00005460 btc as that 'reference output amount'.

Finally the guts and glory of an Omni Protocol transaction, the data packet encoded into OP_RETURN.
This is a hex encoded payload that has a few different components.
From your example above you already have the ASM OP_RETURN 6f6d6e69000000000000001f000000002faf0800 OP_EQUAL

If we break it down we get:
Bitcoin protocol:
 OP_RETURN  opcode/operation

Omni protocol (hex encoded values):
 6f6d6e69 -  string 'omni' used to indicate/mark the tx is for the omni protocol to Omni software
 0000 - Next 4 bytes indicate the Transaction version, at present simple send is version 0
 0000 - next 4 bytes indicate transaction type, simple send is type 0
 0000001f - Next 8 bytes, are used to represent the token property id of tokens being acted upon, In this case Tether is Property id 31, 1f in hex
 000000002faf0800 - Next 16 bytes are used to indicate the number of tokens being sent as a whole number.
  Note: The omni protocol has 2 concepts for tokens, Divisible like bitcoin, fractional amounts. And not indivisible, smallest unit represented is 1, no fractional amounts. When encoding
  amounts for the payload divisible amounts are converted to whole number representations (multiple by 1e8). Since Tether is a divisible property, sending an amount of 8, you would
  hex encoded 800000000 * 8 *  1e8)

Bitcoin protocol :
 OP_EQUAL -  You actually do not want this, remove it. THE OP_RETURN is a data payload, not actually an addresses.

A few more notes/things to understand.
The Omni Protocol is not Input/Output based. I.e. the output of a 8 tether send is not needed/relevant when sending 8 Tethers later on.
The Omni Protocol is basically a state machine, where every transaction you send is just an instruction that state machine uses to update a balance or process a request.
So when you send 8 Tether, you are basically sending the instructions to the Omni protocol that say, transfer 8 Tether from address X to address Y.
If all the validation/security/tx checking are verified then the software processes the request and balances are updated/funds are moved.

I've updated your tx (without signatures) to show what the 8 Tether simple send would look like using only the 1 input (minimize tx size)
Code:
0100000001cb0e9efba54a6acee3d8b09df2b9527ca05fb1c61b6f893ad5c8ee2cc4d6f54e00000000b500483045022100d7845a9e0e854d675451863027eefaa7b01d5ae87ee700c3b40012e2c94a30760220053e223dca51f234887226871cbbe94678913ab8b96c60edff8e454a2efc4876014c6951210247bcd2c9e1bf8bfc9e567c8f9c81ef5f2c5356e544ab7b9141b7ef93f272da9f2102771dbfd6b9e6183e893c07ea49cfc781d1836e42b6425ff2a59100cc2e9b11222102ab0456bde3a2a8f5066fa4827c8a00c9388e6da1fdc22f90c406d89112c8bacb53aeffffffff030000000000000000176a156f6d6e69000000000000001f000000002faf080087a0860100000000001976a9142168fe52d8c1cbc656a544859c4193dd4b92e23788ac54150000000000001976a914f40da014c137ad88006608834887556944e2dfeb88ac00000000


and if we decode it to show both the BTC and OMNI decode info we get

Code:
{
  "BTC": {
    "hash": "fbe3b32419117a95e0983bf930a1d2b285e3c8a8a6af082c59d24e7e47fc354a",
    "locktime": 0,
    "size": 332,
    "txid": "fbe3b32419117a95e0983bf930a1d2b285e3c8a8a6af082c59d24e7e47fc354a",
    "version": 1,
    "vin": [
      {
        "scriptSig": {
          "asm": "0 3045022100d7845a9e0e854d675451863027eefaa7b01d5ae87ee700c3b40012e2c94a30760220053e223dca51f234887226871cbbe94678913ab8b96c60edff8e454a2efc4876[ALL] 51210247bcd2c9e1bf8bfc9e567c8f9c81ef5f2c5356e544ab7b9141b7ef93f272da9f2102771dbfd6b9e6183e893c07ea49cfc781d1836e42b6425ff2a59100cc2e9b11222102ab0456bde3a2a8f5066fa4827c8a00c9388e6da1fdc22f90c406d89112c8bacb53ae",
          "hex": "00483045022100d7845a9e0e854d675451863027eefaa7b01d5ae87ee700c3b40012e2c94a30760220053e223dca51f234887226871cbbe94678913ab8b96c60edff8e454a2efc4876014c6951210247bcd2c9e1bf8bfc9e567c8f9c81ef5f2c5356e544ab7b9141b7ef93f272da9f2102771dbfd6b9e6183e893c07ea49cfc781d1836e42b6425ff2a59100cc2e9b11222102ab0456bde3a2a8f5066fa4827c8a00c9388e6da1fdc22f90c406d89112c8bacb53ae"
        },
        "sequence": 4294967295,
        "txid": "4ef5d6c42ceec8d53a896f1bc6b15fa07c52b9f29db0d8e3ce6a4aa5fb9e0ecb",
        "vout": 0
      }
    ],
    "vout": [
      {
        "n": 0,
        "scriptPubKey": {
          "asm": "OP_RETURN 6f6d6e69000000000000001f000000002faf080087",
          "hex": "6a156f6d6e69000000000000001f000000002faf080087",
          "type": "nulldata"
        },
        "value": 0.0
      },
      {
        "n": 1,
        "scriptPubKey": {
          "addresses": [
            "143f5QPkc5mJurEr2kGPPoecJqkhvaQ2u2"
          ],
          "asm": "OP_DUP OP_HASH160 2168fe52d8c1cbc656a544859c4193dd4b92e237 OP_EQUALVERIFY OP_CHECKSIG",
          "hex": "76a9142168fe52d8c1cbc656a544859c4193dd4b92e23788ac",
          "reqSigs": 1,
          "type": "pubkeyhash"
        },
        "value": 0.001
      },
      {
        "n": 2,
        "scriptPubKey": {
          "addresses": [
            "1PFSCWbPdfQfwtRidBxj5x2HxigG7JGFNb"
          ],
          "asm": "OP_DUP OP_HASH160 f40da014c137ad88006608834887556944e2dfeb OP_EQUALVERIFY OP_CHECKSIG",
          "hex": "76a914f40da014c137ad88006608834887556944e2dfeb88ac",
          "reqSigs": 1,
          "type": "pubkeyhash"
        },
        "value": 5.46e-05
      }
    ],
    "vsize": 332
  },
  "OMNI": {
    "amount": "8.00000000",
    "confirmations": 0,
    "divisible": true,
    "fee": "0.00094540",
    "ismine": false,
    "propertyid": 31,
    "referenceaddress": "1PFSCWbPdfQfwtRidBxj5x2HxigG7JGFNb",
    "sendingaddress": "3B2d4gAe51A6yEPG9qAxRfKxdVA1Zfpq9R",
    "txid": "fbe3b32419117a95e0983bf930a1d2b285e3c8a8a6af082c59d24e7e47fc354a",
    "type": "Simple Send",
    "type_int": 0,
    "version": 0
  }  
}

If you were to sign this tx with the required number of signatures it would be valid to send.