tokenly / swapbot

Exchange tokens with an automated machine
3 stars 4 forks source link

Specify a different recipient address encoded in an OP_RETURN #227

Open deweller opened 8 years ago

deweller commented 8 years ago

When a user purchases a token with BTC, swapbot will look for an OP_RETURN in the transaction. If it finds one, and the OP_RETURN begins with SWAPBOT and 0x00 (0x53574150424f5400), then the next 25 bytes will be interpreted as a new destination bitcoin address.

Each OP_RETURN should be exactly 33 bytes in length.

Here is an example OP_RETURN to specify that the swap should be sent to the bitcoin address 1JztLWos5K7LsqW5E78EASgiVBaCe6f7cD.

53574150424f54|00|00c56cb39f9b289c0ec4ef6943fa107c904820fe0980df2772
     |         |                 |    
     |         |                 └── 25 byte bitcoin address (not in base58 format)
     |         |
     |         └─ 0x00 instruction byte
     |
     └── "SWAPBOT"
deweller commented 8 years ago

For a small PHP library to encode this OP_RETURN data, see https://github.com/tokenly/swapbot-op-return.