Hush Full Node software. We were censored from Github, this is where all development happens now. https://hush.is
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

152 lines
6.0 KiB

8 years ago
/******************************************************************************
* Copyright © 2014-2016 The SuperNET Developers. *
* *
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
* the top-level directory of this distribution for the individual copyright *
* holder information and the developer policies on copyright and licensing. *
* *
* Unless otherwise agreed in a custom licensing agreement, no part of the *
* SuperNET software, including this file may be copied, modified, propagated *
* or distributed except according to the terms contained in the LICENSE file *
* *
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
#ifndef H_KOMODOEVENTS_H
#define H_KOMODOEVENTS_H
8 years ago
8 years ago
#ifdef WIN32
#define PACKED
#else
#define PACKED __attribute__((packed))
#endif
8 years ago
#define KOMODO_EVENT_RATIFY 'P'
8 years ago
#define KOMODO_EVENT_NOTARIZED 'N'
#define KOMODO_EVENT_UTXO 'U'
#define KOMODO_EVENT_KMDHEIGHT 'K'
//#define KOMODO_EVENT_DELETE 'D'
#define KOMODO_EVENT_PRICEFEED 'V'
#define KOMODO_EVENT_OPRETURN 'R'
#define KOMODO_OPRETURN_DEPOSIT 'D'
8 years ago
#define KOMODO_OPRETURN_ISSUED 'I' // assetchain
8 years ago
#define KOMODO_OPRETURN_WITHDRAW 'W' // assetchain
8 years ago
#define KOMODO_OPRETURN_REDEEMED 'X'
8 years ago
8 years ago
struct komodo_event_notarized { bits256 blockhash,desttxid; int32_t notarizedheight; char dest[16]; } PACKED;
8 years ago
struct komodo_event_pubkeys { uint8_t num; uint8_t pubkeys[64][33]; } PACKED;
8 years ago
struct komodo_event_utxo { bits256 txid; uint64_t voutmask; uint8_t numvouts; } PACKED;
8 years ago
struct komodo_event_opreturn { bits256 txid; uint64_t value; uint16_t vout,oplen; uint8_t opret[]; } PACKED;
8 years ago
struct komodo_event_pricefeed { uint8_t num; uint32_t prices[35]; } PACKED;
struct komodo_event
{
struct komodo_event *related;
uint16_t len;
int32_t height;
uint8_t type,reorged;
char symbol[16];
uint8_t space[];
} PACKED;
8 years ago
struct komodo_event *komodo_eventadd(int32_t height,char *symbol,uint8_t type,uint8_t *data,uint16_t datalen)
8 years ago
{
struct komodo_event *ep; uint16_t len = (uint16_t)(sizeof(*ep) + datalen);
8 years ago
ep = (struct komodo_event *)calloc(1,len);
8 years ago
ep->len = len;
ep->height = height;
ep->type = type;
strcpy(ep->symbol,symbol);
if ( datalen != 0 )
memcpy(ep->space,data,datalen);
return(ep);
}
8 years ago
void komodo_eventadd_notarized(char *symbol,int32_t height,char *dest,bits256 blockhash,bits256 desttxid,int32_t notarizedheight)
8 years ago
{
struct komodo_event_notarized N;
memset(&N,0,sizeof(N));
N.blockhash = blockhash;
N.desttxid = desttxid;
N.notarizedheight = notarizedheight;
strcpy(N.dest,dest);
8 years ago
komodo_eventadd(height,symbol,KOMODO_EVENT_NOTARIZED,(uint8_t *)&N,sizeof(N));
8 years ago
}
void komodo_eventadd_pubkeys(char *symbol,int32_t height,uint8_t num,uint8_t pubkeys[64][33])
{
struct komodo_event_pubkeys P;
memset(&P,0,sizeof(P));
P.num = num;
memcpy(P.pubkeys,pubkeys,33 * num);
8 years ago
komodo_eventadd(height,symbol,KOMODO_EVENT_RATIFY,(uint8_t *)&P,(int32_t)(sizeof(P.num) + 33 * num));
8 years ago
}
8 years ago
void komodo_eventadd_utxo(char *symbol,int32_t height,uint8_t notaryid,bits256 txid,uint64_t voutmask,uint8_t numvouts)
8 years ago
{
struct komodo_event_utxo U;
memset(&U,0,sizeof(U));
U.txid = txid;
U.voutmask = voutmask;
U.numvouts = numvouts;
8 years ago
komodo_eventadd(height,symbol,KOMODO_EVENT_UTXO,(uint8_t *)&U,sizeof(U));
8 years ago
}
void komodo_eventadd_pricefeed(char *symbol,int32_t height,uint32_t *prices,uint8_t num)
{
struct komodo_event_pricefeed F;
memset(&F,0,sizeof(F));
F.num = num;
memcpy(F.prices,prices,sizeof(*F.prices) * num);
8 years ago
komodo_eventadd(height,symbol,KOMODO_EVENT_PRICEFEED,(uint8_t *)&F,(int32_t)(sizeof(F.num) + sizeof(*F.prices) * num));
8 years ago
}
void komodo_eventadd_kmdheight(char *symbol,int32_t height,int32_t kmdheight)
{
8 years ago
komodo_eventadd(height,symbol,KOMODO_EVENT_KMDHEIGHT,(uint8_t *)&kmdheight,sizeof(kmdheight));
8 years ago
}
8 years ago
void komodo_eventadd_opreturn(char *symbol,int32_t height,uint8_t type,bits256 txid,uint64_t value,uint16_t vout,uint8_t *buf,uint16_t opretlen)
8 years ago
{
struct komodo_event_opreturn O; uint8_t opret[10000];
memset(&O,0,sizeof(O));
O.txid = txid;
O.value = value;
O.vout = vout;
memcpy(opret,&O,sizeof(O));
8 years ago
memcpy(&opret[sizeof(O)],buf,opretlen);
8 years ago
O.oplen = (int32_t)(opretlen + sizeof(O));
komodo_eventadd(height,symbol,type,opret,O.oplen);
8 years ago
}
8 years ago
void komodo_eventadd_deposit(char *symbol,int32_t height,uint64_t komodoshis,char *fiat,uint64_t fiatoshis,uint8_t rmd160[20],bits256 kmdtxid,uint16_t kmdvout,uint64_t price)
8 years ago
{
uint8_t opret[512]; uint16_t opretlen;
8 years ago
komodo_eventadd_opreturn(symbol,height,KOMODO_OPRETURN_DEPOSIT,kmdtxid,komodoshis,kmdvout,opret,opretlen);
8 years ago
}
8 years ago
void komodo_eventadd_issued(char *symbol,int32_t height,int32_t fiatheight,bits256 fiattxid,uint16_t fiatvout,bits256 kmdtxid,uint16_t kmdvout,uint64_t fiatoshis)
8 years ago
{
uint8_t opret[512]; uint16_t opretlen;
8 years ago
komodo_eventadd_opreturn(symbol,height,KOMODO_OPRETURN_ISSUED,fiattxid,fiatoshis,fiatvout,opret,opretlen);
8 years ago
}
8 years ago
void komodo_eventadd_withdraw(char *symbol,int32_t height,uint64_t komodoshis,char *fiat,uint64_t fiatoshis,uint8_t rmd160[20],bits256 fiattxid,int32_t fiatvout,uint64_t price)
8 years ago
{
uint8_t opret[512]; uint16_t opretlen;
8 years ago
komodo_eventadd_opreturn(symbol,height,KOMODO_OPRETURN_WITHDRAW,fiattxid,fiatoshis,fiatvout,opret,opretlen);
8 years ago
}
8 years ago
void komodo_eventadd_redeemed(char *symbol,int32_t height,bits256 kmdtxid,uint16_t kmdvout,int32_t fiatheight,bits256 fiattxid,uint16_t fiatvout,uint64_t komodoshis)
8 years ago
{
uint8_t opret[512]; uint16_t opretlen;
8 years ago
komodo_eventadd_opreturn(symbol,height,KOMODO_OPRETURN_REDEEMED,kmdtxid,komodoshis,kmdvout,opret,opretlen);
8 years ago
}
// process events
//
8 years ago
8 years ago
#endif