| BRFC | title | authors | version |
|---|---|---|---|
| 8f90ea3dd551 | MSGP | bitcoineler/SH | 1.0.0 |
A simple messaging protocol to send messages to bitcoin users (unicast | multicast | broadcast). The protocol is used to establish a connection via Bitcoin. Further data exchange can then be made via Bitcoin or P2P.
- negotigate connection information via bitcoin to establish a P2P connection (VoIP Calls, sharing Files, etc.)
- encapsulate other protocols into MSGP (Chat, Filesharing, etc.)
6d736770 <type> <channel-id> <data>
| field | size | function |
|---|---|---|
prefix |
4 Bytes | protocol prefix 0x6d736770 |
type |
4 Bytes | message type |
channel-ID |
32 Bytes | channel identifier |
data |
n Bytes | protocoldata + encapsulated protocols |
Prefix (4Bytes): 0x6d736770 (ASCII:'MSGP')
A 32Byte Channel identifier e.g SHA256-Hash(pubkey) or a broadcast address
further protocol data + encapsulated protocols. Encrypted using (bsv.Ecies.electrumEncrypt) or unencrypted (see message types)
<senderPubkey> <sigHashFlag> <senderSig> <sequenceNumber> <encapsulatedProtocolData>
| field | size | function |
|---|---|---|
senderPubkey |
33 Bytes | sender Publickey |
sigHashFlag |
1 Bytes | sigHash Flag (https://wiki.bitcoinsv.io/index.php/SIGHASH_flags) |
senderSig |
70 Bytes | sender Signature |
sequenceNumber |
4 Bytes | sequencenumber |
encapsulatedProtocolData |
n Bytes | protocoldata |
Use sigHashFlag, include at least one Input in the signed preimage to prevent message replay.
Type is a 4 Byte field.
| type | description |
|---|---|
| 0x00000001 | MSGP unicast/multicast v1 (for a single receiver or group) |
| 0x00000002 | MSGP broadcast v1 |
Unicast/Multicast encrypted
Type (4Bytes): 0x00000001
Channel-ID (32Bytes): e481259cdfa4ed647fdc446ffc8f848993543092bf46570fb984f56d7d1f4021
Encrypted-Data: Encrypted(SenderPubkey][sigHashFlag][senderSig][sequenceNumber][protocolData])
Broadcast unencrypted
Type (4Bytes): 0x00000002
Channel-ID (32Bytes): ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
Unecrypted-Data: [senderPubkey][sigHashFlag][senderSig][sequenceNumber][protocolData]
6d736770 00000001 e481259cdfa4ed647fdc446ffc8f848993543092bf46570fb984f56d7d1f4021 42494531023b7c441578c792d10f4b55ae1b509073a78cdf620b2d77a35e0ae4fa167708e91cb683a65cc03aaa315f9e8020c161e8e90f2e572db1ad3e534139ac667ec1faf76678662c15551e0b4d273e0f9ea2e037f3a0b6506bec746dc12e01b71ac9f4dc66888716667fe9c92c7ba43e71e93586a435dcae2c01e1d135ffa0794f69fbcf2adf983e6adaf240d5fb490057ce3a8f204fceaabe62c49740b8755dbc47b3dbbc21890c7e015135b6c77208d1f58556f1bfabeafc5f11d8f7d15440d056881be2ac1f78ccd1877b4e326a3a5214226f3f903d69bc136425ccfd17e32be7bd
- Prefix (MSGP):
6d736770 - Type:
00000001 - Channel-ID:
e481259cdfa4ed647fdc446ffc8f848993543092bf46570fb984f56d7d1f4021 - Encrypted data:
42494531023b7c441578c792d10f4b55ae1b509073a78cdf620b2d77a35e0ae4fa167708e91cb683a65cc03aaa315f9e8020c161e8e90f2e572db1ad3e534139ac667ec1faf76678662c15551e0b4d273e0f9ea2e037f3a0b6506bec746dc12e01b71ac9f4dc66888716667fe9c92c7ba43e71e93586a435dcae2c01e1d135ffa0794f69fbcf2adf983e6adaf240d5fb490057ce3a8f204fceaabe62c49740b8755dbc47b3dbbc21890c7e015135b6c77208d1f58556f1bfabeafc5f11d8f7d15440d056881be2ac1f78ccd1877b4e326a3a5214226f3f903d69bc136425ccfd17e32be7bd
There are two ways of writing into bitcoin, using OP_RETURN or OP_PUSHDATA
OP_PUSHDATA <MSGP-Data> OP_DROP OP_DUP OP_HASH160 <HASH160> OP_EQUALVERIFY OP_CHECKSIGOP_FALSE OP_RETURN <MSGP-Data>
You can receive & read messages by filtering the blockchain for MSGP transactions or subscribe to a filter service.
MSGP Transaction by TxId
https://gateway.codugh.com/api/MSGP-Bitcoin-Messaging-Protocol/tx/{txid}
Confirmed MSGP Transactions
https://gateway.codugh.com/api/MSGP-Bitcoin-Messaging-Protocol/c/{channelId}
Unconfirmed MSGP Transactions
https://gateway.codugh.com/api/MSGP-Bitcoin-Messaging-Protocol/u/{channelId}
MSGP Transactions Eventstream
https://gateway.codugh.com/api/MSGP-Bitcoin-Messaging-Protocol/s/{channelId}