Detect Counterparty transaction

I’m looking for a simple way to detect if any transaction is a Counterparty transaction or not.

From docs (http://counterparty.io/docs/protocol/) :


For identification purposes, every Counterparty transaction’s ‘data’ field is prefixed by the string ‘CNTRPRTY’, encoded in UTF‐8. This string is long enough that transactions with outputs containing pseudo‐random data cannot be mistaken for valid Counterparty transactions . In testing (i.e. using the TESTCOIN Counterparty network on any blockchain), this string is ‘XX’.

Counterparty data may be stored in three different types of outputs, or in some combinations of those formats. All of the data is obfuscated by ARC4 encryption using the public key of the first sender as the encryption key.

Multi‐signature data outputs are one‐of‐three outputs where the first public key is that of the sender, so that the value of the output is redeemable, and the second two public keys encode the data, zero‐padded and prefixed with a length byte.

The data may also be stored in OP_RETURN outputs or as fake pubkeyhashes.

so, if I understand it correct, the ‘data’ could be hidden anywhere inside a transaction, right?

This is raw of my Counterparty  transaction: http://blockexplorer.com/rawtx/2efafece815ac0d40d2c232bfa51adcb9041aad7c3654a8652bbd4f5152a8a92

{
“value”:“0.00007800”,
“scriptPubKey”:“1 0304827bc3d968efe82580dca4944f6079ee8f7da1a1a587541de3cbc4db924fc8 023f154c431a5fe2340930a9663f98274f615eaf8401737b68c7df123697f8b237 0284e6a0379c5ff2d66327a7f2cf754695a81a2b186821033ddf2ccd0e6de39d82 3 OP_CHECKMULTISIG”
},

Is this a ‘data’ output?
And where’s the "CNTRPRTY (1c434e545250525459) marker then?

Check out https://github.com/pinheadmz/Counterparty-Data-Decoder. (I haven't used it myself).

Edit: I'm not sure why there's no code in your transaction. Is that a Bitcoin send tx (i.e. a Counterwallet, but not a Counterparty tx)?

Thanks for your answer.


This is a Counterparty tx made from Counterwallet.
http://www.blockscan.com/tx?txhash=2efafece815ac0d40d2c232bfa51adcb9041aad7c3654a8652bbd4f5152a8a92
Another question... Is it safe to add OP_RETURN output into Counterparty transaction? 
Transaction can hold only one OP_RETURN output according to the Bitcoin protocol.

The data may also be stored in OP_RETURN outputs or as fake pubkeyhashes.
But, I've never seen any Counterparty transaction with OP_RETURN outputs.

Hi!


I copied this from the docs:

===

All create_ API calls return an unsigned raw transaction string, hex encoded (i.e. the same format that bitcoind returns with its raw transaction API calls).

The exact form and format of this unsigned raw transaction string is specified via the encoding and pubkey parameters on each create_ API call:

  • To return the transaction as an OP_RETURN transaction, specify opreturn for the encoding parameter. Note that as of bitcoind 0.9.0, not all Counterparty transactions are possible with OP_RETURN, due to the 40 byte limit imposed by the bitcoind client in order for the transaction to be relayed on mainnet.

  • To return the transaction as a multisig transaction, specify multisig for the encoding parameter.

    • If the source address is in the local bitcoind wallet.dat. pubkey can be left as null.
    • If the source address is not in the local bitcoind wallet.dat, pubkey should be set to the hex-encoded public key.
  • auto may also be specified to let counterpartyd choose here. Note that at this time, auto is effectively the same as multisig.

  • To return the Counterparty transaction encoded into arbitrary address outputs (i.e. pubkeyhash encoding), specifypubkeyhash for the encoding parameter. pubkey is also required to be set (as above, with multisig encoding) if the source address is not contained in the local bitcoind wallet.dat. Note that this method is not recommended as a first-resort, as it pollutes the UTXO set.