Skip to content

Socket IO

nickpro edited this page Nov 30, 2018 · 25 revisions

Contents

Connection

Client must set next headers for creating a socketIO connection with server:

  • userID: user identifier
  • deviceType: field, which identifies device type: it could be Android or iOS
  • jwtToken: JWT token for user authentication

Events

Currently there is 2 event, which is represented by next JSON-object in TransactionUpdate event:

{
   transactionType: "outcoming", // or "incoming"
   amount: 122,
   status: "statusType",
   txid: "tx_id"
}

Get exchange from Poloniex (endpoint exchangePoloniex) and Gdax (endpoint exchangeGdax) and Bitfinex (endpoint exchangeBitfinex)

Response:

{
"EURtoBTC":0,
"USDtoBTC":7.418815768634956e-05,
"ETHtoBTC":0.08747900277376175, 
"ETHtoUSD":1182.2099609375,
"ETHtoEUR":0,
"BTCtoUSD":13479.240234375
"EOStoUSD":7.440423
}

Notice, that there are similar responses for this two events, but in Poloniex case ETH to EUR and EUR to BTC are always empty, because this exchange doesn't supports this rates. It is possible to ignore this fields.

Firebase

For push notifications Multy uses Firebase Cloud Messaging. It is necessary to set serverKeyin server config. When transaction for special user was done, back side is sending push notification to btcTransactionUpdate-userID.

Is user registered in several devices, all devices gets TransactionUpdate.

{
"score":           "1",
"time":            "2:00AM",
"amount":          "1000000",
"transactionType": "1",
"currencyid":      "60",
"networkid":       "4",
"walletindex":     "2",
"txid":            "0xTxID",
}

An event of transaction is similar to socketio event.

Messaging

For multisig interaction we use ws messaging over socketio

Base message is looks like :

{  
"type":1,  // it's kinda signature method eg: join:multisig.
"from":"multy",  
"to":"ur userid",  
"date":1531820490, // time unix 
"status":0,  
"payload":{}, // any    
}

Types:

"type": join multisig = 1 can everyone who have an invite code

"type":leave multisig = 2 can only who already have invited

"type":delete multisig = 3 only creator can delete

"type":kick multisig = 4 only creator can kick

"type":check multisig = 5 can everyone who have an invite code

"type":view transaction = 6 only members can view

"type":decline transaction = 7 only members can decline

Payload:

{  
"userid":"userid",  
"address":"0xAddress",  
"invitecode":"kek",  
"addresstokick":"0xAddressTo", //omitempty
"walletindex":0,  
"currencyid":60,  
"networkid":1  
"txid": "tx" // for view or decline
}

Userid related updates and responses from server will goes to: msgRecieve = "message:recieve:userid"

e.g.: join:multisig

  1. Joiner
{  
"type":1,
"from":"multy",  
"to":"ur userid",  
"date":1531820490, 
"payload":"join:multisig:ok"  
}
  1. Members if online
{  
    "currencyid":0,
    "networkid":0,
    "confirmations":0,
    "walletName":"",
    "factoryAddress":"",
    "contractAddress":"",
    "txOfCreation":"",
    "lastActionTime":0,
    "dateOfCreation":0,
    "owners":[  
        {  
            "userID":"",
            "address":"",
            "associated":false,
            "creator":false,
            "walletIndex":0,
            "addressIndex":0
        }
    ],
    "deployStatus":1,
    "status":"",
    "inviteCode":"",
    "ownersCount":0
}

leave:multisig && :multisig

  1. Reqester
{  
"type":2,
"from":"multy",  
"to":"ur userid",  
"date":1531820490, 
"payload":"leave:multisig:ok"  || ":multisig:ok" 
}
  1. Members if online

same as join:multisig

delete:multisig

  1. Reqester
{  
"type":2,
"from":"multy",  
"to":"ur userid",  
"date":1531820490, 
"payload":"delete:multisig:ok"
}
  1. Members if online
{  
"type":3,
"from":"multy",  
"to":"ur userid",  
"date":1531820490, 
"payload":"invitecode"
}

check:multisig:

  1. Reqester
{  
"type":5,
"from":"multy",  
"to":"ur userid",  
"date":1531820490, 
"payload":{
	currencyid:60,
	networkid:4,
	exists: true,
}
}

"type":view transaction = 6 only members can view

"type":decline transaction = 7 only members can decline

view transaction = 6:

  1. Reqester
{  
"type":5,
"from":"multy",  
"to":"ur userid",  
"date":1531820490, 
"payload":"viewed"
}

decline transaction = 7:

  1. Reqester
{  
"type":5,
"from":"multy",  
"to":"ur userid",  
"date":1531820490, 
"payload":"declined"
}

Notifications

message:recieve:userid:

notify on deploy ms

{  
"type":8,
"from":"multy",  
"to":"ur userid",  
"date":1531820490, 
"payload":{  
    "currencyid":0,
    "networkid":0,
    "confirmations":0,
    "walletName":"",
    "factoryAddress":"",
    "contractAddress":"",
    "txOfCreation":"",
    "lastActionTime":0,
    "dateOfCreation":0,
    "owners":[  
        {  
            "userID":"",
            "address":"",
            "associated":false,
            "creator":false,
            "walletIndex":0,
            "addressIndex":0
        }
    ],
    "deployStatus":1,
    "status":"",
    "inviteCode":"",
    "ownersCount":0
}
}

Notify on transaction

"type":NotifyPaymentReq = 9 "type":NotifyIncomingTx = 10 "type":NotifyConfirmTx = 11 "type":NotifyRevokeTx = 12

{  
"type": 9,
"from":"multy",  
"to":"ur userid",  
"date":1531820490, 
"payload":{ transaction}
}

AirDrop Runtime flow

Receiver ON

Fires by potential receiver on application startup (as for airdrop flow v2)

event:startup:receiver:on:

Request packet

{"userid": "someuserid", "usercode": "someusercode"}

Response packet

["ok"]

Receivers available

Fires by sender to get receivers and their available wallets (as for airdrop flow v2)

event:startup:receiver:available

Request packet

{"ids": ["bluetoothIdentifier1", "bluetoothIdentifier2"]}

Response packet

{
  "userid": "someuserId",
  "usercode": "bluetoothIdentifier2",
  "supportedAddresses": [
    {
      "currencyid": 60,
      "networkid": 1,
      "address": "0xsupportedAddress"
    }
  ]
}

Clone this wiki locally