repo_name
stringlengths
5
122
path
stringlengths
3
232
text
stringlengths
6
1.05M
valkyrienyanko/game-engine
Game Engine/src/graphics/buffers/indexbuffer.h
#pragma once #include <GL/glew.h> #include "../renderer.h" namespace valk { namespace graphics { class IndexBuffer { private: GLuint m_BufferID; GLuint m_Count; public: IndexBuffer(GLushort* data, GLsizei count); ~IndexBuffer(); void bind() const; void unbind() const; inline GLuint getCount() const { return m_Count; } }; } }
valkyrienyanko/game-engine
Game Engine/src/graphics/window.h
#pragma once #include "renderer.h" #include <GLFW/glfw3.h> #include <iostream> namespace valk { namespace graphics { constexpr int MAX_KEYS = 1024; constexpr int MAX_BUTTONS = 32; class Window { private: const char* m_Title; int m_Width, m_Height; GLFWwindow *m_Window; bool m_Closed; bool m_Keys[MAX_KEYS]; bool m_MouseButtons[MAX_BUTTONS]; double mx, my; public: Window(const char *title, int width, int height); ~Window(); void clear() const; void update(); bool closed() const; inline int getWidth() { return m_Width; } inline int getHeight() { return m_Height; } bool isKeyDown(unsigned int keycode) const; bool isMouseDown(unsigned int button) const; void getMousePos(double& x, double& y) const; private: bool init(); friend static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods); friend static void mouse_button_callback(GLFWwindow* window, int button, int action, int mods); friend static void cursor_position_callback(GLFWwindow* window, double xpos, double ypos); }; } }
valkyrienyanko/game-engine
Game Engine/src/utils/fileutils.h
#pragma once #include <string> #include <fstream> namespace valk { class FileUtils { public: static std::string read_file(const std::string& filepath) { std::ifstream ifs((filepath).c_str()); std::string content( std::istreambuf_iterator<char>(ifs.rdbuf()), std::istreambuf_iterator<char>() ); return content; } }; }
valkyrienyanko/game-engine
Game Engine/src/maths/maths_func.h
<filename>Game Engine/src/maths/maths_func.h #pragma once #pragma warning (disable : 4244) // Possible loss of data conversion from double to float #define _USE_MATH_DEFINES #include <math.h> namespace valk { namespace maths { inline float toRadians(float degrees) { return degrees * (M_PI / 180.0f); } } }
valkyrienyanko/game-engine
Game Engine/src/graphics/renderable2d.h
#pragma once #include "buffers\buffer.h" #include "buffers\indexbuffer.h" #include "buffers\vertexarray.h" #include "..\maths\maths.h" #include "shader.h" namespace valk { namespace graphics { class Renderable2D { protected: maths::vec3 m_Position; maths::vec2 m_Size; maths::vec4 m_Color; VertexArray* m_VertexArray; IndexBuffer* m_IndexBuffer; Shader& m_Shader; public: Renderable2D(maths::vec3 position, maths::vec2 size, maths::vec4 color, Shader& shader) : m_Position(position), m_Size(size), m_Color(color), m_Shader(shader) { m_VertexArray = new VertexArray(); GLfloat vertices[] = { 0, 0, 0, 0, size.y, 0, size.x, size.y, 0, size.x, 0, 0, }; GLfloat colors[] = { color.x, color.y, color.z, color.w, color.x, color.y, color.z, color.w, color.x, color.y, color.z, color.w, color.x, color.y, color.z, color.w }; m_VertexArray->addBuffer(new Buffer(vertices, 4 * 3, 3), 0); m_VertexArray->addBuffer(new Buffer(colors, 4 * 4, 4), 1); GLushort indices[] = { 0, 1, 2, 2, 3, 0 }; m_IndexBuffer = new IndexBuffer(indices, 6); } virtual ~Renderable2D() { delete m_VertexArray; delete m_IndexBuffer; } inline const VertexArray* getVAO() const { return m_VertexArray; } inline const IndexBuffer* getIBO() const { return m_IndexBuffer; } inline Shader& getShader() const { return m_Shader; } inline const maths::vec3& getPosition() const { return m_Position; } inline const maths::vec2& getSize() const { return m_Size; } inline const maths::vec4& getColor() const { return m_Color; } }; } }
Dez1J/dwmblocks
plugin/battery_plus.c
<reponame>Dez1J/dwmblocks<gh_stars>0 #include <X11/Xlib.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <signal.h> #include <limits.h> #define PDN #define PUP #define LENGTH(X) (sizeof X / sizeof X[0]) #define BLOCKLENGTH 512 char curtext[BLOCKLENGTH]; #define BLOCKLENGTH 512 #define SPRINTF(str, ...) ({ \ int len = snprintf(str, BLOCKLENGTH, __VA_ARGS__); \ len < BLOCKLENGTH ? len + 1 : BLOCKLENGTH; \ }) #define NILL INT_MIN #define ICONe "๎ท" /* unexpected error */ #define ICONa "๎" /* no battery */ #define ICON0 "๏‰„" #define ICON1 "๏‰ƒ" #define ICON2 "๏‰‚" #define ICON3 "๏‰" #define ICON4 "๏‰€" //#define ICON5 "๎‰‹" //#define ICON6 "๎‰ˆ" //#define ICON7 "๎‰‰" //#define ICON8 "๎‰Š" //#define ICON9 "๎‰‡" //#define ICON(bat) icons[(bat * (LENGTH(icons) - 1) + 50) / 100] #define ICON(bat) icons[((bat - 1) * LENGTH(icons)) / 100 ] #define BATC 10 /* critical level */ #define BATL 20 /* low level */ #define BATP 40 /* plug in level */ #define BATU 80 /* unplug level */ #define BATCAPFILE "/sys/class/power_supply/BAT0/capacity" #define ACSTATEFILE "/sys/class/power_supply/AC0/online" #define BATCFULLFILE "/sys/class/power_supply/BAT0/charge_full" #define BATCNOWFILE "/sys/class/power_supply/BAT0/charge_now" #define BATRATEFILE "/sys/class/power_supply/BAT0/current_now" #define CNOTIFY(t, msg) (char *[]){ "notify-send", \ "-h", "string:x-canonical-private-synchronous:batmon", \ "-u", "critical", \ "-t", t, \ "BatMon", msg, NULL } #define NNOTIFY(t, msg) (char *[]){ "notify-send", \ "-h", "string:x-canonical-private-synchronous:batmon", \ "-t", t, \ "BatMon", msg, NULL } #define TNOTIFY(t, msg) (char *[]){ "notify-send", \ "-h", "string:x-canonical-private-synchronous:batmon", \ "-h", "int:transient:1", \ "-t", t, \ "BatMon", msg, NULL } #define UCNOTIFY(t, msg) uspawn(NNOTIFY(t, msg)) #define UNNOTIFY(t, msg) uspawn(NNOTIFY(t, msg)) #define UTNOTIFY(t, msg) uspawn(TNOTIFY(t, msg)) enum { Normal, Critical, Low, Plug, Unplug }; int readint(const char *path, int *var) { FILE *fp; if (!(fp = fopen(path, "r"))) return 0; if (fscanf(fp, "%d", var) != 1) { fclose(fp); return 0; } fclose(fp); return 1; } Display *dpy; void cleanup() { /* XStoreName(dpy, DefaultRootWindow(dpy), ""); */ XCloseDisplay(dpy); } void uspawn(char *const *arg) { switch (fork()) { case -1: perror("uspawn - fork"); cleanup(); exit(1); case 0: close(ConnectionNumber(dpy)); setsid(); execvp(arg[0], arg); perror("uspawn - child - execvp"); _exit(127); } } size_t batteryu(char *str, int ac) { static int level = Normal; static char *icons[] = { ICON0, ICON1, ICON2, ICON3, ICON4 }; int bat; if (!readint(BATCAPFILE, &bat)) { strcpy(str, ICONa); return sizeof ICONa; } /* routine update */ if (ac == NILL) { if (!readint(ACSTATEFILE, &ac)) return SPRINTF(str, ICONe "%d%%", bat); if (ac) { if (bat < BATU) level = Normal; else { if (level != Unplug) { UNNOTIFY("0", "Unplug the charger"); level = Unplug; } } return SPRINTF(str, PUP "%s%d%%", ICON(bat), bat); } else { if (bat > BATP) level = Normal; else if (bat > BATL) { if (level != Plug) { UNNOTIFY("0", "Plug in the charger"); level = Plug; } } else if (bat > BATC) { if (level != Low) { UNNOTIFY("0", "Battery level is low!"); level = Low; } } else { if (level != Critical) { UCNOTIFY("0", "Battery level is critical!"); level = Critical; } } return SPRINTF(str, PDN "%s%d%%", ICON(bat), bat); } /* charger plugged in */ } else if (ac) { if (bat < BATU) { UTNOTIFY("1000", "Charger plugged in"); level = Normal; } else { //UNNOTIFY("0", "Unplug the charger"); UNNOTIFY("0", "please Unplug the charger"); level = Unplug; } return SPRINTF(str, PUP "%s%d%%", ICON(bat), bat); /* charger plugged out */ } else { if (bat > BATP) { UTNOTIFY("1000", "Charger plugged out"); level = Normal; } else if (bat > BATL) { UNNOTIFY("0", "Plug in the charger"); level = Plug; } else if (bat > BATC) { UNNOTIFY("0", "Battery level is low!"); level = Low; } else { UCNOTIFY("0", "Battery level is critical!"); level = Critical; } return SPRINTF(str, PDN "%s%d%%", ICON(bat), bat); } } int main(){ if (!(dpy = XOpenDisplay(NULL))) { fputs("Error: could not open display.\n", stderr); return 1; } batteryu(curtext, 1); // uspawn(TNOTIFY("0", "main function x notify information senf test!")); printf("battery test:%s",curtext); XCloseDisplay(dpy); return 0; }
Dez1J/dwmblocks
plugin/alsa_vol.c
<filename>plugin/alsa_vol.c<gh_stars>0 /* include this into your dwmstatus.c and use get_vol() as volume. * * if your audio card and subunit numbers differ from 0,0 you might havo * * to use amixer, aplay and the /proc/asound file tree to adapt. * * * * I had compilation issues. As result i had to drop the -std=c99 and * * -pedantic flags from the config.mk * */ #include <alsa/asoundlib.h> #include <alsa/control.h> #include <stdio.h> int get_vol(void) { int vol; snd_hctl_t *hctl; snd_ctl_elem_id_t *id; snd_ctl_elem_value_t *control; // To find card and subdevice : / proc / asound /, aplay - L,amixer controls snd_hctl_open(&hctl, "hw:0", 0); snd_hctl_load(hctl); snd_ctl_elem_id_alloca(&id); snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER); // amixer controls snd_ctl_elem_id_set_name(id, "Master Playback Volume"); snd_hctl_elem_t *elem = snd_hctl_find_elem(hctl, id); snd_ctl_elem_value_alloca(&control); snd_ctl_elem_value_set_id(control, id); snd_hctl_elem_read(elem, control); vol = (int)snd_ctl_elem_value_get_integer(control, 0); snd_hctl_close(hctl); return vol; } int main(){ printf("Test:%d",get_vol()); }
Dez1J/dwmblocks
plugin/pulsea_vol.c
<filename>plugin/pulsea_vol.c /** * Author: <NAME> * License: Public Domain * * Description: * This is a simple test program to hook into PulseAudio volume change * notifications. It was created for the possibility of having an automatically * updating volume widget in a tiling window manager status bar. * * Compiling: * * g++ $(shell pkg-config libpulse --cflags --libs) pulsetest.c -o pulsetest */ #include <stdio.h> #include <assert.h> #include <signal.h> #include <pulse/pulseaudio.h> class PulseAudio { private: pa_mainloop* _mainloop; pa_mainloop_api* _mainloop_api; pa_context* _context; pa_signal_event* _signal; public: PulseAudio() : _mainloop(NULL), _mainloop_api(NULL), _context(NULL), _signal(NULL) { } /** * Initializes state and connects to the PulseAudio server. */ bool initialize() { _mainloop = pa_mainloop_new(); if (!_mainloop) { fprintf(stderr, "pa_mainloop_new() failed.\n"); return false; } _mainloop_api = pa_mainloop_get_api(_mainloop); if (pa_signal_init(_mainloop_api) != 0) { fprintf(stderr, "pa_signal_init() failed\n"); return false; } _signal = pa_signal_new(SIGINT, exit_signal_callback, this); if (!_signal) { fprintf(stderr, "pa_signal_new() failed\n"); return false; } signal(SIGPIPE, SIG_IGN); _context = pa_context_new(_mainloop_api, "PulseAudio Test"); if (!_context) { fprintf(stderr, "pa_context_new() failed\n"); return false; } if (pa_context_connect(_context, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL) < 0) { fprintf(stderr, "pa_context_connect() failed: %s\n", pa_strerror(pa_context_errno(_context))); return false; } pa_context_set_state_callback(_context, context_state_callback, this); return true; } /** * Runs the main PulseAudio event loop. Calling quit will cause the event * loop to exit. */ int run() { int ret = 1; if (pa_mainloop_run(_mainloop, &ret) < 0) { fprintf(stderr, "pa_mainloop_run() failed.\n"); return ret; } return ret; } /** * Exits the main loop with the specified return code. */ void quit(int ret = 0) { _mainloop_api->quit(_mainloop_api, ret); } /** * Called when the PulseAudio system is to be destroyed. */ void destroy() { if (_context) { pa_context_unref(_context); _context = NULL; } if (_signal) { pa_signal_free(_signal); pa_signal_done(); _signal = NULL; } if (_mainloop) { pa_mainloop_free(_mainloop); _mainloop = NULL; _mainloop_api = NULL; } } ~PulseAudio() { destroy(); } private: /* * Called on SIGINT. */ static void exit_signal_callback(pa_mainloop_api *m, pa_signal_event *e, int sig, void *userdata) { PulseAudio* pa = (PulseAudio*)userdata; if (pa) pa->quit(); } /* * Called whenever the context status changes. */ static void context_state_callback(pa_context *c, void *userdata) { assert(c && userdata); PulseAudio* pa = (PulseAudio*)userdata; switch (pa_context_get_state(c)) { case PA_CONTEXT_CONNECTING: case PA_CONTEXT_AUTHORIZING: case PA_CONTEXT_SETTING_NAME: break; case PA_CONTEXT_READY: fprintf(stderr, "PulseAudio connection established.\n"); pa_context_get_server_info(c, server_info_callback, userdata); // Subscribe to sink events from the server. This is how we get // volume change notifications from the server. pa_context_set_subscribe_callback(c, subscribe_callback, userdata); pa_context_subscribe(c, PA_SUBSCRIPTION_MASK_SINK, NULL, NULL); break; case PA_CONTEXT_TERMINATED: pa->quit(0); fprintf(stderr, "PulseAudio connection terminated.\n"); break; case PA_CONTEXT_FAILED: default: fprintf(stderr, "Connection failure: %s\n", pa_strerror(pa_context_errno(c))); pa->quit(1); break; } } /* * Called when an event we subscribed to occurs. */ static void subscribe_callback(pa_context *c, pa_subscription_event_type_t type, uint32_t idx, void *userdata) { unsigned facility = type & PA_SUBSCRIPTION_EVENT_FACILITY_MASK; //type &= PA_SUBSCRIPTION_EVENT_TYPE_MASK; pa_operation *op = NULL; switch (facility) { case PA_SUBSCRIPTION_EVENT_SINK: op = pa_context_get_sink_info_by_index(c, idx, sink_info_callback, userdata); break; default: assert(0); // Got event we aren't expecting. break; } if (op) pa_operation_unref(op); } /* * Called when the requested sink information is ready. */ static void sink_info_callback(pa_context *c, const pa_sink_info *i, int eol, void *userdata) { if (i) { float volume = (float)pa_cvolume_avg(&(i->volume)) / (float)PA_VOLUME_NORM; printf("percent volume = %.0f%%%s\n", volume * 100.0f, i->mute ? " (muted)" : ""); } } /* * Called when the requested information on the server is ready. This is * used to find the default PulseAudio sink. */ static void server_info_callback(pa_context *c, const pa_server_info *i, void *userdata) { printf("default sink name = %s\n", i->default_sink_name); pa_context_get_sink_info_by_name(c, i->default_sink_name, sink_info_callback, userdata); } }; int main(int argc, char *argv[]) { PulseAudio pa = PulseAudio(); if (!pa.initialize()) return 0; int ret = pa.run(); return ret; }
Dez1J/dwmblocks
plugin/mpdstatus.c
<reponame>Dez1J/dwmblocks // gcc -o mpdstatus mpdstatus.c -lmpdclient #include <mpd/client.h> #include <mpd/status.h> #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> void cut(char *sub, const char *, int n1, char *es); char *smprintf(char *fmt, ...) { va_list fmtargs; char *ret; int len; va_start(fmtargs, fmt); len = vsnprintf(NULL, 0, fmt, fmtargs); va_end(fmtargs); ret = malloc(++len); if (ret == NULL) { perror("malloc"); exit(1); } va_start(fmtargs, fmt); vsnprintf(ret, len, fmt, fmtargs); va_end(fmtargs); return ret; } /* simple function to retrieve mpd status */ char *getmpdstat() { struct mpd_song *song = NULL; char *mpdstat = NULL, *pos_pl = NULL, *play_flag = NULL; char *retstr = NULL; int elapsed = 0, total = 0, remain = 0, br = 0; struct mpd_connection *conn; if (!(conn = mpd_connection_new("localhost", 6600, 30000)) || mpd_connection_get_error(conn)) { return smprintf(" Not connected! \n"); } mpd_command_list_begin(conn, true); mpd_send_status(conn); mpd_send_current_song(conn); mpd_command_list_end(conn); struct mpd_status *theStatus = mpd_recv_status(conn); if ((theStatus) && (mpd_status_get_state(theStatus) == MPD_STATE_PLAY || mpd_status_get_state(theStatus) == MPD_STATE_PAUSE)) { mpd_response_next(conn); song = mpd_recv_song(conn); int len = strlen(mpd_song_get_tag(song, MPD_TAG_TITLE, 0)); char title[31] = {""}; if (len > 30) { char end[3] = {"..."}; strncpy(title, mpd_song_get_tag(song, MPD_TAG_TITLE, 0), 27); strncpy(title + 27, end, 3); title[30] = '\0'; } else { strcpy(title, mpd_song_get_tag(song, MPD_TAG_TITLE, 0)); } char artist[16]; cut(artist, mpd_song_get_tag(song, MPD_TAG_ARTIST, 0), 15, "..."); char date[5] = {""}; strncpy(date, mpd_song_get_tag(song, MPD_TAG_DATE, 0) ?: "none", 4); date[4] = '\0'; pos_pl = smprintf("%5d/%d", mpd_status_get_song_pos(theStatus) + 1, mpd_status_get_queue_length(theStatus)); play_flag = smprintf("%s%s%s", mpd_status_get_random(theStatus) ? "z" : "-", mpd_status_get_repeat(theStatus) ? "r" : "-", mpd_status_get_single(theStatus) ? "s" : "-"); mpdstat = mpd_status_get_state(theStatus) == MPD_STATE_PLAY ? "P" : "Z"; //elapsed = mpd_status_get_elapsed_time(theStatus); //total = mpd_status_get_total_time(theStatus); //remain = total - elapsed; br = mpd_status_get_kbit_rate(theStatus); mpd_song_free(song); retstr = smprintf(" %s - %s ๏Žต [%s%s %s] %dk @%s \n", title, artist, mpdstat, play_flag, pos_pl, br, date); } else retstr = smprintf(" [S] \n"); mpd_response_finish(conn); mpd_connection_free(conn); return retstr; } void cut(char *sub, const char *ms, int n1, char *es) { int len1 = strlen(ms); int len2 = strlen(es); if (len1 > n1) { strncpy(sub, ms, n1 - len2); strncpy(sub + n1 - len2, es, len2); sub[n1] = '\0'; } else { strcpy(sub, ms); } }
Dez1J/dwmblocks
plugin/load_avg.c
<filename>plugin/load_avg.c #include <stdarg.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> int pscanf(const char *path, const char *fmt, ...) { FILE *fp; va_list ap; int n; if (!(fp = fopen(path, "r"))) { // warn("fopen '%s':", path); return -1; } va_start(ap, fmt); n = vfscanf(fp, fmt, ap); va_end(ap); fclose(fp); return (n == EOF) ? -1 : n; } // const char *cpu_perc(void) { int cpu_perc() { static long double a[7]; long double b[7], sum; // memcpy(b, a, sizeof(b)); /* cpu user nice system idle iowait irq softirq */ if (a[0] == 0) { if (pscanf("/proc/stat", "%*s %Lf %Lf %Lf %Lf %Lf %Lf %Lf", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6]) != 7) { return 1; } } // printf("\n"); // sleep(1); // while (1) { if (pscanf("/proc/stat", "%*s %Lf %Lf %Lf %Lf %Lf %Lf %Lf", &b[0], &b[1], &b[2], &b[3], &b[4], &b[5], &b[6]) != 7) { return 3; } if (b[0] == 0) { return 4; } sum = (b[0] + b[1] + b[2] + b[3] + b[4] + b[5] + b[6]) - (a[0] + a[1] + a[2] + a[3] + a[4] + a[5] + a[6]); if (sum == 0) { return 5; } printf("%d%\n", (int)(100 * ((b[0] + b[1] + b[2] + b[5] + b[6]) - (a[0] + a[1] + a[2] + a[5] + a[6])) / sum)); memcpy(a, b, sizeof(b)); // sleep(1); // } return 0; } int cpu_load() { double avgs[3]; if (getloadavg(avgs, 3) < 0) { return -1; } printf("%.2f %.2f %.2f", avgs[0], avgs[1], avgs[2]); return 0; } int main() { while (1) { system("clear"); cpu_load(); printf("\t"); cpu_perc(); // printf("\n"); sleep(1); } return 0; }
Dez1J/dwmblocks
blocks.h
<reponame>Dez1J/dwmblocks //Modify this file to change what commands output to your statusbar, and recompile using the make command. static const Block blocks[] = { /*Icon*/ /*Command*/ /*Update Interval*/ /*Update Signal*/ // {"", "/home/jiang/Suckless_J/mpdstatus/mpdstatus", 1, 12, NULL}, {"", NULL, 0, 12, getmpdstat}, {"", NULL, 1, 0, show_nettraf}, // {"", "/home/jiang/.dwmbar/statusbar/scrobbler", 0, 13, NULL}, // {"", "/home/jiang/.dwmbar/statusbar/nettraf", 1, 0, NULL}, // {"", "/home/jiang/.scripts/pacupdate", 28800, 0, NULL}, // {"", "/home/jiang/.dwmbar/statusbar/release", 0, 0, NULL}, {"", "/home/jiang/.dwmbar/statusbar/volume", 0, 10, NULL}, {"", "xbacklight |awk -F . '{printf \" ๏†… %s% \\n\",$1}'", 0, 11, NULL}, {"", "/home/jiang/.dwmbar/statusbar/cpu_usage", 2, 0, NULL}, {"", "/home/jiang/.dwmbar/statusbar/memory", 1, 0, NULL}, {"๏‹‰ ", "sensors | awk '/^temp1:/{print $2}'|sed -n '3p'", 3, 0, NULL}, // {"", "/home/jiang/.dwmbar/statusbar/battery", 5, 0, NULL}, {" ๏‰€ ", NULL, 60, 0, getbattery}, {"", "/home/jiang/.dwmbar/statusbar/clock", 60, 0, NULL}, // {"", "/home/jiang/.dwmbar/statusbar/BTBattery", 300, 13, NULL}, // {"", "/home/jiang/.dwmbar/statusbar/weather", 18000, 5, NULL}, // {"", "/home/jiang/.dwmbar/statusbar/mpdstatus", 1, 12, NULL}, // {"", "/home/jiang/.dwmbar/statusbar/torrent", 20, 15, NULL}, // {"", "cat /tmp/lrc.tmp", 1, 0, NULL}, }; //sets delimeter between status commands. NULL character ('\0') means no delimeter. static char delim = ' ';
Dez1J/dwmblocks
plugin/nettraf.c
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <stdarg.h> #include <string.h> static unsigned long long int rec, sent; //char * //smprintf(char *fmt, ...) //{ // va_list fmtargs; // char *ret; // int len; // // va_start(fmtargs, fmt); // len = vsnprintf(NULL, 0, fmt, fmtargs); // va_end(fmtargs); // // ret = malloc(++len); // if (ret == NULL) { // perror("malloc"); // exit(1); // } // // va_start(fmtargs, fmt); // vsnprintf(ret, len, fmt, fmtargs); // va_end(fmtargs); // // return ret; //} int parse_netdev(unsigned long long int *receivedabs, unsigned long long int *sentabs) { char buf[255]; char *datastart; static int bufsize; int rval; FILE *devfd; unsigned long long int receivedacc, sentacc; bufsize = 255; devfd = fopen("/proc/net/dev", "r"); rval = 1; // Ignore the first two lines of the file fgets(buf, bufsize, devfd); fgets(buf, bufsize, devfd); while (fgets(buf, bufsize, devfd)) { if ((datastart = strstr(buf, "lo:")) == NULL) { datastart = strstr(buf, ":"); // With thanks to the conky project at http://conky.sourceforge.net/ sscanf(datastart + 1, "%llu %*d %*d %*d %*d %*d %*d %*d %llu",\ &receivedacc, &sentacc); *receivedabs += receivedacc; *sentabs += sentacc; rval = 0; } } fclose(devfd); return rval; } void calculate_speed(char *speedstr, unsigned long long int newval, unsigned long long int oldval) { double speed; speed = (newval - oldval) / 1024.0; if (speed > 1024.0) { speed /= 1024.0; sprintf(speedstr, "%6.3f MB", speed); } else { sprintf(speedstr, "%6.2f KB", speed); } } char * get_netusage(unsigned long long int *rec, unsigned long long int *sent) { unsigned long long int newrec, newsent; newrec = newsent = 0; char downspeedstr[15], upspeedstr[15]; static char retstr[42]; int retval; retval = parse_netdev(&newrec, &newsent); if (retval) { fprintf(stdout, "Error when parsing /proc/net/dev file.\n"); exit(1); } calculate_speed(downspeedstr, newrec, *rec); calculate_speed(upspeedstr, newsent, *sent); //โ†“โ†‘ ๏ธ๏ท sprintf(retstr, " ๏ฃ%s ๏ข%s \n", downspeedstr, upspeedstr); *rec = newrec; *sent = newsent; return retstr; } char * show_nettraf(){ // static unsigned long long int rec, sent; // char *netstats; // netstats = get_netusage(&rec, &sent); // printf("%s\n",netstats); return get_netusage(&rec, &sent); } //int //main(void) //{ // char *status; // char *netstats; // static unsigned long long int rec, sent; // // parse_netdev(&rec, &sent); // for (;;) { // netstats = get_netusage(&rec, &sent); //// status = smprintf("[N: %s]", netstats); // printf("%s\n",netstats); //// free(status); // sleep(1); // } // // return 0; //}
keichi/tiny-lldpd
src/lldp.h
<filename>src/lldp.h #ifndef __LLDP_H__ #define __LLDP_H__ enum TLVType { TLV_END = 0, TLV_CHASSIS_ID, TLV_PORT_ID, TLV_TTL, TLV_PORT_DESCRIPTION, TLV_SYSTEM_NAME, TLV_SYSTEM_DESCRIPTION, TLV_SYSTEM_CAPABILITIES, TLV_MANAGEMENT_ADDRESS, TLV_ORGANIZATION_SPECIFIC = 127 }; enum ChassisIDSubType { CHASSIS_ID_CHASSIS_COMPONENT = 1, CHASSIS_ID_INTERFACE_ALIAS, CHASSIS_ID_PORT_COMPONENT, CHASSIS_ID_MAC_ADDRESS, CHASSIS_ID_NETWORK_ADDRESS, CHASSIS_ID_INTERFACE_NAME, CHASSIS_ID_LOCALLY_ASSIGNED }; enum PortIDSubType { PORT_ID_INTERFACE_ALIAS = 1, PORT_ID_PORT_COMPONENT, PORT_ID_MAC_ADDRESS, PORT_ID_NETWORK_ADDRESS, PORT_ID_INTERFACE_NAME, PORT_ID_AGENT_CIRCUIT_ID, PORT_ID_LOCALLY_ASSIGNED }; int write_lldp_tlv_header(void *buffer, int type, int length); int write_lldp_tlv(void *buffer, int type, int length, const void *value); int write_lldp_chassis_id_tlv(void *buffer, int chassis_id_subtype, int length, const void *chassis_id); int write_lldp_port_id_tlv(void *buffer, int port_id_subtype, int length, const void *port_id); int write_lldp_ttl_tlv(void *buffer, int ttl); int write_lldp_end_tlv(void *buffer); #endif
keichi/tiny-lldpd
src/main.c
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <syslog.h> #include <unistd.h> #include <signal.h> #include <sys/socket.h> #include <netinet/in.h> #include <netpacket/packet.h> #include <net/ethernet.h> #include "lldp.h" #include "ether_utils.h" #include "tlv_writer.h" #define PID_FILE_PATH "/var/run/tlldpd.pid" #define SENDBUF_SIZE (1024) #define ETH_P_LLDP (0x88cc) int check_duplicate_run() { FILE *pid_file; if ((pid_file = fopen(PID_FILE_PATH, "r"))) { int pid; if (fscanf(pid_file, "%d", &pid) == 1) { if (kill(pid, 0) >= 0) { return 1; } } fclose(pid_file); } return 0; } int daemonize() { // If already a daemon if (getppid() == 1) { return 0; } if (daemon(0, 0) < 0) { return -1; } openlog("tlldpd", LOG_PID, LOG_DAEMON); syslog(LOG_INFO, "Tiny LLDP daemon started.\n"); pid_t pid = getpid(); FILE *pid_file; if ((pid_file = fopen(PID_FILE_PATH, "w"))) { fprintf(pid_file, "%d\n", pid); fclose(pid_file); } else { syslog(LOG_ERR, "Failed to write pid file.\n"); } return 0; } void send_lldp_packet(const char *if_name, int sock) { // Group MAC address for neareset bridge const char dst_address[ETH_ALEN] = {0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e}; char src_address[ETH_ALEN]; int if_ip_address; int if_index; if (get_if_mac_addres(if_name, sock, src_address) < 0) { syslog(LOG_ERR, "Failed to get interface MAC address\n"); } if (get_if_ip_addres(if_name, sock, &if_ip_address) < 0) { syslog(LOG_ERR, "Failed to get interface IP address\n"); } if (get_if_index(if_name, sock, &if_index) < 0) { syslog(LOG_ERR, "Failed to get interface index\n"); } // Construct Ethernet frame int frame_size = 0; char sendbuf[SENDBUF_SIZE]; memset(sendbuf, 0, SENDBUF_SIZE); // Construct Ethernet header frame_size += write_ethernet_header(sendbuf, src_address, dst_address, ETH_P_LLDP); // Construct Ethernet body // Required LLDP TLVs frame_size += write_lldp_chassis_id_tlv(sendbuf + frame_size, CHASSIS_ID_MAC_ADDRESS, ETH_ALEN, src_address); frame_size += write_lldp_port_id_tlv(sendbuf + frame_size, PORT_ID_MAC_ADDRESS, ETH_ALEN, src_address); frame_size += write_lldp_ttl_tlv(sendbuf + frame_size, LLDP_DEFAULT_TTL); // Optionsl LLDP TLVs frame_size += write_port_description_tlv(sendbuf + frame_size, if_name); frame_size += write_system_name_tlv(sendbuf + frame_size); frame_size += write_system_description_tlv(sendbuf + frame_size); frame_size += write_management_address_tlv(sendbuf + frame_size, if_ip_address, if_index); frame_size += write_lldp_end_tlv(sendbuf + frame_size); // Send out Ethernet frame struct sockaddr_ll socket_address; socket_address.sll_ifindex = if_index; socket_address.sll_halen = ETH_ALEN; memcpy(socket_address.sll_addr, dst_address, ETH_ALEN); if (sendto(sock, sendbuf, frame_size, 0, (struct sockaddr*)&socket_address, sizeof(struct sockaddr_ll)) < 0) { syslog(LOG_ERR, "LLDP packet send failed\n"); } } int main(int argc, char *argv[]) { // flags int duplicate_run_allowed = 0; int lldp_interval = 1; int do_daemonize = 1; // Comannd line options parsing int result; while((result = getopt(argc, argv, "Ddi:")) != -1) { switch(result) { case 'd': duplicate_run_allowed = 1; break; case 'i': lldp_interval = atoi(optarg); break; case 'D': do_daemonize = 0; break; } } // Check if root if (getuid() != 0) { printf("You must be root to run this daemon\n"); exit(EXIT_FAILURE); } // Check if a tiny-lldpd is running if (!duplicate_run_allowed && check_duplicate_run()) { printf("tiny-lldpd daemon is already running\n"); exit(EXIT_FAILURE); } // Daemoniza myself printf("Starting tiny-lldpd...\n"); if (do_daemonize && daemonize() < 0) { printf("Failed to daemonize\n"); exit(EXIT_FAILURE); } // Get socket int sock = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (sock < 0) { syslog(LOG_ERR, "Socket initialization error\n"); exit(EXIT_FAILURE); } char if_names[16][16]; int if_count; // Get all interface names get_all_ifs(sock, if_names, &if_count); while (1) { int i; // For each interfaces for (i = 0; i < if_count; i ++) { // Send out LLDP packet send_lldp_packet(if_names[i], sock); } sleep(lldp_interval); } return 0; }
keichi/tiny-lldpd
src/tlv_writer.c
<gh_stars>1-10 #include <stdio.h> #include <string.h> #include <unistd.h> #include <sys/utsname.h> #include <net/ethernet.h> #include <netinet/in.h> #include <netpacket/packet.h> #include "lldp.h" #include "tlv_writer.h" int write_ethernet_header(void *buffer, const char *src_address, const char *dst_address, int protocol_type) { struct ether_header *eh = (struct ether_header *)buffer; memcpy(eh->ether_shost, src_address, ETH_ALEN); memcpy(eh->ether_dhost, dst_address, ETH_ALEN); eh->ether_type = htons(protocol_type); return sizeof(struct ether_header); } int write_system_name_tlv(void *buffer) { char hostname[HOST_NAME_LENGTH]; gethostname(hostname, HOST_NAME_LENGTH); return write_lldp_tlv(buffer, TLV_SYSTEM_NAME, strlen(hostname), hostname); } int write_system_description_tlv(void *buffer) { struct utsname info; uname(&info); char tmp[255]; sprintf(tmp, "%s %s %s %s %s", info.sysname, info.nodename, info.release, info.version, info.machine); return write_lldp_tlv(buffer, TLV_SYSTEM_DESCRIPTION, strlen(tmp), tmp); } int write_management_address_tlv(void *buffer, int if_ip_address, int if_index) { // Awful code. Must be fixed. char tmp[255]; tmp[0] = 5; tmp[1] = 1; *((int *)(tmp + 2)) = if_ip_address; tmp[6] = 2; *((int *)(tmp + 7)) = htonl(if_index); tmp[11] = 0; return write_lldp_tlv(buffer, TLV_MANAGEMENT_ADDRESS, 12, tmp); } int write_port_description_tlv(void *buffer, const char *if_name) { return write_lldp_tlv(buffer, TLV_PORT_DESCRIPTION, strlen(if_name), if_name); }
keichi/tiny-lldpd
src/ether_utils.c
#include <stdint.h> #include <string.h> #include <unistd.h> #include <sys/ioctl.h> #include <net/if.h> #include <net/ethernet.h> #include <netinet/in.h> #include "ether_utils.h" int get_if_index(const char *if_name, int sock, int *index) { struct ifreq ifr; memset(&ifr, 0, sizeof(struct ifreq)); strcpy(ifr.ifr_name, if_name); if (ioctl(sock, SIOCGIFINDEX, &ifr) < 0) { return -1; } *index = ifr.ifr_ifindex; return 0; } int get_if_mac_addres(const char *if_name, int sock, char *mac_address) { struct ifreq ifr; memset(&ifr, 0, sizeof(struct ifreq)); strcpy(ifr.ifr_name, if_name); if (ioctl(sock, SIOCGIFHWADDR, &ifr) < 0) { return -1; } memcpy(mac_address, ifr.ifr_hwaddr.sa_data, ETH_ALEN); return 0; } int get_if_ip_addres(const char *if_name, int sock, int *ip_address) { struct ifreq ifr; memset(&ifr, 0, sizeof(struct ifreq)); strcpy(ifr.ifr_name, if_name); if (ioctl(sock, SIOCGIFADDR, &ifr) < 0) { return -1; } struct sockaddr_in *addr_in = (struct sockaddr_in *)&ifr.ifr_addr; *ip_address = addr_in->sin_addr.s_addr; return 0; } int get_all_ifs(int sock, char (*if_names)[16], int *if_count) { struct ifconf conf; struct ifreq req[16]; conf.ifc_len = sizeof(req); conf.ifc_buf = (__caddr_t)req; if (ioctl(sock, SIOCGIFCONF, &conf)) { return -1; } int i; int count = 0; for (i = 0; i < conf.ifc_len / sizeof(struct ifreq); i++) { if (ioctl(sock, SIOCGIFFLAGS, &req[i]) < 0) { continue; } uint16_t flags = req[i].ifr_flags; // If interface is up and not a loopback device if (!(flags & IFF_LOOPBACK) && (flags & IFF_UP)) { strcpy(if_names[count++], req[i].ifr_name); } } *if_count = count; return 0; }
keichi/tiny-lldpd
src/tlv_writer.h
#ifndef __TLV_WRITER_H__ #define __TLV_WRITER_H__ #define HOST_NAME_LENGTH (255) #define LLDP_DEFAULT_TTL (120) int write_ethernet_header(void *buffer, const char *src_address, const char *dst_address, int protocol_type); int write_system_name_tlv(void *buffer); int write_system_description_tlv(void *buffer); int write_management_address_tlv(void *buffer, int if_ip_address, int if_index); int write_port_description_tlv(void *buffer, const char *if_name); #endif
keichi/tiny-lldpd
src/lldp.c
<filename>src/lldp.c<gh_stars>1-10 #include <stdint.h> #include <string.h> #include <netinet/in.h> #include "lldp.h" int write_lldp_tlv_header(void *buffer, int type, int length) { *((uint16_t *)buffer) = htons((type & 0x7f) << 9 | (length & 0x1ff)); return 2; } int write_lldp_tlv(void *buffer, int type, int length, const void *value) { int size = 0; size += write_lldp_tlv_header(buffer, type, length); memcpy(buffer + size, value, length); size += length; return size; } int write_lldp_chassis_id_tlv(void *buffer, int chassis_id_subtype, int length, const void *chassis_id) { int size = 0; size += write_lldp_tlv_header(buffer, TLV_CHASSIS_ID, length + 1); *((uint8_t *)buffer + size) = (uint8_t)chassis_id_subtype; size++; memcpy(buffer + size, chassis_id, length); size += length; return size; } int write_lldp_port_id_tlv(void *buffer, int port_id_subtype, int length, const void *port_id) { int size = 0; size += write_lldp_tlv_header(buffer, TLV_PORT_ID, length + 1); *((uint8_t *)buffer + size) = (uint8_t)port_id_subtype; size++; memcpy(buffer + size, port_id, length); size += length; return size; } int write_lldp_ttl_tlv(void *buffer, int ttl) { int size = 0; size += write_lldp_tlv_header(buffer, TLV_TTL, 2); *((uint16_t *)(buffer + size)) = htons((uint16_t)120); size += 2; return size; } int write_lldp_end_tlv(void *buffer) { int size = 0; size += write_lldp_tlv_header(buffer, TLV_END, 0); return size; }
keichi/tiny-lldpd
src/ether_utils.h
#ifndef __ETHER_UTILS_H__ #define __ETHER_UTILS_H__ #include <stdint.h> int get_if_index(const char *if_name, int sock, int *index); int get_if_mac_addres(const char *if_name, int sock, char *mac_address); int get_if_ip_addres(const char *if_name, int sock, int *ip_address); int get_all_ifs(int sock, char (*if_names)[16], int *if_count); #endif
baifendian/eyeofgod_app
Thehandofgod/Thehandofgod/controllers/DetailViewController.h
// // DetailViewController.h // Thehandofgod // // Created by linde on 16/7/8. // Copyright ยฉ 2016ๅนด linde. All rights reserved. // #import "BaseViewController.h" @interface DetailViewController : BaseViewController @end
baifendian/eyeofgod_app
Thehandofgod/Thehandofgod/controllers/SettingViewController.h
// // SettingViewController.h // Thehandofgod // // Created by linde on 16/7/8. // Copyright ยฉ 2016ๅนด linde. All rights reserved. // #import "BaseViewController.h" @interface SettingViewController : BaseViewController @end
baifendian/eyeofgod_app
Thehandofgod/Thehandofgod/controllers/MainViewController.h
<filename>Thehandofgod/Thehandofgod/controllers/MainViewController.h // // MainViewController.h // Thehandofgod // // Created by linde on 16/7/7. // Copyright ยฉ 2016ๅนด linde. All rights reserved. // #import "BaseViewController.h" @interface MainViewController : BaseViewController @end
baifendian/eyeofgod_app
Thehandofgod/Thehandofgod/BaseViewController.h
<filename>Thehandofgod/Thehandofgod/BaseViewController.h // // ViewController.h // Thehandofgod // // Created by linde on 16/7/7. // Copyright ยฉ 2016ๅนด linde. All rights reserved. // #import <UIKit/UIKit.h> @interface BaseViewController : UIViewController @property(strong,nonatomic) NSString * baseUrl; @property (strong,nonatomic) NSString * path; -(void)loadData; @end
baifendian/eyeofgod_app
Thehandofgod/net/BFDMarsURLConnection.h
<filename>Thehandofgod/net/BFDMarsURLConnection.h // // BFDMarsURLConnection.h // mars // // Created by linde on 16/6/14. // Copyright ยฉ 2016ๅนด linde. All rights reserved. // #import <Foundation/Foundation.h> @interface BFDMarsURLConnection : NSURLConnection<NSURLConnectionDelegate> +(void)BFDURL_POSTRequestWithUrl:(NSString *)urlStr Params:(NSData *)params successBlock:(void(^)(NSString *json))successBlock failedBlock:(void(^)(NSError *error))failedBlock; +(void)BFDURL_GETRequestWithUrl:(NSString *)urlStr Params:(NSString *)params successBlock:(void(^)(NSDictionary *json))successBlock failedBlock:(void(^)(NSError *error))failedBlock; @end
baifendian/eyeofgod_app
Thehandofgod/Thehandofgod/GtSdkLib/GeTuiSdk.h
<reponame>baifendian/eyeofgod_app<gh_stars>0 // // GeTuiSdk.h // GeTuiSdk // // Created by gexin on 15-5-5. // Copyright (c) 2015ๅนด Gexin Interactive (Beijing) Network Technology Co.,LTD. All rights reserved. // #import <Foundation/Foundation.h> typedef enum { SdkStatusStarting, // ๆญฃๅœจๅฏๅŠจ SdkStatusStarted, // ๅฏๅŠจ SdkStatusStoped // ๅœๆญข } SdkStatus; @protocol GeTuiSdkDelegate; @interface GeTuiSdk : NSObject #pragma mark - ๅŸบๆœฌๅŠŸ่ƒฝ /** * ๅฏๅŠจไธชๆŽจSDK * * @param appid ่ฎพ็ฝฎapp็š„ไธชๆŽจappId๏ผŒๆญคappIdไปŽไธชๆŽจ็ฝ‘็ซ™่Žทๅ– * @param appKey ่ฎพ็ฝฎapp็š„ไธชๆŽจappKey๏ผŒๆญคappKeyไปŽไธชๆŽจ็ฝ‘็ซ™่Žทๅ– * @param appSecret ่ฎพ็ฝฎapp็š„ไธชๆŽจappSecret๏ผŒๆญคappSecretไปŽไธชๆŽจ็ฝ‘็ซ™่Žทๅ– * @param delegate ๅ›ž่ฐƒไปฃ็†delegate */ + (void)startSdkWithAppId:(NSString *)appid appKey:(NSString *)appKey appSecret:(NSString *)appSecret delegate:(id<GeTuiSdkDelegate>)delegate; /** * ๅœๆญขSDK๏ผŒๅนถไธ”้‡Šๆ”พ่ต„ๆบ๏ผˆๅทฒๅผƒ็”จ๏ผ‰ */ + (void)stopSdk __deprecated; /** * ้”€ๆฏSDK๏ผŒๅนถไธ”้‡Šๆ”พ่ต„ๆบ */ + (void)destroy; /** * ๆขๅคSDK่ฟ่กŒ,IOS7 ไปฅๅŽๆ”ฏๆŒBackground Fetchๆ–นๅผ๏ผŒๅŽๅฐๅฎšๆœŸๆ›ดๆ–ฐๆ•ฐๆฎ,่ฏฅๆŽฅๅฃ้œ€่ฆๅœจFetch่ตทๆฅๅŽ่ขซ่ฐƒ็”จ๏ผŒไฟ่ฏSDK ๆ•ฐๆฎ่Žทๅ–ใ€‚ */ + (void)resume; #pragma mark - /** * ่Žทๅ–SDK็‰ˆๆœฌๅท * * @return ็‰ˆๆœฌๅ€ผ */ + (NSString *)version; /** * ่Žทๅ–SDK็š„Cid * * @return Cidๅ€ผ */ + (NSString *)clientId; /** * ่Žทๅ–SDK่ฟ่กŒ็Šถๆ€ * * @return ่ฟ่กŒ็Šถๆ€ */ + (SdkStatus)status; #pragma mark - /** * ๆ˜ฏๅฆๅ…่ฎธSDK ๅŽๅฐ่ฟ่กŒ๏ผˆ้ป˜่ฎคๅ€ผ๏ผšNO๏ผ‰ * ๅค‡ๆณจ๏ผšๅฏไปฅๆœชๅฏๅŠจSDKๅฐฑ่ฐƒ็”จ่ฏฅๆ–นๆณ• * ่ญฆๅ‘Š๏ผš่ฏฅๅŠŸ่ƒฝไผšๅ’Œ้Ÿณไนๆ’ญๆ”พๅ†ฒ็ช๏ผŒไฝฟ็”จๆ—ถ่ฏทๆณจๆ„ * * @param isEnable ๆ”ฏๆŒๅฝ“APP่ฟ›ๅ…ฅๅŽๅฐๅŽ๏ผŒไธชๆŽจๆ˜ฏๅฆ่ฟ่กŒ,YES.ๅ…่ฎธ */ + (void)runBackgroundEnable:(BOOL)isEnable; /** * ๅœฐ็†ๅ›ดๆ ๅŠŸ่ƒฝ๏ผŒ่ฎพ็ฝฎๅœฐ็†ๅ›ดๆ ๆ˜ฏๅฆ่ฟ่กŒ * ๅค‡ๆณจ๏ผšSDKๅฏไปฅๆœชๅฏๅŠจๅฐฑ่ฐƒ็”จ่ฏฅๆ–นๆณ• * * @param isEnable ่ฎพ็ฝฎๅœฐ็†ๅ›ดๆ ๅŠŸ่ƒฝๆ˜ฏๅฆ่ฟ่กŒ๏ผˆ้ป˜่ฎคๅ€ผ๏ผšNO๏ผ‰ * @param isVerify ่ฎพ็ฝฎๆ˜ฏๅฆSDKไธปๅŠจๅผนๅ‡บ็”จๆˆทๅฎšไฝ่ฏทๆฑ‚๏ผˆ้ป˜่ฎคๅ€ผ๏ผšNO๏ผ‰ */ + (void)lbsLocationEnable:(BOOL)isEnable andUserVerify:(BOOL)isVerify; /** * ่ฎพ็ฝฎๅค„็†ๆ˜พ็คบ็š„AlertViewๆ˜ฏๅฆ้šๅฑๅน•ๆ—‹่ฝฌ * ๅค‡ๆณจ๏ผšSDKๅฏไปฅๆœชๅฏๅŠจๅฐฑ่ฐƒ็”จ่ฏฅๆ–นๆณ• * * @param orientations ๆ”ฏๆŒ็š„ๅฑๅน•ๆ–นๅ‘ๅˆ—่กจ๏ผŒๅ…ทไฝ“ๅ€ผ่ฏทๅ‚็…งUIInterfaceOrientation๏ผˆFrom iOS SDK๏ผ‰ */ + (void)setAllowedRotateUiOrientations:(NSArray *)orientations; /** * ่ฎพ็ฝฎCrashๆ•ๆ‰ๅฏ็”จ๏ผˆ้ป˜่ฎคๅ€ผ๏ผšYES๏ผ‰ * ๅค‡ๆณจ๏ผš่ฏฅๆ–นๆณ•้œ€่ฆๅœจๆœชๅฏๅŠจSDKไน‹ๅ‰่ฐƒ็”จ * * @param isEnable ๆ˜ฏๅฆๅฏๅŠจCrashๆ•่Žท */ + (void)setCrashCatchEnable:(BOOL)isEnable; #pragma mark - /** * ๅ‘ไธชๆŽจๆœๅŠกๅ™จๆณจๅ†ŒDeviceToken * ๅค‡ๆณจ๏ผšๅฏไปฅๆœชๅฏๅŠจSDKๅฐฑ่ฐƒ็”จ่ฏฅๆ–นๆณ• * * @param deviceToken ๆŽจ้€ๆ—ถไฝฟ็”จ็š„deviceToken * */ + (void)registerDeviceToken:(NSString *)deviceToken; /** * ็ป‘ๅฎšๅˆซๅๅŠŸ่ƒฝ:ๅŽๅฐๅฏไปฅๆ นๆฎๅˆซๅ่ฟ›่กŒๆŽจ้€ * * @param alias ๅˆซๅๅญ—็ฌฆไธฒ */ + (void)bindAlias:(NSString *)alias; /** * ๅ–ๆถˆ็ป‘ๅฎšๅˆซๅๅŠŸ่ƒฝ * * @param alias ๅˆซๅๅญ—็ฌฆไธฒ */ + (void)unbindAlias:(NSString *)alias; /** * ็ป™็”จๆˆทๆ‰“ๆ ‡็ญพย , ๅŽๅฐๅฏไปฅๆ นๆฎๆ ‡็ญพ่ฟ›่กŒๆŽจ้€ * * @param tags ๅˆซๅๆ•ฐ็ป„ * * @return ๆไบค็ป“ๆžœ๏ผŒYES่กจ็คบๅฐ่ฏ•ๆไบคๆˆๅŠŸ๏ผŒNO่กจ็คบๅฐ่ฏ•ๆไบคๅคฑ่ดฅ */ + (BOOL)setTags:(NSArray *)tags; /** * ่ฎพ็ฝฎๅ…ณ้—ญๆŽจ้€ๆจกๅผ๏ผˆ้ป˜่ฎคๅ€ผ๏ผšNO๏ผ‰ * * @param isValue ๆถˆๆฏๆŽจ้€ๅผ€ๅ‘๏ผŒYES.ๅ…ณ้—ญๆถˆๆฏๆŽจ้€ NO.ๅผ€ๅฏๆถˆๆฏๆŽจ้€ * * SDK-1.2.1+ * */ + (void)setPushModeForOff:(BOOL)isValue; /** * ๅŒๆญฅ่ง’ๆ ‡ๅ€ผๅˆฐไธชๆŽจๆœๅŠกๅ™จ * ่ฏฅๆ–นๆณ•ๅชๆ˜ฏๅŒๆญฅ่ง’ๆ ‡ๅ€ผๅˆฐไธชๆŽจๆœๅŠกๅ™จ๏ผŒๆœฌๅœฐไป้กป่ฐƒ็”จsetApplicationIconBadgeNumberๅ‡ฝๆ•ฐ * * SDK-1.4.0+ * * @param value ่ง’ๆ ‡ๆ•ฐๅ€ผ */ + (void)setBadge:(NSUInteger)value; /** * ๅคไฝ่ง’ๆ ‡๏ผŒ็ญ‰ๅŒไบŽ"setBadge:0" * * SDK-1.4.0+ * */ + (void)resetBadge; #pragma mark - /** * SDKๅ‘้€ไธŠ่กŒๆถˆๆฏ็ป“ๆžœ * * @param body ้œ€่ฆๅ‘้€็š„ๆถˆๆฏๆ•ฐๆฎ * @param error ๅฆ‚ๆžœๅ‘้€ๆˆๅŠŸ่ฟ”ๅ›žmessageid๏ผŒๅ‘้€ๅคฑ่ดฅ่ฟ”ๅ›žnil * * @return ๆถˆๆฏ็š„msgId */ + (NSString *)sendMessage:(NSData *)body error:(NSError **)error; /** * ไธŠ่กŒ็ฌฌไธ‰ๆ–น่‡ชๅฎšไน‰ๅ›žๆ‰งactionid * * @param actionId ็”จๆˆท่‡ชๅฎšไน‰็š„actionid๏ผŒint็ฑปๅž‹๏ผŒๅ–ๅ€ผ90001-90999ใ€‚ * @param taskId ไธ‹ๅ‘ไปปๅŠก็š„ไปปๅŠกID * @param msgId ไธ‹ๅ‘ไปปๅŠก็š„ๆถˆๆฏID * * @return BOOL๏ผŒYES่กจ็คบๅฐ่ฏ•ๆไบคๆˆๅŠŸ๏ผŒNO่กจ็คบๅฐ่ฏ•ๆไบคๅคฑ่ดฅใ€‚ๆณจ๏ผš่ฏฅ็ป“ๆžœไธไปฃ่กจๆœๅŠกๅ™จๆ”ถๅˆฐ่ฏฅๆกๆ•ฐๆฎ * ่ฏฅๆ–นๆณ•้œ€่ฆๅœจๅ›ž่ฐƒๆ–นๆณ•โ€œGeTuiSdkDidReceivePayload:andTaskId:andMessageId:andOffLine:fromApplication:โ€ไฝฟ็”จ */ + (BOOL)sendFeedbackMessage:(NSInteger)actionId andTaskId:(NSString *)taskId andMsgId:(NSString *)msgId; /** * ๆธ…็ฉบไธ‹ๆ‹‰้€š็Ÿฅๆ ๅ…จ้ƒจ้€š็Ÿฅ,ๅนถๅฐ†่ง’ๆ ‡็ฝฎโ€œ0โ€๏ผŒไธๆ˜พ็คบ่ง’ๆ ‡ */ + (void)clearAllNotificationForNotificationBar; /** * ๆ นๆฎpayloadIdๅ–ๅ›žPayloadๆ•ฐๆฎ๏ผˆๅทฒๅผƒ็”จ๏ผ‰ * * @param payloadId ไธชๆŽจSDK่Žทๅ–ๅˆฐ้€ไผ ๆถˆๆฏๆ—ถ่ฟ”ๅ›ž็š„payloadId * * @return ไธ‹ๅ‘็š„ๆถˆๆฏๆ•ฐๆฎ */ + (NSData *)retrivePayloadById:(NSString *)payloadId __deprecated; @end #pragma mark - SDK Delegate @protocol GeTuiSdkDelegate <NSObject> @optional /** * SDK็™ปๅ…ฅๆˆๅŠŸ่ฟ”ๅ›žclientId * * @param clientId ๆ ‡่ฏ†็”จๆˆท็š„clientId * ่ฏดๆ˜Ž:ๅฏๅŠจGeTuiSdkๅŽ๏ผŒSDKไผš่‡ชๅŠจๅ‘ไธชๆŽจๆœๅŠกๅ™จๆณจๅ†ŒSDK๏ผŒๅฝ“ๆˆๅŠŸๆณจๅ†Œๆ—ถ๏ผŒSDK้€š็Ÿฅๅบ”็”จๆณจๅ†ŒๆˆๅŠŸใ€‚ * ๆณจๆ„: ๆณจๅ†ŒๆˆๅŠŸไป…่กจ็คบๆŽจ้€้€š้“ๅปบ็ซ‹๏ผŒๅฆ‚ๆžœappid/appkey/appSecret็ญ‰้ชŒ่ฏไธ้€š่ฟ‡๏ผŒไพ็„ถๆ— ๆณ•ๆŽฅๆ”ถๅˆฐๆŽจ้€ๆถˆๆฏ๏ผŒ่ฏท็กฎไฟ้ชŒ่ฏไฟกๆฏๆญฃ็กฎใ€‚ */ - (void)GeTuiSdkDidRegisterClient:(NSString *)clientId; /** * SDK้€š็Ÿฅๆ”ถๅˆฐไธชๆŽจๆŽจ้€็š„้€ไผ ๆถˆๆฏ๏ผˆๅทฒๅผƒ็”จ๏ผ‰ * * @param payloadId ไปฃ่กจๆŽจ้€ๆถˆๆฏ็š„ๅ”ฏไธ€id * @param taskId ๆŽจ้€ๆถˆๆฏ็š„ไปปๅŠกid * @param aMsgId ๆŽจ้€ๆถˆๆฏ็š„messageid * @param offLine ๆ˜ฏๅฆๆ˜ฏ็ฆป็บฟๆถˆๆฏ๏ผŒYES.ๆ˜ฏ็ฆป็บฟๆถˆๆฏ * @param appId ๅบ”็”จ็š„appId * ่ฏดๆ˜Ž: SDKไผšๅฐ†ๆŽจ้€ๆถˆๆฏๅœจๆœฌๅœฐๆ•ฐๆฎๅบ“ไธญไฟ็•™5ๅคฉ๏ผŒ่ฏทๅŠๆ—ถๅ–ๅ‡บ๏ผˆSee retrivePayloadById๏ผš๏ผ‰๏ผŒๅ–ๅ‡บๅŽๆถˆๆฏๅฐ†่ขซๅˆ ้™คใ€‚ */ - (void)GeTuiSdkDidReceivePayload:(NSString *)payloadId andTaskId:(NSString *)taskId andMessageId:(NSString *)aMsgId andOffLine:(BOOL)offLine fromApplication:(NSString *)appId __deprecated; /** * SDK้€š็Ÿฅๆ”ถๅˆฐไธชๆŽจๆŽจ้€็š„้€ไผ ๆถˆๆฏ * * @param payloadData ๆŽจ้€ๆถˆๆฏๅ†…ๅฎน * @param taskId ๆŽจ้€ๆถˆๆฏ็š„ไปปๅŠกid * @param msgId ๆŽจ้€ๆถˆๆฏ็š„messageid * @param offLine ๆ˜ฏๅฆๆ˜ฏ็ฆป็บฟๆถˆๆฏ๏ผŒYES.ๆ˜ฏ็ฆป็บฟๆถˆๆฏ * @param appId ๅบ”็”จ็š„appId */ - (void)GeTuiSdkDidReceivePayloadData:(NSData *)payloadData andTaskId:(NSString *)taskId andMsgId:(NSString *)msgId andOffLine:(BOOL)offLine fromGtAppId:(NSString *)appId; /** * SDK้€š็Ÿฅๅ‘้€ไธŠ่กŒๆถˆๆฏ็ป“ๆžœ๏ผŒๆ”ถๅˆฐsendMessageๆถˆๆฏๅ›ž่ฐƒ * * @param messageId โ€œsendMessage:error:โ€่ฟ”ๅ›ž็š„id * @param result ๆˆๅŠŸ่ฟ”ๅ›ž1, ๅคฑ่ดฅ่ฟ”ๅ›ž0 * ่ฏดๆ˜Ž: ๅฝ“่ฐƒ็”จsendMessage:error:ๆŽฅๅฃๆ—ถ๏ผŒๆถˆๆฏๆŽจ้€ๅˆฐไธชๆŽจๆœๅŠกๅ™จ๏ผŒๆœๅŠกๅ™จ้€š่ฟ‡่ฏฅๆŽฅๅฃ้€š็Ÿฅsdkๅˆฐ่พพ็ป“ๆžœ๏ผŒresultไธบ 1 ่ฏดๆ˜Žๆถˆๆฏๅ‘้€ๆˆๅŠŸ * ๆณจๆ„: ้œ€็ฌฌไธ‰ๆ–นๆœๅŠกๅ™จๆŽฅๅ…ฅไธชๆŽจ,SendMessage ๅˆฐ่พพ็ฌฌไธ‰ๆ–นๆœๅŠกๅ™จๅŽ่ฟ”ๅ›ž 1 */ - (void)GeTuiSdkDidSendMessage:(NSString *)messageId result:(int)result; /** * SDK้‡ๅˆฐ้”™่ฏฏๆถˆๆฏ่ฟ”ๅ›žerror * * @param error SDKๅ†…้ƒจๅ‘็”Ÿ้”™่ฏฏ๏ผŒ้€š็Ÿฅ็ฌฌไธ‰ๆ–น๏ผŒ่ฟ”ๅ›ž้”™่ฏฏ */ - (void)GeTuiSdkDidOccurError:(NSError *)error; /** * SDK่ฟ่กŒ็Šถๆ€้€š็Ÿฅ * * @param aStatus ่ฟ”ๅ›žSDK่ฟ่กŒ็Šถๆ€ */ - (void)GeTuiSDkDidNotifySdkState:(SdkStatus)aStatus; /** * SDK่ฎพ็ฝฎๅ…ณ้—ญๆŽจ้€ๆจกๅผๅ›ž่ฐƒ * * @param isModeOff ๅ…ณ้—ญๆจกๅผ๏ผŒYES.ๆœๅŠกๅ™จๅ…ณ้—ญๆŽจ้€ๅŠŸ่ƒฝ NO.ๆœๅŠกๅ™จๅผ€ๅฏๆŽจ้€ๅŠŸ่ƒฝ * @param error ้”™่ฏฏๅ›ž่ฐƒ๏ผŒ่ฟ”ๅ›ž่ฎพ็ฝฎๆ—ถ็š„้”™่ฏฏไฟกๆฏ */ - (void)GeTuiSdkDidSetPushMode:(BOOL)isModeOff error:(NSError *)error; @end
alex-alex/CinemaCity
CinemaCity/FieldCell.h
<filename>CinemaCity/FieldCell.h // // FieldCell.h // CinemaCity // // Created by <NAME> on 16/04/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> typedef enum { FieldCellTypeUsername, FieldCellTypePassword, FieldCellTypeOther } FieldCellType; @protocol FieldCellDelegate; @interface FieldCell : UITableViewCell <UITextFieldDelegate> { IBOutlet UITextField *_textField; } @property (nonatomic) FieldCellType fieldCellType; @property (nonatomic, weak) id <FieldCellDelegate> delegate; @property (nonatomic, readonly) NSString *value; @end @protocol FieldCellDelegate <NSObject> @optional - (void)textDidChangeInFieldCell:(FieldCell *)cell; - (void)didReturnInFieldCell:(FieldCell *)cell; @end
alex-alex/CinemaCity
CinemaCity/HistoryCell.h
<reponame>alex-alex/CinemaCity<gh_stars>1-10 // // HistoryCell.h // CinemaCity // // Created by <NAME> on 31/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> @interface HistoryCell : UITableViewCell { __weak IBOutlet UILabel *_dateLabel; __weak IBOutlet UILabel *_placeLabel; __weak IBOutlet UILabel *_itemLabel; __weak IBOutlet UILabel *_priceLabel; __weak IBOutlet UILabel *_pointsLabel; } @property (nonatomic, strong) NSDictionary *historyDict; @end
alex-alex/CinemaCity
CinemaCity/MovieDetailPosterCell.h
// // MovieDetailPosterCell.h // CinemaCity // // Created by <NAME> on 27/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> @interface MovieDetailPosterCell : UITableViewCell { __weak IBOutlet UIImageView *_imageView; __weak IBOutlet UIButton *_trailerButton; } @property (nonatomic, strong) NSDictionary *infoDict; - (IBAction)playTrailer; @end
alex-alex/CinemaCity
Extensions/RMDateSelectionViewController/RMDateSelectionViewController.h
// // RMDateSelectionViewController.h // RMDateSelectionViewController // // Created by <NAME> on 26.10.13. // Copyright (c) 2013-2015 <NAME> // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // #import "RMActionController.h" /** * RMDateSelectionViewController is an iOS control for selecting a date using UIDatePicker in a UIActionSheet like fashon. When a RMDateSelectionViewController is shown the user gets the opportunity to select a date using a UIDatePicker. * * RMDateSelectionViewController supports bouncing effects when animating the date selection view controller. In addition, motion effects are supported while showing the date selection view controller. Both effects can be disabled by using the properties called disableBouncingWhenShowing and disableMotionEffects. * * On iOS 8 and later Apple opened up their API for blurring the background of UIViews. RMDateSelectionViewController makes use of this API. The type of the blur effect can be changed by using the blurEffectStyle property. If you want to disable the blur effect you can do so by using the disableBlurEffects property. * * @warning RMDateSelectionViewController is not designed to be reused. Each time you want to display a RMDateSelectionViewController a new instance should be created. If you want to set a specific date before displaying, you can do so by using the datePicker property. */ @interface RMDateSelectionViewController : RMActionController /** * The UIDatePicker instance used by RMDateSelectionViewController. * * Use this property to access the date picker and to set options like minuteInterval and others. */ @property (nonatomic, readonly) UIDatePicker *datePicker; @end
alex-alex/CinemaCity
CinemaCity/MovieDetailViewController.h
// // MovieDetailViewController.h // CinemaCity // // Created by <NAME> on 27/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> @interface MovieDetailViewController : UITableViewController @property (nonatomic, strong) NSString *featureCode; @end
alex-alex/CinemaCity
CinemaCity/Utilities.h
// // Utilities.h // CinemaCity // // Created by <NAME> on 27/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> #define NSNullIfNil(_obj) _obj == nil ? (id)[NSNull null] : _obj #define EmptyStringIfNil(_obj) _obj == nil ? (id)@"" : _obj @interface Utilities : NSObject + (NSString *)stringByStrippingHTML:(NSString *)html; + (NSString *)URLEscapeString:(NSString *)string; + (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size; @end
alex-alex/CinemaCity
CinemaCity/SeatButton.h
<reponame>alex-alex/CinemaCity // // SeatButton.h // CinemaCity // // Created by <NAME> on 29/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> #define UIControlStateChoosed 1 << 16 @interface SeatButton : UIButton @property (nonatomic) int status; @property (nonatomic, strong) NSIndexPath *place; @end
alex-alex/CinemaCity
CinemaCity/TicketRequest.h
// // TicketRequest.h // CinemaCity // // Created by <NAME> on 29/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> @interface TicketRequest : NSObject @end
alex-alex/CinemaCity
CinemaCity/MainTabBarViewController.h
<gh_stars>1-10 // // MainTabBarViewController.h // CinemaCity // // Created by <NAME> on 27/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> @interface MainTabBarViewController : UITabBarController @end
alex-alex/CinemaCity
CinemaCity/ReservationTypeViewController.h
<reponame>alex-alex/CinemaCity // // ReservationTypeViewController.h // CinemaCity // // Created by <NAME> on 29/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> @interface ReservationTypeViewController : UIViewController { __weak IBOutlet UIButton *_reservationButton; __weak IBOutlet UIButton *_purchaseButton; } @property (nonatomic, strong) NSDictionary *URLtemplate; @property (nonatomic, strong) NSString *presentationCode; - (IBAction)reservation; - (IBAction)purchase; @end
alex-alex/CinemaCity
CinemaCity/HistoryViewController.h
<gh_stars>1-10 // // HistoryViewController.h // CinemaCity // // Created by <NAME> on 31/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> @interface HistoryViewController : UITableViewController @end
alex-alex/CinemaCity
CinemaCity/ClubViewController.h
<filename>CinemaCity/ClubViewController.h<gh_stars>1-10 // // ClubViewController.h // CinemaCity // // Created by <NAME> on 31/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> #import "FieldCell.h" @interface ClubViewController : UITableViewController <FieldCellDelegate> @end
alex-alex/CinemaCity
Extensions/FontAwesomeKit/FAKFontAwesome.h
#import "FAKIcon.h" @interface FAKFontAwesome : FAKIcon // Generated Code + (instancetype)glassIconWithSize:(CGFloat)size; + (instancetype)musicIconWithSize:(CGFloat)size; + (instancetype)searchIconWithSize:(CGFloat)size; + (instancetype)envelopeOIconWithSize:(CGFloat)size; + (instancetype)heartIconWithSize:(CGFloat)size; + (instancetype)starIconWithSize:(CGFloat)size; + (instancetype)starOIconWithSize:(CGFloat)size; + (instancetype)userIconWithSize:(CGFloat)size; + (instancetype)filmIconWithSize:(CGFloat)size; + (instancetype)thLargeIconWithSize:(CGFloat)size; + (instancetype)thIconWithSize:(CGFloat)size; + (instancetype)thListIconWithSize:(CGFloat)size; + (instancetype)checkIconWithSize:(CGFloat)size; + (instancetype)timesIconWithSize:(CGFloat)size; + (instancetype)searchPlusIconWithSize:(CGFloat)size; + (instancetype)searchMinusIconWithSize:(CGFloat)size; + (instancetype)powerOffIconWithSize:(CGFloat)size; + (instancetype)signalIconWithSize:(CGFloat)size; + (instancetype)cogIconWithSize:(CGFloat)size; + (instancetype)trashOIconWithSize:(CGFloat)size; + (instancetype)homeIconWithSize:(CGFloat)size; + (instancetype)fileOIconWithSize:(CGFloat)size; + (instancetype)clockOIconWithSize:(CGFloat)size; + (instancetype)roadIconWithSize:(CGFloat)size; + (instancetype)downloadIconWithSize:(CGFloat)size; + (instancetype)arrowCircleODownIconWithSize:(CGFloat)size; + (instancetype)arrowCircleOUpIconWithSize:(CGFloat)size; + (instancetype)inboxIconWithSize:(CGFloat)size; + (instancetype)playCircleOIconWithSize:(CGFloat)size; + (instancetype)repeatIconWithSize:(CGFloat)size; + (instancetype)refreshIconWithSize:(CGFloat)size; + (instancetype)listAltIconWithSize:(CGFloat)size; + (instancetype)lockIconWithSize:(CGFloat)size; + (instancetype)flagIconWithSize:(CGFloat)size; + (instancetype)headphonesIconWithSize:(CGFloat)size; + (instancetype)volumeOffIconWithSize:(CGFloat)size; + (instancetype)volumeDownIconWithSize:(CGFloat)size; + (instancetype)volumeUpIconWithSize:(CGFloat)size; + (instancetype)qrcodeIconWithSize:(CGFloat)size; + (instancetype)barcodeIconWithSize:(CGFloat)size; + (instancetype)tagIconWithSize:(CGFloat)size; + (instancetype)tagsIconWithSize:(CGFloat)size; + (instancetype)bookIconWithSize:(CGFloat)size; + (instancetype)bookmarkIconWithSize:(CGFloat)size; + (instancetype)printIconWithSize:(CGFloat)size; + (instancetype)cameraIconWithSize:(CGFloat)size; + (instancetype)fontIconWithSize:(CGFloat)size; + (instancetype)boldIconWithSize:(CGFloat)size; + (instancetype)italicIconWithSize:(CGFloat)size; + (instancetype)textHeightIconWithSize:(CGFloat)size; + (instancetype)textWidthIconWithSize:(CGFloat)size; + (instancetype)alignLeftIconWithSize:(CGFloat)size; + (instancetype)alignCenterIconWithSize:(CGFloat)size; + (instancetype)alignRightIconWithSize:(CGFloat)size; + (instancetype)alignJustifyIconWithSize:(CGFloat)size; + (instancetype)listIconWithSize:(CGFloat)size; + (instancetype)outdentIconWithSize:(CGFloat)size; + (instancetype)indentIconWithSize:(CGFloat)size; + (instancetype)videoCameraIconWithSize:(CGFloat)size; + (instancetype)pictureOIconWithSize:(CGFloat)size; + (instancetype)pencilIconWithSize:(CGFloat)size; + (instancetype)mapMarkerIconWithSize:(CGFloat)size; + (instancetype)adjustIconWithSize:(CGFloat)size; + (instancetype)tintIconWithSize:(CGFloat)size; + (instancetype)pencilSquareOIconWithSize:(CGFloat)size; + (instancetype)shareSquareOIconWithSize:(CGFloat)size; + (instancetype)checkSquareOIconWithSize:(CGFloat)size; + (instancetype)arrowsIconWithSize:(CGFloat)size; + (instancetype)stepBackwardIconWithSize:(CGFloat)size; + (instancetype)fastBackwardIconWithSize:(CGFloat)size; + (instancetype)backwardIconWithSize:(CGFloat)size; + (instancetype)playIconWithSize:(CGFloat)size; + (instancetype)pauseIconWithSize:(CGFloat)size; + (instancetype)stopIconWithSize:(CGFloat)size; + (instancetype)forwardIconWithSize:(CGFloat)size; + (instancetype)fastForwardIconWithSize:(CGFloat)size; + (instancetype)stepForwardIconWithSize:(CGFloat)size; + (instancetype)ejectIconWithSize:(CGFloat)size; + (instancetype)chevronLeftIconWithSize:(CGFloat)size; + (instancetype)chevronRightIconWithSize:(CGFloat)size; + (instancetype)plusCircleIconWithSize:(CGFloat)size; + (instancetype)minusCircleIconWithSize:(CGFloat)size; + (instancetype)timesCircleIconWithSize:(CGFloat)size; + (instancetype)checkCircleIconWithSize:(CGFloat)size; + (instancetype)questionCircleIconWithSize:(CGFloat)size; + (instancetype)infoCircleIconWithSize:(CGFloat)size; + (instancetype)crosshairsIconWithSize:(CGFloat)size; + (instancetype)timesCircleOIconWithSize:(CGFloat)size; + (instancetype)checkCircleOIconWithSize:(CGFloat)size; + (instancetype)banIconWithSize:(CGFloat)size; + (instancetype)arrowLeftIconWithSize:(CGFloat)size; + (instancetype)arrowRightIconWithSize:(CGFloat)size; + (instancetype)arrowUpIconWithSize:(CGFloat)size; + (instancetype)arrowDownIconWithSize:(CGFloat)size; + (instancetype)shareIconWithSize:(CGFloat)size; + (instancetype)expandIconWithSize:(CGFloat)size; + (instancetype)compressIconWithSize:(CGFloat)size; + (instancetype)plusIconWithSize:(CGFloat)size; + (instancetype)minusIconWithSize:(CGFloat)size; + (instancetype)asteriskIconWithSize:(CGFloat)size; + (instancetype)exclamationCircleIconWithSize:(CGFloat)size; + (instancetype)giftIconWithSize:(CGFloat)size; + (instancetype)leafIconWithSize:(CGFloat)size; + (instancetype)fireIconWithSize:(CGFloat)size; + (instancetype)eyeIconWithSize:(CGFloat)size; + (instancetype)eyeSlashIconWithSize:(CGFloat)size; + (instancetype)exclamationTriangleIconWithSize:(CGFloat)size; + (instancetype)planeIconWithSize:(CGFloat)size; + (instancetype)calendarIconWithSize:(CGFloat)size; + (instancetype)randomIconWithSize:(CGFloat)size; + (instancetype)commentIconWithSize:(CGFloat)size; + (instancetype)magnetIconWithSize:(CGFloat)size; + (instancetype)chevronUpIconWithSize:(CGFloat)size; + (instancetype)chevronDownIconWithSize:(CGFloat)size; + (instancetype)retweetIconWithSize:(CGFloat)size; + (instancetype)shoppingCartIconWithSize:(CGFloat)size; + (instancetype)folderIconWithSize:(CGFloat)size; + (instancetype)folderOpenIconWithSize:(CGFloat)size; + (instancetype)arrowsVIconWithSize:(CGFloat)size; + (instancetype)arrowsHIconWithSize:(CGFloat)size; + (instancetype)barChartOIconWithSize:(CGFloat)size; + (instancetype)twitterSquareIconWithSize:(CGFloat)size; + (instancetype)facebookSquareIconWithSize:(CGFloat)size; + (instancetype)cameraRetroIconWithSize:(CGFloat)size; + (instancetype)keyIconWithSize:(CGFloat)size; + (instancetype)cogsIconWithSize:(CGFloat)size; + (instancetype)commentsIconWithSize:(CGFloat)size; + (instancetype)thumbsOUpIconWithSize:(CGFloat)size; + (instancetype)thumbsODownIconWithSize:(CGFloat)size; + (instancetype)starHalfIconWithSize:(CGFloat)size; + (instancetype)heartOIconWithSize:(CGFloat)size; + (instancetype)signOutIconWithSize:(CGFloat)size; + (instancetype)linkedinSquareIconWithSize:(CGFloat)size; + (instancetype)thumbTackIconWithSize:(CGFloat)size; + (instancetype)externalLinkIconWithSize:(CGFloat)size; + (instancetype)signInIconWithSize:(CGFloat)size; + (instancetype)trophyIconWithSize:(CGFloat)size; + (instancetype)githubSquareIconWithSize:(CGFloat)size; + (instancetype)uploadIconWithSize:(CGFloat)size; + (instancetype)lemonOIconWithSize:(CGFloat)size; + (instancetype)phoneIconWithSize:(CGFloat)size; + (instancetype)squareOIconWithSize:(CGFloat)size; + (instancetype)bookmarkOIconWithSize:(CGFloat)size; + (instancetype)phoneSquareIconWithSize:(CGFloat)size; + (instancetype)twitterIconWithSize:(CGFloat)size; + (instancetype)facebookIconWithSize:(CGFloat)size; + (instancetype)githubIconWithSize:(CGFloat)size; + (instancetype)unlockIconWithSize:(CGFloat)size; + (instancetype)creditCardIconWithSize:(CGFloat)size; + (instancetype)rssIconWithSize:(CGFloat)size; + (instancetype)hddOIconWithSize:(CGFloat)size; + (instancetype)bullhornIconWithSize:(CGFloat)size; + (instancetype)bellIconWithSize:(CGFloat)size; + (instancetype)certificateIconWithSize:(CGFloat)size; + (instancetype)handORightIconWithSize:(CGFloat)size; + (instancetype)handOLeftIconWithSize:(CGFloat)size; + (instancetype)handOUpIconWithSize:(CGFloat)size; + (instancetype)handODownIconWithSize:(CGFloat)size; + (instancetype)arrowCircleLeftIconWithSize:(CGFloat)size; + (instancetype)arrowCircleRightIconWithSize:(CGFloat)size; + (instancetype)arrowCircleUpIconWithSize:(CGFloat)size; + (instancetype)arrowCircleDownIconWithSize:(CGFloat)size; + (instancetype)globeIconWithSize:(CGFloat)size; + (instancetype)wrenchIconWithSize:(CGFloat)size; + (instancetype)tasksIconWithSize:(CGFloat)size; + (instancetype)filterIconWithSize:(CGFloat)size; + (instancetype)briefcaseIconWithSize:(CGFloat)size; + (instancetype)arrowsAltIconWithSize:(CGFloat)size; + (instancetype)usersIconWithSize:(CGFloat)size; + (instancetype)linkIconWithSize:(CGFloat)size; + (instancetype)cloudIconWithSize:(CGFloat)size; + (instancetype)flaskIconWithSize:(CGFloat)size; + (instancetype)scissorsIconWithSize:(CGFloat)size; + (instancetype)filesOIconWithSize:(CGFloat)size; + (instancetype)paperclipIconWithSize:(CGFloat)size; + (instancetype)floppyOIconWithSize:(CGFloat)size; + (instancetype)squareIconWithSize:(CGFloat)size; + (instancetype)barsIconWithSize:(CGFloat)size; + (instancetype)listUlIconWithSize:(CGFloat)size; + (instancetype)listOlIconWithSize:(CGFloat)size; + (instancetype)strikethroughIconWithSize:(CGFloat)size; + (instancetype)underlineIconWithSize:(CGFloat)size; + (instancetype)tableIconWithSize:(CGFloat)size; + (instancetype)magicIconWithSize:(CGFloat)size; + (instancetype)truckIconWithSize:(CGFloat)size; + (instancetype)pinterestIconWithSize:(CGFloat)size; + (instancetype)pinterestSquareIconWithSize:(CGFloat)size; + (instancetype)googlePlusSquareIconWithSize:(CGFloat)size; + (instancetype)googlePlusIconWithSize:(CGFloat)size; + (instancetype)moneyIconWithSize:(CGFloat)size; + (instancetype)caretDownIconWithSize:(CGFloat)size; + (instancetype)caretUpIconWithSize:(CGFloat)size; + (instancetype)caretLeftIconWithSize:(CGFloat)size; + (instancetype)caretRightIconWithSize:(CGFloat)size; + (instancetype)columnsIconWithSize:(CGFloat)size; + (instancetype)sortIconWithSize:(CGFloat)size; + (instancetype)sortAscIconWithSize:(CGFloat)size; + (instancetype)sortDescIconWithSize:(CGFloat)size; + (instancetype)envelopeIconWithSize:(CGFloat)size; + (instancetype)linkedinIconWithSize:(CGFloat)size; + (instancetype)undoIconWithSize:(CGFloat)size; + (instancetype)gavelIconWithSize:(CGFloat)size; + (instancetype)tachometerIconWithSize:(CGFloat)size; + (instancetype)commentOIconWithSize:(CGFloat)size; + (instancetype)commentsOIconWithSize:(CGFloat)size; + (instancetype)boltIconWithSize:(CGFloat)size; + (instancetype)sitemapIconWithSize:(CGFloat)size; + (instancetype)umbrellaIconWithSize:(CGFloat)size; + (instancetype)clipboardIconWithSize:(CGFloat)size; + (instancetype)lightbulbOIconWithSize:(CGFloat)size; + (instancetype)exchangeIconWithSize:(CGFloat)size; + (instancetype)cloudDownloadIconWithSize:(CGFloat)size; + (instancetype)cloudUploadIconWithSize:(CGFloat)size; + (instancetype)userMdIconWithSize:(CGFloat)size; + (instancetype)stethoscopeIconWithSize:(CGFloat)size; + (instancetype)suitcaseIconWithSize:(CGFloat)size; + (instancetype)bellOIconWithSize:(CGFloat)size; + (instancetype)coffeeIconWithSize:(CGFloat)size; + (instancetype)cutleryIconWithSize:(CGFloat)size; + (instancetype)fileTextOIconWithSize:(CGFloat)size; + (instancetype)buildingOIconWithSize:(CGFloat)size; + (instancetype)hospitalOIconWithSize:(CGFloat)size; + (instancetype)ambulanceIconWithSize:(CGFloat)size; + (instancetype)medkitIconWithSize:(CGFloat)size; + (instancetype)fighterJetIconWithSize:(CGFloat)size; + (instancetype)beerIconWithSize:(CGFloat)size; + (instancetype)hSquareIconWithSize:(CGFloat)size; + (instancetype)plusSquareIconWithSize:(CGFloat)size; + (instancetype)angleDoubleLeftIconWithSize:(CGFloat)size; + (instancetype)angleDoubleRightIconWithSize:(CGFloat)size; + (instancetype)angleDoubleUpIconWithSize:(CGFloat)size; + (instancetype)angleDoubleDownIconWithSize:(CGFloat)size; + (instancetype)angleLeftIconWithSize:(CGFloat)size; + (instancetype)angleRightIconWithSize:(CGFloat)size; + (instancetype)angleUpIconWithSize:(CGFloat)size; + (instancetype)angleDownIconWithSize:(CGFloat)size; + (instancetype)desktopIconWithSize:(CGFloat)size; + (instancetype)laptopIconWithSize:(CGFloat)size; + (instancetype)tabletIconWithSize:(CGFloat)size; + (instancetype)mobileIconWithSize:(CGFloat)size; + (instancetype)circleOIconWithSize:(CGFloat)size; + (instancetype)quoteLeftIconWithSize:(CGFloat)size; + (instancetype)quoteRightIconWithSize:(CGFloat)size; + (instancetype)spinnerIconWithSize:(CGFloat)size; + (instancetype)circleIconWithSize:(CGFloat)size; + (instancetype)replyIconWithSize:(CGFloat)size; + (instancetype)githubAltIconWithSize:(CGFloat)size; + (instancetype)folderOIconWithSize:(CGFloat)size; + (instancetype)folderOpenOIconWithSize:(CGFloat)size; + (instancetype)smileOIconWithSize:(CGFloat)size; + (instancetype)frownOIconWithSize:(CGFloat)size; + (instancetype)mehOIconWithSize:(CGFloat)size; + (instancetype)gamepadIconWithSize:(CGFloat)size; + (instancetype)keyboardOIconWithSize:(CGFloat)size; + (instancetype)flagOIconWithSize:(CGFloat)size; + (instancetype)flagCheckeredIconWithSize:(CGFloat)size; + (instancetype)terminalIconWithSize:(CGFloat)size; + (instancetype)codeIconWithSize:(CGFloat)size; + (instancetype)replyAllIconWithSize:(CGFloat)size; + (instancetype)mailReplyAllIconWithSize:(CGFloat)size; + (instancetype)starHalfOIconWithSize:(CGFloat)size; + (instancetype)locationArrowIconWithSize:(CGFloat)size; + (instancetype)cropIconWithSize:(CGFloat)size; + (instancetype)codeForkIconWithSize:(CGFloat)size; + (instancetype)chainBrokenIconWithSize:(CGFloat)size; + (instancetype)questionIconWithSize:(CGFloat)size; + (instancetype)infoIconWithSize:(CGFloat)size; + (instancetype)exclamationIconWithSize:(CGFloat)size; + (instancetype)superscriptIconWithSize:(CGFloat)size; + (instancetype)subscriptIconWithSize:(CGFloat)size; + (instancetype)eraserIconWithSize:(CGFloat)size; + (instancetype)puzzlePieceIconWithSize:(CGFloat)size; + (instancetype)microphoneIconWithSize:(CGFloat)size; + (instancetype)microphoneSlashIconWithSize:(CGFloat)size; + (instancetype)shieldIconWithSize:(CGFloat)size; + (instancetype)calendarOIconWithSize:(CGFloat)size; + (instancetype)fireExtinguisherIconWithSize:(CGFloat)size; + (instancetype)rocketIconWithSize:(CGFloat)size; + (instancetype)maxcdnIconWithSize:(CGFloat)size; + (instancetype)chevronCircleLeftIconWithSize:(CGFloat)size; + (instancetype)chevronCircleRightIconWithSize:(CGFloat)size; + (instancetype)chevronCircleUpIconWithSize:(CGFloat)size; + (instancetype)chevronCircleDownIconWithSize:(CGFloat)size; + (instancetype)html5IconWithSize:(CGFloat)size; + (instancetype)css3IconWithSize:(CGFloat)size; + (instancetype)anchorIconWithSize:(CGFloat)size; + (instancetype)unlockAltIconWithSize:(CGFloat)size; + (instancetype)bullseyeIconWithSize:(CGFloat)size; + (instancetype)ellipsisHIconWithSize:(CGFloat)size; + (instancetype)ellipsisVIconWithSize:(CGFloat)size; + (instancetype)rssSquareIconWithSize:(CGFloat)size; + (instancetype)playCircleIconWithSize:(CGFloat)size; + (instancetype)ticketIconWithSize:(CGFloat)size; + (instancetype)minusSquareIconWithSize:(CGFloat)size; + (instancetype)minusSquareOIconWithSize:(CGFloat)size; + (instancetype)levelUpIconWithSize:(CGFloat)size; + (instancetype)levelDownIconWithSize:(CGFloat)size; + (instancetype)checkSquareIconWithSize:(CGFloat)size; + (instancetype)pencilSquareIconWithSize:(CGFloat)size; + (instancetype)externalLinkSquareIconWithSize:(CGFloat)size; + (instancetype)shareSquareIconWithSize:(CGFloat)size; + (instancetype)compassIconWithSize:(CGFloat)size; + (instancetype)caretSquareODownIconWithSize:(CGFloat)size; + (instancetype)caretSquareOUpIconWithSize:(CGFloat)size; + (instancetype)caretSquareORightIconWithSize:(CGFloat)size; + (instancetype)eurIconWithSize:(CGFloat)size; + (instancetype)gbpIconWithSize:(CGFloat)size; + (instancetype)usdIconWithSize:(CGFloat)size; + (instancetype)inrIconWithSize:(CGFloat)size; + (instancetype)jpyIconWithSize:(CGFloat)size; + (instancetype)rubIconWithSize:(CGFloat)size; + (instancetype)krwIconWithSize:(CGFloat)size; + (instancetype)btcIconWithSize:(CGFloat)size; + (instancetype)fileIconWithSize:(CGFloat)size; + (instancetype)fileTextIconWithSize:(CGFloat)size; + (instancetype)sortAlphaAscIconWithSize:(CGFloat)size; + (instancetype)sortAlphaDescIconWithSize:(CGFloat)size; + (instancetype)sortAmountAscIconWithSize:(CGFloat)size; + (instancetype)sortAmountDescIconWithSize:(CGFloat)size; + (instancetype)sortNumericAscIconWithSize:(CGFloat)size; + (instancetype)sortNumericDescIconWithSize:(CGFloat)size; + (instancetype)thumbsUpIconWithSize:(CGFloat)size; + (instancetype)thumbsDownIconWithSize:(CGFloat)size; + (instancetype)youtubeSquareIconWithSize:(CGFloat)size; + (instancetype)youtubeIconWithSize:(CGFloat)size; + (instancetype)xingIconWithSize:(CGFloat)size; + (instancetype)xingSquareIconWithSize:(CGFloat)size; + (instancetype)youtubePlayIconWithSize:(CGFloat)size; + (instancetype)dropboxIconWithSize:(CGFloat)size; + (instancetype)stackOverflowIconWithSize:(CGFloat)size; + (instancetype)instagramIconWithSize:(CGFloat)size; + (instancetype)flickrIconWithSize:(CGFloat)size; + (instancetype)adnIconWithSize:(CGFloat)size; + (instancetype)bitbucketIconWithSize:(CGFloat)size; + (instancetype)bitbucketSquareIconWithSize:(CGFloat)size; + (instancetype)tumblrIconWithSize:(CGFloat)size; + (instancetype)tumblrSquareIconWithSize:(CGFloat)size; + (instancetype)longArrowDownIconWithSize:(CGFloat)size; + (instancetype)longArrowUpIconWithSize:(CGFloat)size; + (instancetype)longArrowLeftIconWithSize:(CGFloat)size; + (instancetype)longArrowRightIconWithSize:(CGFloat)size; + (instancetype)appleIconWithSize:(CGFloat)size; + (instancetype)windowsIconWithSize:(CGFloat)size; + (instancetype)androidIconWithSize:(CGFloat)size; + (instancetype)linuxIconWithSize:(CGFloat)size; + (instancetype)dribbbleIconWithSize:(CGFloat)size; + (instancetype)skypeIconWithSize:(CGFloat)size; + (instancetype)foursquareIconWithSize:(CGFloat)size; + (instancetype)trelloIconWithSize:(CGFloat)size; + (instancetype)femaleIconWithSize:(CGFloat)size; + (instancetype)maleIconWithSize:(CGFloat)size; + (instancetype)gittipIconWithSize:(CGFloat)size; + (instancetype)sunOIconWithSize:(CGFloat)size; + (instancetype)moonOIconWithSize:(CGFloat)size; + (instancetype)archiveIconWithSize:(CGFloat)size; + (instancetype)bugIconWithSize:(CGFloat)size; + (instancetype)vkIconWithSize:(CGFloat)size; + (instancetype)weiboIconWithSize:(CGFloat)size; + (instancetype)renrenIconWithSize:(CGFloat)size; + (instancetype)pagelinesIconWithSize:(CGFloat)size; + (instancetype)stackExchangeIconWithSize:(CGFloat)size; + (instancetype)arrowCircleORightIconWithSize:(CGFloat)size; + (instancetype)arrowCircleOLeftIconWithSize:(CGFloat)size; + (instancetype)caretSquareOLeftIconWithSize:(CGFloat)size; + (instancetype)dotCircleOIconWithSize:(CGFloat)size; + (instancetype)wheelchairIconWithSize:(CGFloat)size; + (instancetype)vimeoSquareIconWithSize:(CGFloat)size; + (instancetype)tryIconWithSize:(CGFloat)size; + (instancetype)plusSquareOIconWithSize:(CGFloat)size; @end
alex-alex/CinemaCity
Extensions/XCDYouTubeVideoPlayerViewController/XCDYouTubeVideoPlayerViewController.h
<filename>Extensions/XCDYouTubeVideoPlayerViewController/XCDYouTubeVideoPlayerViewController.h // // XCDYouTubeVideoPlayerViewController.h // XCDYouTubeVideoPlayerViewController // // Created by <NAME> on 02.05.13. // Copyright (c) 2013 <NAME>. All rights reserved. // #import <MediaPlayer/MediaPlayer.h> typedef NS_ENUM(NSUInteger, XCDYouTubeVideoQuality) { XCDYouTubeVideoQualitySmall240 = 36, XCDYouTubeVideoQualityMedium360 = 18, XCDYouTubeVideoQualityHD720 = 22, XCDYouTubeVideoQualityHD1080 = 37, }; MP_EXTERN NSString *const XCDYouTubeVideoErrorDomain; MP_EXTERN NSString *const XCDMoviePlayerPlaybackDidFinishErrorUserInfoKey; // NSError key for the `MPMoviePlayerPlaybackDidFinishNotification` userInfo dictionary enum { XCDYouTubeErrorInvalidVideoIdentifier = 2, // The given `videoIdentifier` string is invalid (including `nil`) XCDYouTubeErrorRemovedVideo = 100, // The video has been removed as a violation of YouTube's policy XCDYouTubeErrorRestrictedPlayback = 150 // The video is not playable because of legal reasons or the this is a private video }; MP_EXTERN NSString *const XCDYouTubeVideoPlayerViewControllerDidReceiveMetadataNotification; // Metadata notification userInfo keys, they are all optional MP_EXTERN NSString *const XCDMetadataKeyTitle; MP_EXTERN NSString *const XCDMetadataKeySmallThumbnailURL; MP_EXTERN NSString *const XCDMetadataKeyMediumThumbnailURL; MP_EXTERN NSString *const XCDMetadataKeyLargeThumbnailURL; @interface XCDYouTubeVideoPlayerViewController : MPMoviePlayerViewController - (id) initWithVideoIdentifier:(NSString *)videoIdentifier; @property (nonatomic, copy) NSString *videoIdentifier; // On iPhone, defaults to @[ @(XCDYouTubeVideoQualityHD720), @(XCDYouTubeVideoQualityMedium360), @(XCDYouTubeVideoQualitySmall240) ] // On iPad, defaults to @[ @(XCDYouTubeVideoQualityHD1080), @(XCDYouTubeVideoQualityHD720), @(XCDYouTubeVideoQualityMedium360), @(XCDYouTubeVideoQualitySmall240) ] // If you really know what you are doing, you can use the `itag` values as described on http://en.wikipedia.org/wiki/YouTube#Quality_and_codecs // Setting this property to nil restores its default values @property (nonatomic, copy) NSArray *preferredVideoQualities; // Ownership of the XCDYouTubeVideoPlayerViewController instance is transferred to the view. - (void) presentInView:(UIView *)view; @end
alex-alex/CinemaCity
CinemaCity/TicketsViewController.h
// // TicketsViewController.h // CinemaCity // // Created by <NAME> on 30/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> #import "TicketCell.h" @interface TicketsViewController : UITableViewController <TicketCellDelegate> @property (nonatomic, strong) NSURL *ticketURL; - (IBAction)continueAction; @end
alex-alex/CinemaCity
CinemaCity/MovieCell.h
<gh_stars>1-10 // // MovieCell.h // CinemaCity // // Created by <NAME> on 27/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> @interface MovieCell : UICollectionViewCell { __weak IBOutlet UIImageView *_imageView; __weak IBOutlet UILabel *_titleLabel; } @property (nonatomic, strong) NSDictionary *movieDict; @end
alex-alex/CinemaCity
CinemaCity/Presentations.h
<gh_stars>1-10 // // Presentations.h // CinemaCity // // Created by <NAME> on 29/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> @interface Presentations : NSObject + (instancetype)presentationsWithDictionary:(NSDictionary *)dictionary; - (instancetype)initWithDictionary:(NSDictionary *)dictionary; - (NSArray *)sites; - (NSString *)siteNameForSiteCode:(NSString *)siteCode; - (NSString *)movieNameForSite:(NSString *)siteCode; - (NSDictionary *)templateForSite:(NSString *)siteCode; - (NSArray *)presentationsAtSite:(NSString *)siteCode date:(NSDate *)date; - (NSArray *)presentationTypeNamesAtSite:(NSString *)siteCode date:(NSDate *)date; @end
alex-alex/CinemaCity
CinemaCity/TicketCell.h
// // TicketCell.h // CinemaCity // // Created by <NAME> on 30/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> @protocol TicketCellDelegate; @interface TicketCell : UITableViewCell { __weak IBOutlet UILabel *_nameLabel; __weak IBOutlet UILabel *_priceLabel; __weak IBOutlet UILabel *_chargeLabel; __weak IBOutlet UILabel *_quantityLabel; __weak IBOutlet UIStepper *_stepper; } @property (nonatomic, strong) id<TicketCellDelegate> delegate; - (void)setPriceDict:(NSDictionary *)priceDict quantity:(int)quantity; - (IBAction)stepperValueChanged:(UIStepper *)sender; @end @protocol TicketCellDelegate <NSObject> @optional - (void)ticketCell:(TicketCell *)cell didChangeQuantity:(int)quantity forPriceID:(NSString *)priceID; @end
alex-alex/CinemaCity
CinemaCity/LicenceViewController.h
<filename>CinemaCity/LicenceViewController.h // // LicenceViewController.h // CinemaCity // // Created by <NAME> on 30/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> @interface LicenceViewController : UIViewController { __weak IBOutlet UITextView *_textField; } @property (nonatomic, strong) NSURL *ticketURL; - (IBAction)continueAction; @end
alex-alex/CinemaCity
CinemaCity/ReservationInputViewController.h
<gh_stars>1-10 // // ReservationInputViewController.h // CinemaCity // // Created by <NAME> on 29/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> @interface ReservationInputViewController : UITableViewController @property (nonatomic, strong) NSString *cinemaID; @property (nonatomic, strong) NSString *venueTypeID; @property (nonatomic, strong) NSString *featureCode; @property (nonatomic, strong) NSURL *detailURL; @property (nonatomic, strong) NSDate *date; @end
alex-alex/CinemaCity
CinemaCity/SeatChooserViewController.h
<reponame>alex-alex/CinemaCity // // SeatChooserViewController.h // CinemaCity // // Created by <NAME> on 29/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> @interface SeatChooserViewController : UIViewController <UIScrollViewDelegate> { __weak IBOutlet UIScrollView *_scrollView; } @property (nonatomic, strong) NSURL *url; @property (nonatomic, strong) NSDictionary *formInfo; @property (nonatomic, strong) NSDictionary *tickets; - (IBAction)continueAction; @end
alex-alex/CinemaCity
CinemaCity/ScheduleCell.h
<gh_stars>1-10 // // ScheduleCell.h // CinemaCity // // Created by <NAME> on 27/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> #import "TintColorSelectionCell.h" @interface ScheduleCell : TintColorSelectionCell { __weak IBOutlet UILabel *_nameLabel; __weak IBOutlet UILabel *_ratingLabel; __weak IBOutlet UILabel *_typeLabel; __weak IBOutlet UILabel *_versionLabel; __weak IBOutlet UILabel *_durationLabel; } - (void)setScheduleDict:(NSDictionary *)scheduleDict today:(BOOL)today; @end
alex-alex/CinemaCity
CinemaCity/API.h
// // API.h // CinemaCity // // Created by <NAME> on 27/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <Foundation/Foundation.h> #import "Presentations.h" @interface API : NSObject @property (nonatomic, readonly) NSOperationQueue *networkQueue; @property (nonatomic, readonly) NSDateFormatter *dateFormatter; @property (nonatomic, readonly) NSDateFormatter *timeFormatter; @property (nonatomic, readonly) NSDateFormatter *humanDateFormatter; @property (nonatomic, readonly) NSDateFormatter *humanDateTimeFormatter; + (instancetype)sharedInstance; - (void)loginUser:(NSString *)username password:(<PASSWORD> *)password completionHandler:(void (^)(NSDictionary *userInfo))handler; - (void)logoutUserWithCompletionHandler:(void (^)(BOOL success))handler; - (void)loadHistoryWithCompletionHandler:(void (^)(NSArray *history))handler; - (void)getMoviesWithCompletionHandler:(void (^)(NSArray *movies))handler; - (void)getScheduleForCinema:(NSString *)cinemaID venueTypeID:(NSString *)venueTypeID date:(NSDate *)date completionHandler:(void (^)(NSArray *schedule))handler; - (void)getPresentationsForURL:(NSURL *)url completionHandler:(void (^)(Presentations *presentations))handler; - (void)getDetailOfMovieWithFeatureCode:(NSString *)featureCode completionHandler:(void (^)(NSDictionary *movieDetail))handler; - (void)getDetailOfMovieWithURL:(NSURL *)url completionHandler:(void (^)(NSDictionary *movieDetail))handler; - (void)loadSelectTicketsFormWithURL:(NSURL *)url completionHandler:(void (^)(NSURL *url, NSDictionary *formInfo, NSArray *prices))handler; - (void)loadSelectTicketsWithURL:(NSURL *)url formInfo:(NSDictionary *)formInfo tickets:(NSDictionary *)tickets completionHandler:(void (^)(NSURL *url, NSDictionary *formInfo, NSArray *seats, CGSize seatSize))handler; - (void)selectSeatsWithURL:(NSURL *)url formInfo:(NSDictionary *)formInfo seats:(NSArray *)seats completionHandler:(void (^)(NSURL *url, NSDictionary *formInfo, NSDate *expirationDate, NSURL *captchaURL))handler captchaHandler:(void (^)(UIImage *captcha))captchaHandler; - (void)sendOrderWithURL:(NSURL *)url formInfo:(NSDictionary *)formInfo name:(NSString *)name surname:(NSString *)surname email:(NSString *)email phone:(NSString *)phone captcha:(NSString *)captcha completionHandler:(void (^)(NSURL *url, NSDictionary *formInfo))handler; @end
alex-alex/CinemaCity
CinemaCity/TintColorSelectionCell.h
<filename>CinemaCity/TintColorSelectionCell.h // // TintColorSelectionCell.h // CinemaCity // // Created by <NAME> on 31/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> @interface TintColorSelectionCell : UITableViewCell @end
alex-alex/CinemaCity
CinemaCity/ScheduleViewController.h
// // ScheduleViewController.h // CinemaCity // // Created by <NAME> on 27/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> #import "RMDateSelectionViewController.h" #import "RMPickerViewController.h" @interface ScheduleViewController : UITableViewController <UIPickerViewDataSource, UIPickerViewDelegate> - (IBAction)changeDate; - (IBAction)changeCinema; @end
alex-alex/CinemaCity
CinemaCity/OrderViewController.h
// // OrderViewController.h // CinemaCity // // Created by <NAME> on 31/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> @interface OrderViewController : UIViewController <UITextFieldDelegate> { __weak IBOutlet UIScrollView *_scrollView; __weak IBOutlet UITextField *_nameField; __weak IBOutlet UITextField *_surnameField; __weak IBOutlet UITextField *_emailField; __weak IBOutlet UITextField *_phoneField; __weak IBOutlet UITextField *_captchaField; __weak IBOutlet UIImageView *_captchaImageView; IBOutlet UIBarButtonItem *_continueButton; IBOutlet UIBarButtonItem *_doneButton; } @property (nonatomic, strong) NSURL *url; @property (nonatomic, strong) NSDictionary *formInfo; @property (nonatomic, strong) NSArray *seats; @end
alex-alex/CinemaCity
CinemaCity/MoviesViewController.h
<reponame>alex-alex/CinemaCity // // MoviesViewController.h // CinemaCity // // Created by <NAME> on 27/03/14. // Copyright (c) 2014 <NAME>. All rights reserved. // #import <UIKit/UIKit.h> #import "RMPickerViewController.h" @interface MoviesViewController : UICollectionViewController <UIPickerViewDataSource, UIPickerViewDelegate> - (IBAction)changeCategory; @end
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/les/BREthereumMessage.h
// // BREthereumMessage.h // Core // // Created by <NAME> on 8/13/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // // See the LICENSE file at the project root for license information. // See the CONTRIBUTORS file at the project root for a list of contributors. #ifndef BR_Ethereum_Message_H #define BR_Ethereum_Message_H #include "BREthereumLESBase.h" #include "msg/BREthereumMessageP2P.h" #include "msg/BREthereumMessageDIS.h" #include "msg/BREthereumMessageETH.h" #include "msg/BREthereumMessageLES.h" #include "msg/BREthereumMessagePIP.h" #ifdef __cplusplus extern "C" { #endif // // BREthereumMessageIdentifier - The Ethereum Wire Protocol (WIP) defines four fundamental // message types. We'll explicitly handle each one. // typedef enum { MESSAGE_P2P = 0x00, MESSAGE_DIS = 0x01, MESSAGE_ETH = 0x02, MESSAGE_LES = 0x03, MESSAGE_PIP = 0x04, } BREthereumMessageIdentifier; /// MARK: - Wire Protocol Messages /** * An ANYMessageIdentifier can be any of P2P, DIS, LES or ETH message identifiers */ typedef int16_t BREthereumANYMessageIdentifier; /** * An Ethereum Message is one of the P2P, DIS, LES or ETH messages */ typedef struct { BREthereumMessageIdentifier identifier; union { BREthereumP2PMessage p2p; BREthereumDISMessage dis; BREthereumETHMessage eth; BREthereumLESMessage les; BREthereumPIPMessage pip; } u; } BREthereumMessage; extern BRRlpItem messageEncode (BREthereumMessage message, BREthereumMessageCoder coder); extern BREthereumMessage messageDecode (BRRlpItem item, BREthereumMessageCoder coder, BREthereumMessageIdentifier type, BREthereumANYMessageIdentifier subtype); extern void messageRelease (BREthereumMessage *message); extern void messagesRelease (BRArrayOf(BREthereumMessage) messages); /** * Check if `message` has the provided `identifier` * * @param message * @param identifer * * @return TRUE (1) if message has identifier, FALSE (0) otherwise. */ extern int messageHasIdentifier (BREthereumMessage *message, BREthereumMessageIdentifier identifer); /** * Check if `message` has the provided `identifier` and 'sub identifier` * * @param message * @param identifer * @param anyIdentifer * * @return TRUE (1) if message has both identifiers, FALSE (0) otherwise. */ extern int messageHasIdentifiers (BREthereumMessage *message, BREthereumMessageIdentifier identifer, BREthereumANYMessageIdentifier anyIdentifier); const char * messageGetIdentifierName (BREthereumMessage *message); const char * messageGetAnyIdentifierName (BREthereumMessage *message); #ifdef __cplusplus } #endif #endif /* BR_Ethereum_Message_H */
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Database/UTXOStore.h
/* * Copyright (c) 2019 Elastos Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef __ELASTOS_SDK_UTXOSTORE_H__ #define __ELASTOS_SDK_UTXOSTORE_H__ #include "Sqlite.h" #include "TableBase.h" namespace Elastos { namespace ElaWallet { class UTXOEntity; class UTXOStore : public TableBase { public: UTXOStore(Sqlite *sqlite, SqliteTransactionType type = IMMEDIATE); ~UTXOStore(); virtual void InitializeTable(); bool Puts(const std::vector<UTXOEntity> &entities); std::vector<UTXOEntity> Gets() const; bool Update(const std::vector<UTXOEntity> &added, const std::vector<UTXOEntity> &deleted, bool replace); bool DeleteAll(); bool Delete(const std::vector<UTXOEntity> &entities); const std::string &GetTableName() const; const std::string &GetTxHashColumnName() const; const std::string &GetIndexColumnName() const; private: bool PutInternal(const UTXOEntity &entity); bool DeleteInternal(const UTXOEntity &entity); private: std::string _tableName; std::string _txHash; std::string _index; std::string _tableCreation; }; class UTXOEntity { public: UTXOEntity() : _n(0) { } UTXOEntity(const std::string &hash, uint16_t n) : _hash(hash), _n(n) { } ~UTXOEntity() { } bool operator==(const UTXOEntity &e) const { return this->_hash == e._hash && this->_n == e._n; } const std::string &Hash() const { return _hash; } uint16_t Index() const { return _n; } private: friend class UTXOStore; std::string _hash; uint16_t _n; }; } } #endif //__ELASTOS_SDK_UTXOSTORE_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/blockchain/BREthereumBlockChain.h
<reponame>fakecoinbase/elastosslashElastos.ELA.SPV.Cpp<filename>ThirdParty/breadwallet-core/ethereum/blockchain/BREthereumBlockChain.h // // BREthereumBlockChain.h // BRCore // // Created by <NAME> on 5/17/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // // See the LICENSE file at the project root for license information. // See the CONTRIBUTORS file at the project root for a list of contributors. #ifndef BR_Ethereum_Blochchain_h #define BR_Ethereum_Blochchain_h #include "BREthereumNetwork.h" #include "BREthereumAccountState.h" #include "BREthereumBloomFilter.h" #include "BREthereumLog.h" #include "BREthereumTransaction.h" #include "BREthereumTransactionStatus.h" #include "BREthereumTransactionReceipt.h" #include "BREthereumBlock.h" #endif // BR_Ethereum_Blochchain_h
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/event/BREventAlarm.c
// // BREventAlarm.c // BRCore // // Created by <NAME> on 5/7/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // // See the LICENSE file at the project root for license information. // See the CONTRIBUTORS file at the project root for a list of contributors. // #include <string.h> #include <limits.h> #include <errno.h> #include <pthread.h> #include <sys/time.h> #include "support/BRAssert.h" #include "support/BRArray.h" #include "BREvent.h" #include "BREventAlarm.h" #define PTHREAD_NULL ((pthread_t) NULL) #define PTHREAD_STACK_SIZE (32 * 1024) /* Explicitly import (from BREvent.c) */ extern void eventHandlerInvokeTimeout (BREventHandler handler); /* `struct timespec` support */ static struct timespec getTime () { struct timeval now; struct timespec time; gettimeofday(&now, NULL); time.tv_sec = now.tv_sec; time.tv_nsec = 1000 * now.tv_usec; return time; } /* Unused static inline struct timespec timespecAdd (struct timespec *t1, struct timespec *t2) { long tv_nsec = t1->tv_nsec + t2->tv_nsec; long tv_sec = t1->tv_sec + t2->tv_sec; if (tv_nsec >= 1000000000) { tv_nsec -= 1000000000; tv_sec += 1; } return (struct timespec) { .tv_sec = tv_sec, .tv_nsec = tv_nsec }; } */ static inline void timespecInc (struct timespec *t1, struct timespec *t2) { t1->tv_nsec += t2->tv_nsec; t1->tv_sec += t2->tv_sec; if (t1->tv_nsec >= 1000000000) { t1->tv_nsec -= 1000000000; t1->tv_sec += 1; } } static inline int timespecCompare (struct timespec *t1, struct timespec *t2) { return (t1->tv_sec > t2->tv_sec ? +1 : (t1->tv_sec < t2->tv_sec ? -1 : (t1->tv_nsec > t2->tv_nsec ? +1 : (t1->tv_nsec < t2->tv_nsec ? -1 : 0)))); } /** */ BREventAlarmClock alarmClock = NULL; typedef enum { ALARM_ONE_SHOT, ALARM_PERIODIC } BREventAlarmType; /** */ typedef struct { BREventAlarmId identifier; BREventAlarmType type; BREventAlarmContext context; BREventAlarmCallback callback; /// The next expiration time. This is updated if the alarm is periodic. struct timespec expiration; /// The alarm's period. For a ONE_SHOT alarm, this is ignored/zeroed. struct timespec period; } BREventAlarm; static BREventAlarm alarmCreatePeriodic (BREventAlarmContext context, BREventAlarmCallback callback, struct timespec expiration, // first expiration... struct timespec period, // ...thereafter increment BREventAlarmId identifier) { return (BREventAlarm) { .type = ALARM_PERIODIC, .identifier = identifier, .context = context, .callback = callback, .expiration = expiration, .period = period }; } static BREventAlarm alarmCreate (BREventAlarmContext context, BREventAlarmCallback callback, struct timespec expiration, BREventAlarmId identifier) { return (BREventAlarm) { .type = ALARM_ONE_SHOT, .identifier = identifier, .context = context, .callback = callback, .expiration = expiration, .period = { .tv_sec = 0, .tv_nsec = 0 } }; } static int alarmIsPeriodic (BREventAlarm *alarm) { return ALARM_PERIODIC == alarm->type; } static void alarmPeriodUpdate (BREventAlarm *alarm) { if (alarmIsPeriodic(alarm)) { timespecInc(&alarm->expiration, &alarm->period); } } static void alarmExpire (BREventAlarm *alarm, BREventAlarmClock clock) { if (NULL != alarm->callback) alarm->callback (alarm->context, alarm->expiration, clock); } /** */ static void alarmClockAssertRecovery (BREventAlarmClock clock); struct BREventAlarmClock { /// Identifier of the next alarm created. BREventAlarmId identifier; /// An BRArrayOf alarms, sorted by alarm.expiration ascending. BREventAlarm *alarms; /// The time of the next timeout struct timespec timeout; // Thread pthread_t thread; pthread_cond_t cond; pthread_mutex_t lock; pthread_mutex_t lockOnStartStop; int threadQuit; }; extern void alarmClockCreateIfNecessary (int start) { if (NULL == alarmClock) alarmClock = alarmClockCreate(); if (start) alarmClockStart(alarmClock); } extern BREventAlarmClock alarmClockCreate (void) { BREventAlarmClock clock = calloc (1, sizeof (struct BREventAlarmClock)); clock->identifier = ALARM_ID_NONE; array_new(clock->alarms, 5); // Create the PTHREAD CONDition variable { pthread_condattr_t attr; pthread_condattr_init(&attr); pthread_cond_init(&clock->cond, &attr); pthread_condattr_destroy(&attr); } // Create the PTHREAD LOCK variable { // The cacheLock is a normal, non-recursive lock pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL); pthread_mutex_init(&clock->lock, &attr); pthread_mutexattr_destroy(&attr); } // Create the PTHREAD LOCK-ON-START-STOP variable { // The cacheLock is a normal, non-recursive lock pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL); pthread_mutex_init(&clock->lockOnStartStop, &attr); pthread_mutexattr_destroy(&attr); } // No thread. clock->thread = PTHREAD_NULL; BRAssertDefineRecovery ((BRAssertRecoveryInfo) clock, (BRAssertRecoveryHandler) alarmClockAssertRecovery); return clock; } extern void alarmClockDestroy (BREventAlarmClock clock) { alarmClockStop(clock); BRAssertRemoveRecovery((BRAssertRecoveryInfo) clock); assert (PTHREAD_NULL == clock->thread); pthread_cond_destroy(&clock->cond); pthread_mutex_destroy(&clock->lock); pthread_mutex_destroy(&clock->lockOnStartStop); array_free (clock->alarms); if (clock == alarmClock) free (alarmClock); alarmClock = NULL; } static void alarmClockInsertAlarm (BREventAlarmClock clock, BREventAlarm alarm) { int count = (int) array_count (clock->alarms); int index = count; for (; index > 0; index--) { // If alarm.expiration is not less than 'alarm at index-1', then insert alarm at index if (-1 != timespecCompare(&alarm.expiration, &clock->alarms[index - 1].expiration)) break; } array_insert (clock->alarms, index, alarm); } typedef void* (*ThreadRoutine) (void*); static void * alarmClockThread (BREventAlarmClock clock) { #if defined (__DARWIN__) pthread_setname_np("Core Ethereum Alarm Clock"); #else pthread_setname_np(clock->thread, "Core Ethereum Alarm Clock"); #endif pthread_mutex_lock(&clock->lock); clock->threadQuit = 0; while (!clock->threadQuit) { // Set the next timeout - based on an existing alarm or 'forever in the future' clock->timeout = (array_count(clock->alarms) > 0 ? clock->alarms[0].expiration : (struct timespec) { .tv_sec = LONG_MAX, .tv_nsec = 0 }); switch (pthread_cond_timedwait (&clock->cond, &clock->lock, &clock->timeout)) { case ETIMEDOUT: { // If we timed-out, then get the alarm that has expired... BREventAlarm alarm = clock->alarms[0]; // ... and remove it from the clock's alarms (for now; if periodic, add it back) array_rm (clock->alarms, 0); // Expire the alarm - invokes the callback. alarmExpire(&alarm, clock); // If periodic, update the alarm expiration and reinsert if (alarmIsPeriodic(&alarm)) { alarmPeriodUpdate(&alarm); alarmClockInsertAlarm(clock, alarm); } break; } default: // Update clock->timeout (above, presumably an alarm was added) and wait again. // Or clock->threadQuit is set. break; } } // Requires as `cond_wait` takes its mutex when signalled. pthread_mutex_unlock(&clock->lock); return NULL; } extern void alarmClockStart (BREventAlarmClock clock) { pthread_mutex_lock(&clock->lockOnStartStop); if (PTHREAD_NULL == clock->thread) { pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); pthread_attr_setstacksize(&attr, PTHREAD_STACK_SIZE); pthread_create(&clock->thread, &attr, (ThreadRoutine) alarmClockThread, clock); pthread_attr_destroy(&attr); } pthread_mutex_unlock(&clock->lockOnStartStop); } extern void alarmClockStop (BREventAlarmClock clock) { pthread_mutex_lock(&clock->lockOnStartStop); if (PTHREAD_NULL != clock->thread) { pthread_mutex_lock(&clock->lock); // ensure this for restart. clock->threadQuit = 1; pthread_cond_signal(&clock->cond); pthread_mutex_unlock(&clock->lock); // ensure this for restart. pthread_join(clock->thread, NULL); // A mini-race here? clock->thread = PTHREAD_NULL; } pthread_mutex_unlock(&clock->lockOnStartStop); } extern int alarmClockIsRunning (BREventAlarmClock clock) { return PTHREAD_NULL != clock->thread; } static void alarmClockAssertRecovery (BREventAlarmClock clock) { alarmClockStop(clock); pthread_mutex_lock(&clock->lockOnStartStop); array_clear(clock->alarms); pthread_mutex_unlock(&clock->lockOnStartStop); } extern BREventAlarmId alarmClockAddAlarmPeriodic (BREventAlarmClock clock, BREventAlarmContext context, BREventAlarmCallback callback, struct timespec period) { pthread_mutex_lock(&clock->lock); BREventAlarmId identifier = ++clock->identifier; alarmClockInsertAlarm(clock, alarmCreatePeriodic(context, callback, getTime(), period, identifier)); // Having modified `alarms` we need to compute a new 'next expiration' pthread_cond_signal(&clock->cond); pthread_mutex_unlock(&clock->lock); return identifier; } extern BREventAlarmId alarmClockAddAlarm (BREventAlarmClock clock, BREventAlarmContext context, BREventAlarmCallback callback, struct timespec expiration) { pthread_mutex_lock(&clock->lock); BREventAlarmId identifier = ++clock->identifier; alarmClockInsertAlarm(clock, alarmCreate(context, callback, expiration, identifier)); // Having modified `alarms` we need to compute a new 'next expiration' pthread_cond_signal(&clock->cond); pthread_mutex_unlock(&clock->lock); return identifier; } extern void alarmClockRemAlarm (BREventAlarmClock clock, BREventAlarmId identifier) { pthread_mutex_lock(&clock->lock); for (int index = 0; index < array_count (clock->alarms); index++) if (identifier == clock->alarms[index].identifier) { array_rm(clock->alarms, index); break; } // Having modified `alarms` we need to compute a new 'next expiration' pthread_cond_signal(&clock->cond); pthread_mutex_unlock(&clock->lock); } extern int alarmClockHasAlarm (BREventAlarmClock clock, BREventAlarmId identifier) { int hasAlarm = 0; pthread_mutex_lock(&clock->lock); for (int index = 0; index < array_count (clock->alarms); index++) if (identifier == clock->alarms[index].identifier) { hasAlarm = 1; break; } pthread_mutex_unlock(&clock->lock); return hasAlarm; }
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/WalletCore/Mnemonic.h
<gh_stars>10-100 // Copyright (c) 2012-2018 The Elastos Open Source Project // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef __ELASTOS_SDK_MNEMONICS_H__ #define __ELASTOS_SDK_MNEMONICS_H__ #include <Common/uint256.h> #include <string> #include <boost/filesystem.hpp> namespace Elastos { namespace ElaWallet { class Mnemonic { public: enum WordCount { WORDS_12 = 12, WORDS_15 = 15, WORDS_18 = 18, WORDS_21 = 21, WORDS_24 = 24 }; public: Mnemonic(const boost::filesystem::path &rootPath); std::string Create(const std::string &language, WordCount words = WORDS_12) const; bool Validate(const std::string &mnemonic) const; uint512 DeriveSeed(const std::string &mnemonic, const std::string &passphrase) const; private: void LoadPath(const boost::filesystem::path &filePath, std::vector<std::string> &wordLists) const; private: boost::filesystem::path _rootPath; }; } } #endif //__ELASTOS_SDK_MNEMONICS_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/les/BREthereumLESRandom.c
<filename>ThirdParty/breadwallet-core/ethereum/les/BREthereumLESRandom.c // // BREthereumRandom.c // breadwallet // // Created by <NAME> on 4/24/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // // See the LICENSE file at the project root for license information. // See the CONTRIBUTORS file at the project root for a list of contributors. #include <pthread.h> #include <stdlib.h> #include <unistd.h> #include <sys/time.h> #include <assert.h> #include "support/BRCrypto.h" #include "BREthereumLESRandom.h" #define KECCAK_HASH_SIZE 32 #define NONCE_SIZE 8 /* * * BREthereumRandomRecord contains fields needed by hmac-drbg */ struct BREthereumLESRandomRecord { uint8_t k[KECCAK_HASH_SIZE]; uint8_t v[KECCAK_HASH_SIZE]; }; // // Public functions // extern BREthereumLESRandomContext randomCreate(const void *seed, size_t seedLen) { BREthereumLESRandomContext ctx = (BREthereumLESRandomContext) calloc(1, sizeof(struct BREthereumLESRandomRecord)); uint32_t currTime = ((uint32_t)time(NULL)); uint32_t curPid = (uint32_t)getpid(); uint8_t nonce[NONCE_SIZE]; nonce[0] = (currTime >> 24) & 0xFF; nonce[1] = (currTime >> 16) & 0xFF; nonce[2] = (currTime >> 8) & 0xFF; nonce[3] = currTime & 0xFF; nonce[4] = (curPid >> 24) & 0xFF; nonce[5] = (curPid >> 16) & 0xFF; nonce[6] = (curPid >> 8) & 0xFF; nonce[7] = curPid & 0xFF; // hmac-drbg with no prediction resistance or additional input // K and V must point to buffers of size hashLen, and ps (personalization string) may be NULL // to generate additional drbg output, use K and V from the previous call, and set seed, nonce and ps to NULL uint8_t dummy; //Run the DRB intially to set the K and V for subsequent calls to random context BRHMACDRBG(&dummy, 0, ctx->k, ctx->v, BRKeccak256, KECCAK_HASH_SIZE, seed, seedLen, nonce, NONCE_SIZE, NULL, 0); return ctx; } extern void randomRelease(BREthereumLESRandomContext ctx) { free(ctx); } extern void randomGenData(BREthereumLESRandomContext ctx, uint8_t* data, size_t dataSize) { BRHMACDRBG(data, dataSize, ctx->k, ctx->v, BRKeccak256, KECCAK_HASH_SIZE, NULL, 0, NULL, 0, NULL, 0); } extern void randomGenPriKey(BREthereumLESRandomContext ctx, BRKey* key) { assert(key != NULL); memset (key, 0, sizeof(BRKey)); UInt256 secret; BRHMACDRBG(secret.u8, 32, ctx->k, ctx->v, BRKeccak256, KECCAK_HASH_SIZE, NULL, 0, NULL, 0, NULL, 0); BRKeySetSecret(key, &secret, 0); var_clean(&secret); } extern void randomGenUInt256(BREthereumLESRandomContext ctx, UInt256* out) { BRHMACDRBG(out->u8, 32, ctx->k, ctx->v, BRKeccak256, KECCAK_HASH_SIZE, NULL, 0, NULL, 0, NULL, 0); }
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Ethereum/EthereumTransfer.h
/* * EthereumTransaction * * Created by <NAME> <<EMAIL>> on 3/20/18. * Copyright (c) 2018 Breadwinner AG. All right reserved. * Copyright (c) 2020 Elastos Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef __ELASTOS_SPVSDK_ETHEREUMTRANSFER_H__ #define __ELASTOS_SPVSDK_ETHEREUMTRANSFER_H__ #include "ReferenceWithDefaultUnit.h" #include <ethereum/ewm/BREthereumTransfer.h> #include <boost/shared_ptr.hpp> namespace Elastos { namespace ElaWallet { class EthereumTransfer : public ReferenceWithDefaultUnit { public: EthereumTransfer(EthereumEWM *ewm, BREthereumTransfer transfer, EthereumAmount::Unit unit); ~EthereumTransfer(); public: BREthereumTransfer getRaw() const; public: bool isConfirmed() const; bool isSubmitted() const; bool isErrored() const; std::string getSourceAddress() const; std::string getTargetAddress() const; std::string getIdentifier() const; std::string getOriginationTransactionHash() const; // Amount std::string getAmount() const; std::string getAmount(EthereumAmount::Unit unit) const; std::string getFee() const; std::string getFee(EthereumAmount::Unit unit) const; std::string getGasPrice() const; std::string getGasPrice(EthereumAmount::Unit unit) const; uint64_t getGasLimit() const; uint64_t getGasUsed() const; // Nonce uint64_t getNonce() const; // Block Number, Timestamp uint64_t getBlockNumber() const; uint64_t getBlockTimestamp() const; uint64_t getBlockConfirmations() const; std::string getErrorDescription() const; }; typedef boost::shared_ptr<EthereumTransfer> EthereumTransferPtr; typedef boost::weak_ptr<EthereumTransfer> EthereumTransferWeakPtr; } } #endif
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/base/BREthereumBase.h
// // BREthereumBase // breadwallet-core Ethereum // // Created by <NAME> on 3/22/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // // See the LICENSE file at the project root for license information. // See the CONTRIBUTORS file at the project root for a list of contributors. #ifndef BR_Ethereum_Base_H #define BR_Ethereum_Base_H #include "support/BRArray.h" #include "support/BRSet.h" #include "ethereum/util/BRUtil.h" #include "ethereum/rlp/BRRlp.h" // All 'base' #include "BREthereumLogic.h" #include "BREthereumEther.h" #include "BREthereumGas.h" #include "BREthereumHash.h" #include "BREthereumData.h" #include "BREthereumAddress.h" #include "BREthereumSignature.h" #ifdef __cplusplus extern "C" { #endif #define REPEAT(index, count) \ for (size_t index = 0, __indexLimit = (size_t) (count); index < __indexLimit; index++) #define OwnershipGiven #define OwnershipKept typedef uint64_t BREthereumTimestamp; // A Unix time #define ETHEREUM_TIMESTAMP_UNKNOWN ((uint64_t) 0) /** * An Ethereum RLP type is an enumeration of the RLP encoding types. * * Four types are defined: the 'network' type produces an encoding consistent with the Etherum * specification. The 'archive' types produces a network encoding w/ some added values needed for * archival (aka persistent) storage. The 'unsigned' type refers to a non-network transaction * encoding suitable for signing. The 'signed' type is an alias for 'network' and is used to * contrast with the 'unsigned' type. */ typedef enum { RLP_TYPE_NETWORK, RLP_TYPE_ARCHIVE, RLP_TYPE_TRANSACTION_UNSIGNED, RLP_TYPE_TRANSACTION_SIGNED = RLP_TYPE_NETWORK, } BREthereumRlpType; /** * An Ethereum Sync mode specifies how an EWM interfaces with the Ethereum P2P network or with 'BRD * Server Assisted' interfaces) to determine a User's transfers. * * There are four modes; they differ in the extent of BRD vs P2P interaction. */ typedef enum { /** * Use the BRD backend for all Core blockchain state. The BRD backend provides: account state * (balance + nonce), transactions, logs, block chain head number, etc. (The BRD backend * offers an etherscan.io-like HTTP interface). The BRD backend includes a 'submit transaction' * interface. */ BRD_ONLY, /* * Use the BRD backend for everything other than 'submit transaction' */ BRD_WITH_P2P_SEND, /** * We'll use the BRD endpoint to identiy blocks of interest based on ETH and TOK transfer * where our addres is the SOURCE or TARGET. We'll only process blocks from the last N (~ 2000) * blocks in the chain. */ P2P_WITH_BRD_SYNC, /** * We'll be willing to do a complete block chain sync, even starting at block zero. We'll * use our 'N-ary Search on Account Changes' to perform the sync effectively. We'll use the * BRD endpoint to augment the 'N-Ary Search' to find TOK transfers where our address is the * SOURCE. */ P2P_ONLY } BREthereumMode; /** * An Ehtereum Sync Interest specifies what a 'BRD Service Assisted' mode sync shoul provide data * for. When query BRD services we can be interested in blocks where the User's account/address * appears in {transactions, logs} x {source, target}. */ typedef enum { CLIENT_GET_BLOCKS_NODE = 0, CLIENT_GET_BLOCKS_TRANSACTIONS_AS_SOURCE = (1 << 0), CLIENT_GET_BLOCKS_TRANSACTIONS_AS_TARGET = (1 << 1), CLIENT_GET_BLOCKS_LOGS_AS_SOURCE = (1 << 2), CLIENT_GET_BLOCKS_LOGS_AS_TARGET = (1 << 3) } BREthereumSyncInterest; /** * An Ethereum Sync Interest Set is an 'option set' of sync interests. */ typedef unsigned int BREthereumSyncInterestSet; static inline int // 1 if match; 0 if not syncInterestMatch(BREthereumSyncInterestSet interests, BREthereumSyncInterest interest) { return interests & interest; } /** * An Ethereum Transfer Status is an enumeration of a transfer's states/status. * * A transfer status extends the 'Ethereum Transaction Status' (which is defined in the Ethereum * specfication) to include more 'life cycle' events such as 'created', 'cancelled, 'replaced' and * 'deleted'. Thus a transfer status is IOS/Android application focused - not P2P network focused. */ typedef enum { /** * Created: transfer created in local memory */ TRANSFER_STATUS_CREATED, /** * Submitted: transfer submitted */ TRANSFER_STATUS_SUBMITTED, /** * Included: transfer is already included in the canonical chain. data contains an * RLP-encoded [blockHash: B_32, blockNumber: P, txIndex: P] structure. */ TRANSFER_STATUS_INCLUDED, /** * Error: transfer sending failed. data contains a text error message */ TRANSFER_STATUS_ERRORED, /** * Cancelled */ TRANSFER_STATUS_CANCELLED, /** * Replaced */ TRANSFER_STATUS_REPLACED, /** * Deleted */ TRANSFER_STATUS_DELETED } BREthereumTransferStatus; #ifdef __cplusplus } #endif #endif /* BR_Ethereum_Base_H */
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/ewm/BREthereumBase.h
// // BREthereumBase.h // BRCore // // Created by <NAME> on 11/19/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // #ifndef BREthereumBase_h #define BREthereumBase_h #include "ethereum/base/BREthereumBase.h" /** * An Ethereum Account holds the public key data associated with a User's 'BIP-39 Paper Key'. * * The account provides the ethereum address (in both string and byte form) and the nonce. (The * account nonce represent the number of ethereum transactions originated by the account; it is * monotonically increasing and is used to guard against double spends.) As per the Ethereum * specification and unlike bitcoin, the account has a single address. */ typedef struct BREthereumAccountRecord *BREthereumAccount; /** * An Ethereum Transfer represents an exchange of a asset between a source and a target address. * * The ethereum specification does not define a 'transfer'; however, the specificaion does define * `transaction` and `log` and depending on the 'Smart Contract' a `log` can represent an * exchange (such as for ERC20). An Ethereum Transfer is thus an abstraction over a 'transaction' * and a 'log' (for such an exchange) * * An Ethereum Transfer has both a source and a target address at least one of which will be the * address for the User's account. A transfer includes an amount. (The amount is a value in a * specfiic currency - ETH, ERC20 token). A transfer includes a `feeBasis` and a `gasEstimate` * where are Ethereum specific concepts used to estimate/compute the fee for the transfers. * * If the Ethereum Transfer is created by the User, then it has an `originatingTransaction`. This * transaction is the submission the the Ethereum P2P network needed to accomplish the transfer. * * Once the transfer has been submitted it will have a 'Transfer Basis'. The basis is represents * the outcome of the submission - it will be either a transaction or a log with an appropriate * status (such as 'included' or 'errored') * * A transfer includes a status. */ typedef struct BREthereumTransferRecord *BREthereumTransfer; /** * An Ethereum Wallet holds a balance and the transfers applicable to a specific currency in a * User's account. A User likely has multiple wallets - such as for ETH and BRD - all of which are * associated with a single account. * * A wallet references the User's account and the account's primary address. * * A wallet has an optional Ethereum Token'. If present, the wallet holds transfers for an ERC20 * (and perhaps other Smart Contract) tokens. If not present, the wallet holds ETH transfers. * * A wallet is associated with a network. Thus, a single account might have different wallets for * different networks - such as 'foundation', 'ropsten' and 'rinkeby' (which is, in fact, only a * testing feature). * * A wallet holds a default gas price and a default gas limit. These are used when creating a * transfer. Different assets (ETH, BRC, etc) require different amounts of gas to execute on the * Ethereum P2P network. Different assets might demand a different gas price (essentially the * speed at which the P2P network includes the transfer). These defaults can be set based on the * needs of the wallet's asset. * * A wallet holds all the transfers - both with User being the source and/or the target. Depending * on the asset the transfers could be based on a transaction or a log. It should be the case that * the balance is the sum total of the transfers; however, there is an important caveat - if the * wallet represents a token asset, then the fees for a transfer apply to the ETH wallet. */ typedef struct BREthereumWalletRecord *BREthereumWallet; /** * An Ethereum Wallet Manager (EWM) manages all the wallets associated with a single account on a * specific Ethereum P2P network. An EWM is the sole/primary interface between IOS and Android * applications with Ethereum wallets. * * An EWM defines a 'client' with a set of callback interfaces that must be implemented by the * IOS and Android applications. These callbacks privide functionality that is architecturally * inappropriate to include in Core code - such as HTTP queries which use libraries that are not * and will not be part of Core code. * * An EWM is associated with a particular account and a network. There may be multiple EWMs with * one per network - such as one EWM for 'foundation', 'ropsten' and 'rinkeby' (essentially a * testing feature). All EWMs are expected to share a single account - although the interface * allows a per EWM account. * * An EWM holds multipe wallets with one ETH wallet and zero or more ERC20 (or other smart * contract) token wallets. Generally wallets for tokens are created as needed - specifically while * scanning the block chain for logs applicable to the account; any log representing an ERC20 * transfer for a known token will produce a new wallet. The client interface includes a callback * to announce new wallets. * * An EWM stores persistent data, such as for blocks, peers, transactions and logs using a * BRFileService. * * An EWM runs in its own pthread. Interactions with the EWM are either asynchronous or blocking * and protected by a mutex in the EWM. Generally blocking functions are those that query EWM state * whereas asynchronous functions are those computing or updating something. An asynchronous * function always leads to a client callback of some kind to announce the result of the * computation. * * An EWM has a specific mode. The mode determines how the EWM scans the block chain. If the EWM * uses the P2P network (as opposed to a fully 'BRD Service Assisted' mode), then the EWM references * a 'BCS' (block chain slice) object through with all P2P interactions proceed. */ typedef struct BREthereumEWMRecord *BREthereumEWM; typedef enum { FEE_BASIS_NONE, FEE_BASIS_GAS } BREthereumFeeBasisType; typedef struct { BREthereumFeeBasisType type; union { struct { BREthereumGas limit; BREthereumGasPrice price; } gas; } u; } BREthereumFeeBasis; extern BREthereumFeeBasis feeBasisCreate (BREthereumGas limit, BREthereumGasPrice price); // // Errors - Right Up Front - 'The Emperor Has No Clothes' ?? // typedef enum { SUCCESS, // Reference access ERROR_UNKNOWN_NODE, ERROR_UNKNOWN_TRANSACTION, ERROR_UNKNOWN_ACCOUNT, ERROR_UNKNOWN_WALLET, ERROR_UNKNOWN_BLOCK, ERROR_UNKNOWN_LISTENER, // Node ERROR_NODE_NOT_CONNECTED, // Transfer ERROR_TRANSACTION_HASH_MISMATCH, ERROR_TRANSACTION_SUBMISSION, // Acount // Wallet // Block // Listener // Numeric ERROR_NUMERIC_PARSE, } BREthereumStatus; #endif /* BREthereumBase_h */
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/les/BREthereumProvision.c
// // BREthereumProvision.c // Core // // Created by <NAME> on 9/4/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // // See the LICENSE file at the project root for license information. // See the CONTRIBUTORS file at the project root for a list of contributors. #include "support/BRAssert.h" #include "BREthereumProvision.h" static size_t minimum (size_t x, size_t y) { return x < y ? x : y; } extern const char * provisionErrorGetReasonName (BREthereumProvisionErrorReason reason) { static const char *names[] = { "Node Inactive", "Node Data" }; return names[reason]; } extern BREthereumLESMessageIdentifier provisionGetMessageLESIdentifier (BREthereumProvisionType type) { switch (type) { case PROVISION_BLOCK_HEADERS: return LES_MESSAGE_GET_BLOCK_HEADERS; case PROVISION_BLOCK_PROOFS: return LES_MESSAGE_GET_HEADER_PROOFS;; case PROVISION_BLOCK_BODIES: return LES_MESSAGE_GET_BLOCK_BODIES; case PROVISION_TRANSACTION_RECEIPTS: return LES_MESSAGE_GET_RECEIPTS; case PROVISION_ACCOUNTS: return LES_MESSAGE_GET_PROOFS_V2; case PROVISION_TRANSACTION_STATUSES: return LES_MESSAGE_GET_TX_STATUS; case PROVISION_SUBMIT_TRANSACTION: return LES_MESSAGE_SEND_TX2; } } extern BREthereumPIPRequestType provisionGetMessagePIPIdentifier (BREthereumProvisionType type) { switch (type) { case PROVISION_BLOCK_HEADERS: return PIP_REQUEST_HEADERS; case PROVISION_BLOCK_PROOFS: return PIP_REQUEST_HEADER_PROOF; case PROVISION_BLOCK_BODIES: return PIP_REQUEST_BLOCK_BODY; case PROVISION_TRANSACTION_RECEIPTS: return PIP_REQUEST_BLOCK_RECEIPTS; case PROVISION_ACCOUNTS: return PIP_REQUEST_ACCOUNT; case PROVISION_TRANSACTION_STATUSES: return PIP_REQUEST_TRANSACTION_INDEX; case PROVISION_SUBMIT_TRANSACTION: return -1; /*assert (0); */ } } extern const char * provisionGetTypeName (BREthereumProvisionType type) { static const char *names[] = { "Headers", "Proofs", "Bodies", "Receipts", "Accounts", "Statuses", "Submit" }; return names[type]; } /// MARK: - LES static BREthereumMessage provisionCreateMessageLES (BREthereumProvision *provisionMulti, size_t messageContentLimit, size_t messageIdBase, size_t index) { uint64_t messageId = messageIdBase + index; switch (provisionMulti->type) { case PROVISION_BLOCK_HEADERS: { BREthereumProvisionHeaders *provision = &provisionMulti->u.headers; if (NULL == provision->headers) { array_new (provision->headers, provision->limit); array_set_count (provision->headers, provision->limit); } uint64_t start = provision->start + index * messageContentLimit; size_t count = provision->limit - index * messageContentLimit; return (BREthereumMessage) { MESSAGE_LES, { .les = { LES_MESSAGE_GET_BLOCK_HEADERS, { .getBlockHeaders = { messageId, 1, // use 'number' { .number = start }, (uint32_t) minimum (count, messageContentLimit), provision->skip, ETHEREUM_BOOLEAN_IS_TRUE (provision->reverse) }}}} }; } case PROVISION_BLOCK_PROOFS: { BREthereumProvisionProofs *provision = &provisionMulti->u.proofs; BRArrayOf(uint64_t) numbers = provision->numbers; size_t numbersCount = array_count(numbers); if (NULL == provision->proofs) { array_new (provision->proofs, numbersCount); array_set_count(provision->proofs, numbersCount); } BRArrayOf(uint64_t) messageBlkNumbers; array_new (messageBlkNumbers, messageContentLimit); BRArrayOf(uint64_t) messageChtNumbers; array_new (messageChtNumbers, messageContentLimit); size_t numbersOffset = index * messageContentLimit; for (size_t i = 0; i < minimum (messageContentLimit, numbersCount - numbersOffset); i++) { uint64_t blkNumber = numbers[(numbersOffset + i)]; uint64_t chtNumber = messageLESGetChtNumber(blkNumber); array_add (messageBlkNumbers, blkNumber); array_add (messageChtNumbers, chtNumber); } return (BREthereumMessage) { MESSAGE_LES, { .les = { LES_MESSAGE_GET_HEADER_PROOFS, { .getHeaderProofs = { messageId, messageChtNumbers, messageBlkNumbers }}}} }; } case PROVISION_BLOCK_BODIES: { BREthereumProvisionBodies *provision = &provisionMulti->u.bodies; BRArrayOf(BREthereumHash) hashes = provision->hashes; size_t hashesCount = array_count(hashes); if (NULL == provision->pairs) { array_new (provision->pairs, hashesCount); array_set_count (provision->pairs, hashesCount); } BRArrayOf(BREthereumHash) messageHashes; array_new(messageHashes, messageContentLimit); size_t hashesOffset = index * messageContentLimit; for (size_t i = 0; i < minimum (messageContentLimit, hashesCount - hashesOffset); i++) array_add (messageHashes, hashes[(hashesOffset + i)]); return (BREthereumMessage) { MESSAGE_LES, { .les = { LES_MESSAGE_GET_BLOCK_BODIES, { .getBlockBodies = { messageId, messageHashes }}}} }; } case PROVISION_TRANSACTION_RECEIPTS: { BREthereumProvisionReceipts *provision = &provisionMulti->u.receipts; BRArrayOf(BREthereumHash) hashes = provision->hashes; size_t hashesCount = array_count(hashes); if (NULL == provision->receipts) { array_new (provision->receipts, hashesCount); array_set_count (provision->receipts, hashesCount); } BRArrayOf(BREthereumHash) messageHashes; array_new(messageHashes, messageContentLimit); size_t hashesOffset = index * messageContentLimit; for (size_t i = 0; i < minimum (messageContentLimit, hashesCount - hashesOffset); i++) array_add (messageHashes, hashes[(hashesOffset + i)]); return (BREthereumMessage) { MESSAGE_LES, { .les = { LES_MESSAGE_GET_RECEIPTS, { .getReceipts = { messageId, messageHashes }}}} }; } case PROVISION_ACCOUNTS: { BREthereumProvisionAccounts *provision = &provisionMulti->u.accounts; BREthereumAddress address = provision->address; BRArrayOf(BREthereumHash) hashes = provision->hashes; size_t hashesCount = array_count(hashes); if (NULL == provision->accounts) { array_new (provision->accounts, hashesCount); array_set_count (provision->accounts, hashesCount); } size_t hashesOffset = index * messageContentLimit; BRArrayOf(BREthereumLESMessageGetProofsSpec) specs; array_new (specs, hashesCount); for (size_t i = 0; i < minimum (messageContentLimit, hashesCount - hashesOffset); i++) { BREthereumLESMessageGetProofsSpec spec = { hashes[hashesOffset + i], address, 0, }; array_add (specs, spec); } return (BREthereumMessage) { MESSAGE_LES, { .les = { LES_MESSAGE_GET_PROOFS, { .getProofs = { messageId, specs }}}} }; } case PROVISION_TRANSACTION_STATUSES: { BREthereumProvisionStatuses *provision = &provisionMulti->u.statuses; BRArrayOf(BREthereumHash) hashes = provision->hashes; size_t hashesCount = array_count(hashes); if (NULL == provision->statuses) { array_new (provision->statuses, hashesCount); array_set_count (provision->statuses, hashesCount); } BRArrayOf(BREthereumHash) messageHashes; array_new(messageHashes, messageContentLimit); size_t hashesOffset = index * messageContentLimit; for (size_t i = 0; i < minimum (messageContentLimit, hashesCount - hashesOffset); i++) array_add (messageHashes, hashes[(hashesOffset + i)]); return (BREthereumMessage) { MESSAGE_LES, { .les = { LES_MESSAGE_GET_TX_STATUS, { .getTxStatus = { messageId, messageHashes }}}} }; } case PROVISION_SUBMIT_TRANSACTION: { BREthereumProvisionSubmission *provision = &provisionMulti->u.submission; switch (index) { case 0: { BRArrayOf(BREthereumTransaction) transactions; array_new (transactions, 1); // TODO: We don't have a way to avoid consuming 'transactions' - so copy // the transaction thereby allow a complete release. array_add (transactions, transactionCopy (provision->transaction)); return (BREthereumMessage) { MESSAGE_LES, { .les = { LES_MESSAGE_SEND_TX2, { .sendTx2 = { messageId, transactions }}}} }; } case 1: { BRArrayOf(BREthereumHash) hashes; array_new (hashes, 1); array_add (hashes, transactionGetHash (provision->transaction)); return (BREthereumMessage) { MESSAGE_LES, { .les = { LES_MESSAGE_GET_TX_STATUS, { .getTxStatus = { messageId, hashes }}}} }; } default: BRFail(); } } } } static BREthereumProvisionStatus provisionHandleMessageLES (BREthereumProvision *provisionMulti, OwnershipGiven BREthereumLESMessage message, size_t messageContentLimit, size_t messageIdBase) { BREthereumProvisionStatus status = PROVISION_SUCCESS; switch (provisionMulti->type) { case PROVISION_BLOCK_HEADERS: { assert (LES_MESSAGE_BLOCK_HEADERS == message.identifier); BREthereumProvisionHeaders *provision = &provisionMulti->u.headers; BRArrayOf(BREthereumBlockHeader) provisionHeaders = provision->headers; BREthereumProvisionIdentifier identifier = messageLESGetRequestId (&message); BRArrayOf(BREthereumBlockHeader) messageHeaders; messageLESBlockHeadersConsume(&message.u.blockHeaders, &messageHeaders); if (0 == array_count(messageHeaders)) status = PROVISION_ERROR; else { size_t offset = messageContentLimit * (identifier - messageIdBase); for (size_t index = 0; index < array_count(messageHeaders); index++) provisionHeaders[offset + index] = messageHeaders[index]; } array_free (messageHeaders); break; } case PROVISION_BLOCK_PROOFS: { assert (LES_MESSAGE_HEADER_PROOFS == message.identifier); BREthereumProvisionProofs *provision = &provisionMulti->u.proofs; BRArrayOf(BREthereumBlockHeaderProof) provisionProofs = provision->proofs; BREthereumProvisionIdentifier identifier = messageLESGetRequestId(&message); BRArrayOf(BREthereumBlockHeader) messageHeaders; BRArrayOf(BREthereumMPTNodePath) messagePaths; messageLESHeaderProofsConsume (&message.u.headerProofs, &messageHeaders, &messagePaths); if (0 == array_count(messageHeaders)) status = PROVISION_ERROR; else { BRRlpCoder coder = rlpCoderCreate(); size_t offset = messageContentLimit * (identifier - messageIdBase); for (size_t index = 0; index < array_count(messageHeaders); index++) { //BREthereumBlockHeader header = messageHeaders[index]; BREthereumMPTNodePath path = messagePaths[index]; // Result location BREthereumBlockHeaderProof *proof = &provisionProofs[offset + index]; // Key for MPT proof BREthereumData key = mptKeyGetFromUInt64 (provision->numbers[offset + index]); BREthereumBoolean isValid = ETHEREUM_BOOLEAN_FALSE; BRRlpData data = mptNodePathGetValue (path, key, &isValid); if (ETHEREUM_BOOLEAN_IS_TRUE (isValid)) { // When valid extract [hash, totalDifficulty] from the MPT proof's value BRRlpItem item = rlpGetItem(coder, data); size_t itemsCount = 0; const BRRlpItem *items = rlpDecodeList (coder, item, &itemsCount); assert (2 == itemsCount); proof->hash = hashRlpDecode(items[0], coder); proof->totalDifficulty = rlpDecodeUInt256 (coder, items[1], 1); rlpReleaseItem(coder, item); rlpDataRelease(data); } else { proof->hash = EMPTY_HASH_INIT; proof->totalDifficulty = UINT256_ZERO; } dataRelease(key); } rlpCoderRelease(coder); } mptNodePathsRelease(messagePaths); blockHeadersRelease(messageHeaders); break; } case PROVISION_BLOCK_BODIES: { assert (LES_MESSAGE_BLOCK_BODIES == message.identifier); BREthereumProvisionBodies *provision = &provisionMulti->u.bodies; BRArrayOf(BREthereumBlockBodyPair) provisionPairs = provision->pairs; BREthereumProvisionIdentifier identifier = messageLESGetRequestId (&message); BRArrayOf(BREthereumBlockBodyPair) messagePairs; messageLESBlockBodiesConsume (&message.u.blockBodies, &messagePairs); if (0 == array_count(messagePairs)) status = PROVISION_ERROR; else { size_t offset = messageContentLimit * (identifier - messageIdBase); for (size_t index = 0; index < array_count(messagePairs); index++) provisionPairs[offset + index] = messagePairs[index]; } array_free (messagePairs); break; } case PROVISION_TRANSACTION_RECEIPTS: { assert (LES_MESSAGE_RECEIPTS == message.identifier); BREthereumProvisionReceipts *provision = &provisionMulti->u.receipts; BRArrayOf(BRArrayOf(BREthereumTransactionReceipt)) provisionPairs = provision->receipts; BREthereumProvisionIdentifier identifier = messageLESGetRequestId (&message); BRArrayOf(BREthereumLESMessageReceiptsArray) messagePairs; messageLESReceiptsConsume (&message.u.receipts, &messagePairs); if (0 == array_count(messagePairs)) status = PROVISION_ERROR; else { size_t offset = messageContentLimit * (identifier - messageIdBase); for (size_t index = 0; index < array_count(messagePairs); index++) provisionPairs[offset + index] = messagePairs[index].receipts; } array_free (messagePairs); break; } case PROVISION_ACCOUNTS: { assert (LES_MESSAGE_PROOFS == message.identifier); BREthereumProvisionAccounts *provision = &provisionMulti->u.accounts; BREthereumHash hash = addressGetHash(provision->address); BREthereumData key = { sizeof(BREthereumHash), hash.bytes }; // We'll fill this - at the proper index if a multiple provision. BRArrayOf(BREthereumAccountState) provisionAccounts = provision->accounts; BREthereumProvisionIdentifier identifier = messageLESGetRequestId (&message); BRArrayOf(BREthereumMPTNodePath) messagePaths; messageLESProofsConsume(&message.u.proofs, &messagePaths); if (0 == array_count(messagePaths)) status = PROVISION_ERROR; else { // We need a coder to RLP decode the proof's RLP data into an AccountState. We could, // and probably should, pass the coder for LES all the way down here. It is a long // way down... so we'll create one. In fact, this is insufficient, because the LES // coder has network and perhaps other context - although that is not needed here. // // We could add a coder to the BREthereumProvisionAccounts... yes, probably should. BRRlpCoder coder = rlpCoderCreate(); size_t offset = messageContentLimit * (identifier - messageIdBase); for (size_t index = 0; index < array_count(messagePaths); index++) { // We expect, require, one path for each index. A common 'GetProofs' error // is be have an empty array for messagePaths - that is, no proofs and no // non-proofs. That is surely an error (boot the node), but... BREthereumMPTNodePath path = messagePaths[index]; BREthereumBoolean foundValue = ETHEREUM_BOOLEAN_FALSE; BRRlpData data = mptNodePathGetValue (path, key, &foundValue); if (ETHEREUM_BOOLEAN_IS_TRUE(foundValue)) { BRRlpItem item = rlpGetItem (coder, data); provisionAccounts[offset + index] = accountStateRlpDecode (item, coder); rlpReleaseItem (coder, item); } else provisionAccounts[offset + index] = accountStateCreateEmpty(); rlpDataRelease(data); } rlpCoderRelease(coder); } mptNodePathsRelease(messagePaths); break; } case PROVISION_TRANSACTION_STATUSES: { assert (LES_MESSAGE_TX_STATUS == message.identifier); BREthereumProvisionStatuses *provision = &provisionMulti->u.statuses; BRArrayOf(BREthereumTransactionStatus) provisionPairs = provision->statuses; BREthereumProvisionIdentifier identifier = messageLESGetRequestId (&message); BRArrayOf(BREthereumTransactionStatus) messagePairs = message.u.txStatus.stati; messageLESTxStatusConsume (&message.u.txStatus, &messagePairs); if (0 == array_count(messagePairs)) status = PROVISION_ERROR; else { size_t offset = messageContentLimit * (identifier - messageIdBase); for (size_t index = 0; index < array_count(messagePairs); index++) provisionPairs[offset + index] = messagePairs[index]; } array_free (messagePairs); break; } case PROVISION_SUBMIT_TRANSACTION: { assert (LES_MESSAGE_TX_STATUS == message.identifier); BREthereumProvisionSubmission *provision = &provisionMulti->u.submission; provision->status = message.u.txStatus.stati[0]; break; } } messageLESRelease(&message); return status; } /// MARK: - PIP static BREthereumMessage provisionCreateMessagePIP (BREthereumProvision *provisionMulti, size_t messageContentLimit, size_t messageIdBase, size_t index) { uint64_t messageId = messageIdBase + index; switch (provisionMulti->type) { case PROVISION_BLOCK_HEADERS: { BREthereumProvisionHeaders *provision = &provisionMulti->u.headers; if (NULL == provision->headers) { array_new (provision->headers, provision->limit); array_set_count(provision->headers, provision->limit); } uint64_t start = provision->start + index * messageContentLimit; size_t count = provision->limit - index * messageContentLimit; BREthereumPIPRequestInput input = { PIP_REQUEST_HEADERS, { .headers = { 1, { .number = start }, provision->skip, (uint32_t) minimum (count, messageContentLimit), provision->reverse }} }; BRArrayOf(BREthereumPIPRequestInput) inputs; array_new (inputs, 1); array_add (inputs, input); return (BREthereumMessage) { MESSAGE_PIP, { .pip = { PIP_MESSAGE_REQUEST, { .request = { messageId, inputs }}}} }; } case PROVISION_BLOCK_PROOFS: { BREthereumProvisionProofs *provision = &provisionMulti->u.proofs; BRArrayOf(uint64_t) numbers = provision->numbers; size_t numbersCount = array_count(numbers); if (NULL == provision->proofs) { array_new (provision->proofs, numbersCount); array_set_count (provision->proofs, numbersCount); } size_t numbersOffset = index * messageContentLimit; BRArrayOf(BREthereumPIPRequestInput) inputs; array_new (inputs, messageContentLimit); for (size_t i = 0; i < minimum (messageContentLimit, numbersCount - numbersOffset); i++) { BREthereumPIPRequestInput input = { PIP_REQUEST_HEADER_PROOF, { .headerProof = { numbers[numbersOffset + i]}} }; array_add (inputs, input); } return (BREthereumMessage) { MESSAGE_PIP, { .pip = { PIP_MESSAGE_REQUEST, { .request = { messageId, inputs }}}} }; } case PROVISION_BLOCK_BODIES: { BREthereumProvisionBodies *provision = &provisionMulti->u.bodies; BRArrayOf(BREthereumHash) hashes = provision->hashes; size_t hashesCount = array_count(hashes); if (NULL == provision->pairs) { array_new (provision->pairs, hashesCount); array_set_count (provision->pairs, hashesCount); } size_t hashesOffset = index * messageContentLimit; BRArrayOf(BREthereumPIPRequestInput) inputs; array_new (inputs, messageContentLimit); for (size_t i = 0; i < minimum (messageContentLimit, hashesCount - hashesOffset); i++) { BREthereumPIPRequestInput input = { PIP_REQUEST_BLOCK_BODY, { .blockBody = { hashes[hashesOffset + i]}} }; array_add (inputs, input); } return (BREthereumMessage) { MESSAGE_PIP, { .pip = { PIP_MESSAGE_REQUEST, { .request = { messageId, inputs }}}} }; } case PROVISION_TRANSACTION_RECEIPTS: { BREthereumProvisionReceipts *provision = &provisionMulti->u.receipts; BRArrayOf(BREthereumHash) hashes = provision->hashes; size_t hashesCount = array_count(hashes); if (NULL == provision->receipts) { array_new (provision->receipts, hashesCount); array_set_count (provision->receipts, hashesCount); } size_t hashesOffset = index * messageContentLimit; BRArrayOf(BREthereumPIPRequestInput) inputs; array_new (inputs, messageContentLimit); for (size_t i = 0; i < minimum (messageContentLimit, hashesCount - hashesOffset); i++) { BREthereumPIPRequestInput input = { PIP_REQUEST_BLOCK_RECEIPTS, { .blockReceipt = { hashes[hashesOffset + i]}} }; array_add (inputs, input); } return (BREthereumMessage) { MESSAGE_PIP, { .pip = { PIP_MESSAGE_REQUEST, { .request = { messageId, inputs }}}} }; } case PROVISION_ACCOUNTS: { BREthereumProvisionAccounts *provision = &provisionMulti->u.accounts; BREthereumHash addressHash = addressGetHash(provision->address); BRArrayOf(BREthereumHash) hashes = provision->hashes; size_t hashesCount = array_count(hashes); if (NULL == provision->accounts) { array_new (provision->accounts, hashesCount); array_set_count (provision->accounts, hashesCount); } size_t hashesOffset = index * messageContentLimit; BRArrayOf(BREthereumPIPRequestInput) inputs; array_new (inputs, messageContentLimit); for (size_t i = 0; i < minimum (messageContentLimit, hashesCount - hashesOffset); i++) { BREthereumPIPRequestInput input = { PIP_REQUEST_ACCOUNT, { .account = { hashes[hashesOffset + i], addressHash }} }; array_add (inputs, input); } return (BREthereumMessage) { MESSAGE_PIP, { .pip = { PIP_MESSAGE_REQUEST, { .request = { messageId, inputs }}}} }; } case PROVISION_TRANSACTION_STATUSES: { BREthereumProvisionStatuses *provision = &provisionMulti->u.statuses; BRArrayOf(BREthereumHash) hashes = provision->hashes; size_t hashesCount = array_count(hashes); if (NULL == provision->statuses) { array_new (provision->statuses, hashesCount); array_set_count (provision->statuses, hashesCount); } size_t hashesOffset = index * messageContentLimit; BRArrayOf(BREthereumPIPRequestInput) inputs; array_new (inputs, messageContentLimit); for (size_t i = 0; i < minimum (messageContentLimit, hashesCount - hashesOffset); i++) { BREthereumPIPRequestInput input = { PIP_REQUEST_TRANSACTION_INDEX, { .transactionIndex = { hashes[hashesOffset + i]}} }; array_add (inputs, input); } return (BREthereumMessage) { MESSAGE_PIP, { .pip = { PIP_MESSAGE_REQUEST, { .request = { messageId, inputs }}}} }; } case PROVISION_SUBMIT_TRANSACTION: { BREthereumProvisionSubmission *provision = &provisionMulti->u.submission; // We have two messages to submit a transaction, but only one response. The response // needs the proper messageIdentifier in order to be paired with this provision. switch (index) { case 0: { BRArrayOf(BREthereumTransaction) transactions; array_new (transactions, 1); // TODO: We don't have a way to avoid consuming 'transactions' - so copy // the transaction thereby allow a complete release. array_add (transactions, transactionCopy (provision->transaction)); return (BREthereumMessage) { MESSAGE_PIP, { .pip = { PIP_MESSAGE_RELAY_TRANSACTIONS, { .relayTransactions = { transactions }}}} }; } case 1: { BRArrayOf(BREthereumPIPRequestInput) inputs; array_new (inputs, 1); BREthereumPIPRequestInput input = { PIP_REQUEST_TRANSACTION_INDEX, { .transactionIndex = { transactionGetHash (provision->transaction) }} }; array_add (inputs, input); return (BREthereumMessage) { MESSAGE_PIP, { .pip = { PIP_MESSAGE_REQUEST, { .request = { messageId, inputs }}}} }; } default: BRFail(); } } } } static BREthereumProvisionStatus provisionHandleMessagePIP (BREthereumProvision *provisionMulti, OwnershipGiven BREthereumPIPMessage message, size_t messageContentLimit, size_t messageIdBase) { BREthereumProvisionStatus status = PROVISION_SUCCESS; switch (provisionMulti->type) { case PROVISION_BLOCK_HEADERS: { assert (PIP_MESSAGE_RESPONSE == message.type); BREthereumProvisionHeaders *provision = &provisionMulti->u.headers; BRArrayOf(BREthereumBlockHeader) provisionHeaders = provision->headers; BREthereumProvisionIdentifier identifier = messagePIPGetRequestId(&message); BRArrayOf(BREthereumPIPRequestOutput) outputs; messagePIPResponseConsume(&message.u.response, &outputs); // TODO: Not likely. assert (1 == array_count(outputs)); BREthereumPIPRequestOutput output = outputs[0]; assert (PIP_REQUEST_HEADERS == output.identifier); BRArrayOf(BREthereumBlockHeader) messageHeaders = output.u.headers.headers; if (0 == array_count(messageHeaders)) status = PROVISION_ERROR; else { size_t offset = messageContentLimit * (identifier - messageIdBase); for (size_t index = 0; index < array_count(messageHeaders); index++) provisionHeaders[offset + index] = messageHeaders[index]; } array_free (messageHeaders); array_free (outputs); break; } case PROVISION_BLOCK_PROOFS: { BREthereumProvisionProofs *provision = &provisionMulti->u.proofs; BRArrayOf(BREthereumBlockHeaderProof) provisionProofs = provision->proofs; BREthereumProvisionIdentifier identifier = messagePIPGetRequestId(&message); BRArrayOf(BREthereumPIPRequestOutput) outputs = NULL; messagePIPResponseConsume (&message.u.response, &outputs); if (0 == array_count(outputs)) status = PROVISION_ERROR; else { BRRlpCoder coder = rlpCoderCreate(); size_t offset = messageContentLimit * (identifier - messageIdBase); for (size_t index = 0; index < array_count(outputs); index++) { assert (PIP_REQUEST_HEADER_PROOF == outputs[index].identifier); // The MPT 'key' is the RLP encoding of the block number BRRlpItem item = rlpEncodeUInt64(coder, provision->numbers[index], 0); BRRlpData data = rlpGetDataSharedDontRelease (coder, item); BREthereumData key = { data.bytesCount, data.bytes }; BREthereumMPTNodePath path; // = outputs[index].u.headerProof.path; messagePIPRequestHeaderProofOutputConsume (&outputs[index].u.headerProof, &path); if (ETHEREUM_BOOLEAN_IS_TRUE (mptNodePathIsValid (path, key))) { provisionProofs[offset + index].hash = outputs[index].u.headerProof.blockHash; provisionProofs[offset + index].totalDifficulty = outputs[index].u.headerProof.blockTotalDifficulty; } else { provisionProofs[offset + index].hash = EMPTY_HASH_INIT; provisionProofs[offset + index].totalDifficulty = UINT256_ZERO; } rlpReleaseItem (coder, item); mptNodePathRelease (path); } rlpCoderRelease(coder); } array_free (outputs); break; } case PROVISION_BLOCK_BODIES: { BREthereumProvisionBodies *provision = &provisionMulti->u.bodies; BRArrayOf(BREthereumBlockBodyPair) provisionPairs = provision->pairs; BREthereumProvisionIdentifier identifier = messagePIPGetRequestId(&message); BRArrayOf(BREthereumPIPRequestOutput) outputs = NULL; messagePIPResponseConsume(&message.u.response, &outputs); if (0 == array_count(outputs)) status = PROVISION_ERROR; else { size_t offset = messageContentLimit * (identifier - messageIdBase); for (size_t index = 0; index < array_count(outputs); index++) { assert (PIP_REQUEST_BLOCK_BODY == outputs[index].identifier); // This 'consumes' outputs[index] by taking {transactions, headers} provisionPairs[offset + index].transactions = outputs[index].u.blockBody.transactions; provisionPairs[offset + index].uncles = outputs[index].u.blockBody.headers; } } array_free (outputs); break; } case PROVISION_TRANSACTION_RECEIPTS: { BREthereumProvisionReceipts *provision = &provisionMulti->u.receipts; BRArrayOf(BRArrayOf(BREthereumTransactionReceipt)) provisionReceiptsArray = provision->receipts; BREthereumProvisionIdentifier identifier = messagePIPGetRequestId(&message); BRArrayOf(BREthereumPIPRequestOutput) outputs = NULL; messagePIPResponseConsume(&message.u.response, &outputs); if (0 == array_count(outputs)) status = PROVISION_ERROR; else { size_t offset = messageContentLimit * (identifier - messageIdBase); for (size_t index = 0; index < array_count(outputs); index++) { assert (PIP_REQUEST_BLOCK_RECEIPTS == outputs[index].identifier); provisionReceiptsArray[offset + index] = outputs[index].u.blockReceipt.receipts; } } array_free (outputs); break; } case PROVISION_ACCOUNTS: { BREthereumProvisionAccounts *provision = &provisionMulti->u.accounts; BRArrayOf(BREthereumAccountState) provisionAccounts= provision->accounts; BREthereumProvisionIdentifier identifier = messagePIPGetRequestId(&message); BRArrayOf(BREthereumPIPRequestOutput) outputs = NULL; messagePIPResponseConsume(&message.u.response, &outputs); if (0 == array_count(outputs)) status = PROVISION_ERROR; else { size_t offset = messageContentLimit * (identifier - messageIdBase); for (size_t index = 0; index < array_count(outputs); index++) { assert (PIP_REQUEST_ACCOUNT == outputs[index].identifier); provisionAccounts[offset + index] = accountStateCreate (outputs[index].u.account.nonce, etherCreate(outputs[index].u.account.balance), outputs[index].u.account.storageRootHash, outputs[index].u.account.codeHash); } } array_free (outputs); break; } case PROVISION_TRANSACTION_STATUSES: { BREthereumProvisionStatuses *provision = &provisionMulti->u.statuses; BRArrayOf(BREthereumTransactionStatus) provisionStatuses = provision->statuses; BREthereumProvisionIdentifier identifier = messagePIPGetRequestId(&message); BRArrayOf(BREthereumPIPRequestOutput) outputs = NULL; messagePIPResponseConsume(&message.u.response, &outputs); // Parity will utterly drop transaction requests for transactions that have errors, // it seems. If we submit a status request for N transaction, is is possible to // only get back M (< N)? // // Consequently, we'll take a different approach, from the above code, when filling // out the `provisionStatuses`. We'll look at each provision status hash (these are // the expected ones) and match it up with some output. If we don't find an output // then we'll label it queued/unknown something. Except... // // ...there is a problem. The PIPReqeustOutput (of subtype PIPTransactionIndex) does // not include the transaction hash used in the input. So we have no way of matching // up the size_t offset = messageContentLimit * (identifier - messageIdBase); size_t remaining = array_count(provisionStatuses) - offset; size_t limit = minimum (remaining, messageContentLimit); if (limit != array_count(outputs)) { for (size_t index = 0; index < limit; index++) provisionStatuses[offset + index] = transactionStatusCreate(TRANSACTION_STATUS_UNKNOWN); } else { for (size_t index = 0; index < array_count(outputs); index++) { assert (PIP_REQUEST_TRANSACTION_INDEX == outputs[index].identifier); provisionStatuses[offset + index] = transactionStatusCreateIncluded (outputs[index].u.transactionIndex.blockHash, outputs[index].u.transactionIndex.blockNumber, outputs[index].u.transactionIndex.transactionIndex, TRANSACTION_STATUS_BLOCK_TIMESTAMP_UNKNOWN, gasCreate(0)); } } array_free (outputs); break; } case PROVISION_SUBMIT_TRANSACTION: { BREthereumProvisionSubmission *provision = &provisionMulti->u.submission; BRArrayOf(BREthereumPIPRequestOutput) outputs = NULL; messagePIPResponseConsume(&message.u.response, &outputs); switch (array_count(outputs)) { case 0: // TODO: probably 'unknown' provision->status = transactionStatusCreate (TRANSACTION_STATUS_QUEUED); break; case 1: provision->status = transactionStatusCreateIncluded (outputs[0].u.transactionIndex.blockHash, outputs[0].u.transactionIndex.blockNumber, outputs[0].u.transactionIndex.transactionIndex, TRANSACTION_STATUS_BLOCK_TIMESTAMP_UNKNOWN, gasCreate (0)); break; default: assert(0); } array_free (outputs); break; } } messagePIPRelease(&message); return status; } /// MARK: - Create / Handle extern BREthereumMessage provisionCreateMessage (BREthereumProvision *provision, BREthereumMessageIdentifier type, size_t messageContentLimit, size_t messageIdBase, size_t index) { switch (type) { case MESSAGE_P2P: case MESSAGE_DIS: case MESSAGE_ETH: assert (0); case MESSAGE_LES: return provisionCreateMessageLES (provision, messageContentLimit, messageIdBase, index); case MESSAGE_PIP: return provisionCreateMessagePIP (provision, messageContentLimit, messageIdBase, index); break; } } static BRArrayOf(uint64_t) numbersCopy (BRArrayOf(uint64_t) numbers) { BRArrayOf(uint64_t) result; array_new (result, array_count(numbers)); array_add_array(result, numbers, array_count(numbers)); return result; } extern BREthereumProvision provisionCopy (BREthereumProvision *provision, BREthereumBoolean copyResults) { assert (ETHEREUM_BOOLEAN_FALSE == copyResults); // for now, switch (provision->type) { case PROVISION_BLOCK_HEADERS: return (BREthereumProvision) { provision->identifier, provision->type, { .headers = { provision->u.headers.start, provision->u.headers.skip, provision->u.headers.limit, provision->u.headers.reverse, NULL }} }; case PROVISION_BLOCK_PROOFS: return (BREthereumProvision) { provision->identifier, provision->type, { .proofs = { numbersCopy(provision->u.proofs.numbers), NULL }} }; case PROVISION_BLOCK_BODIES: return (BREthereumProvision) { provision->identifier, provision->type, { .bodies = { hashesCopy(provision->u.bodies.hashes), NULL }} }; case PROVISION_TRANSACTION_RECEIPTS: return (BREthereumProvision) { provision->identifier, provision->type, { .receipts = { hashesCopy(provision->u.receipts.hashes), NULL }} }; case PROVISION_ACCOUNTS: return (BREthereumProvision) { provision->identifier, provision->type, { .accounts = { provision->u.accounts.address, hashesCopy(provision->u.accounts.hashes), NULL }} }; case PROVISION_TRANSACTION_STATUSES: return (BREthereumProvision) { provision->identifier, provision->type, { .statuses = { hashesCopy(provision->u.statuses.hashes), NULL }} }; case PROVISION_SUBMIT_TRANSACTION: return (BREthereumProvision) { provision->identifier, provision->type, { .submission = { transactionCopy (provision->u.submission.transaction), (BREthereumTransactionStatus) {} }} }; } } extern void provisionReleaseResults (BREthereumProvision *provision) { switch (provision->type) { case PROVISION_BLOCK_HEADERS: if (NULL != provision->u.headers.headers) // Sometimes the headers will be NULL - because we preallocated the response. blockHeadersRelease(provision->u.headers.headers); break; case PROVISION_BLOCK_PROOFS: if (NULL != provision->u.proofs.proofs) array_free (provision->u.proofs.proofs); break; case PROVISION_BLOCK_BODIES: if (NULL != provision->u.bodies.pairs) blockBodyPairsRelease(provision->u.bodies.pairs); break; case PROVISION_TRANSACTION_RECEIPTS: if (NULL != provision->u.receipts.receipts) { size_t count = array_count(provision->u.receipts.receipts); for (size_t index = 0; index < count; index++) transactionReceiptsRelease (provision->u.receipts.receipts[index]); array_free (provision->u.receipts.receipts); } break; case PROVISION_ACCOUNTS: if (NULL != provision->u.accounts.accounts) array_free (provision->u.accounts.accounts); break; case PROVISION_TRANSACTION_STATUSES: if (NULL != provision->u.statuses.statuses) array_free (provision->u.statuses.statuses); break; case PROVISION_SUBMIT_TRANSACTION: break; } } extern void provisionRelease (BREthereumProvision *provision, BREthereumBoolean releaseResults) { switch (provision->type) { case PROVISION_BLOCK_HEADERS: break; case PROVISION_BLOCK_PROOFS: if (NULL != provision->u.proofs.numbers) array_free (provision->u.proofs.numbers); break; case PROVISION_BLOCK_BODIES: if (NULL != provision->u.bodies.hashes) array_free (provision->u.bodies.hashes); break; case PROVISION_TRANSACTION_RECEIPTS: if (NULL != provision->u.receipts.hashes) array_free (provision->u.receipts.hashes); break; case PROVISION_ACCOUNTS: if (NULL != provision->u.accounts.hashes) array_free (provision->u.accounts.hashes); break; case PROVISION_TRANSACTION_STATUSES: if (NULL != provision->u.statuses.hashes) array_free (provision->u.statuses.hashes); break; case PROVISION_SUBMIT_TRANSACTION: if (NULL != provision->u.submission.transaction) transactionRelease (provision->u.submission.transaction); break; } if (ETHEREUM_BOOLEAN_IS_TRUE(releaseResults)) provisionReleaseResults(provision); } extern void provisionHeadersConsume (BREthereumProvisionHeaders *provision, BRArrayOf(BREthereumBlockHeader) *headers) { if (NULL != headers) { *headers = provision->headers; provision->headers = NULL; } } extern void provisionProofsConsume (BREthereumProvisionProofs *provision, BRArrayOf(uint64_t) *numbers, BRArrayOf(BREthereumBlockHeaderProof) *proofs) { if (NULL != numbers) { *numbers = provision->numbers; provision->numbers = NULL; } if (NULL != proofs ) { *proofs = provision->proofs ; provision->proofs = NULL; } } extern void provisionBodiesConsume (BREthereumProvisionBodies *provision, BRArrayOf(BREthereumHash) *hashes, BRArrayOf(BREthereumBlockBodyPair) *pairs) { if (NULL != hashes) { *hashes = provision->hashes; provision->hashes = NULL; } if (NULL != pairs ) { *pairs = provision->pairs; provision->pairs = NULL; } } extern void provisionReceiptsConsume (BREthereumProvisionReceipts *provision, BRArrayOf(BREthereumHash) *hashes, BRArrayOf(BRArrayOf(BREthereumTransactionReceipt)) *receipts) { if (NULL != hashes) { *hashes = provision->hashes; provision->hashes = NULL; } if (NULL != receipts) { *receipts = provision->receipts; provision->receipts = NULL; } } extern void provisionAccountsConsume (BREthereumProvisionAccounts *provision, BRArrayOf(BREthereumHash) *hashes, BRArrayOf(BREthereumAccountState) *accounts) { if (NULL != hashes) { *hashes = provision->hashes; provision->hashes = NULL; } if (NULL != accounts) { *accounts = provision->accounts; provision->accounts = NULL; } } extern void provisionStatusesConsume (BREthereumProvisionStatuses *provision, BRArrayOf(BREthereumHash) *hashes, BRArrayOf(BREthereumTransactionStatus) *statuses) { if (NULL != hashes) { *hashes = provision->hashes; provision->hashes = NULL; } if (NULL != statuses) { *statuses = provision->statuses; provision->statuses = NULL; } } extern void provisionSubmissionConsume (BREthereumProvisionSubmission *provision, BREthereumTransaction *transaction, BREthereumTransactionStatus *status) { if (NULL != transaction) { *transaction = provision->transaction; provision->transaction = NULL; } if (NULL != status) { *status = provision->status; } } extern BREthereumProvisionStatus provisionHandleMessage (BREthereumProvision *provision, OwnershipGiven BREthereumMessage message, size_t messageContentLimit, size_t messageIdBase) { switch (message.identifier) { case MESSAGE_P2P: case MESSAGE_DIS: case MESSAGE_ETH: messageRelease(&message); return PROVISION_SUCCESS; case MESSAGE_LES: return provisionHandleMessageLES (provision, message.u.les, messageContentLimit, messageIdBase); case MESSAGE_PIP: return provisionHandleMessagePIP (provision, message.u.pip, messageContentLimit, messageIdBase); } } extern BREthereumBoolean provisionMatches (BREthereumProvision *provision1, BREthereumProvision *provision2) { return AS_ETHEREUM_BOOLEAN (provision1->type == provision2->type && provision1->identifier == provision2->identifier // bodies? ); } extern void provisionResultRelease (BREthereumProvisionResult *result) { provisionRelease (&result->provision, ETHEREUM_BOOLEAN_TRUE); }
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Common/ElementSet.h
/* * Copyright (c) 2019 Elastos Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef __ELASTOS_SDK_TRANSACTIONSET_H__ #define __ELASTOS_SDK_TRANSACTIONSET_H__ #include <set> #include <Common/uint256.h> namespace Elastos { namespace ElaWallet { template<class T> class ElementSet { public: typedef struct { bool operator() (const T &x, const T &y) const { return x->GetHash() < y->GetHash(); } } TCompare; T Get(const uint256 &hash) const { typename std::set<T, TCompare>::const_iterator it; it = std::find_if(_elements.begin(), _elements.end(), [&hash](const T &e) { return hash == e->GetHash(); }); if (it == _elements.end()) return nullptr; return *it; } std::set<T, TCompare> &Raw() { return _elements; } bool Contains(const T &e) const { return _elements.find(e) != _elements.end(); } bool Contains(const uint256 &hash) const { return Get(hash) != nullptr; } bool Insert(const T &e) { return _elements.insert(e).second; } size_t Size() { return _elements.size(); } bool Remove(const T &e) { return _elements.erase(e) > 0; } bool RemoveMatchPrevHash(const uint256 &hash) { typename std::set<T, TCompare>::const_iterator it; it = std::find_if(_elements.cbegin(), _elements.cend(), [&hash](const T &e) { return hash == e->GetPrevBlockHash(); }); if (it != _elements.end()) { _elements.erase(it); return true; } return false; } T GetMatchPrevHash(const uint256 &hash) const { typename std::set<T, TCompare>::const_iterator it; it = std::find_if(_elements.cbegin(), _elements.cend(), [&hash](const T &e) { return hash == e->GetPrevBlockHash(); }); if (it != _elements.end()) return *it; return nullptr; } void Clear() { _elements.clear(); } private: std::set<T, TCompare> _elements; }; } } #endif //__ELASTOS_SDK_TRANSACTIONSET_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/SpvService/SpvService.h
<reponame>fakecoinbase/elastosslashElastos.ELA.SPV.Cpp // Copyright (c) 2012-2018 The Elastos Open Source Project // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef __ELASTOS_SDK_SPVSERVICE_H__ #define __ELASTOS_SDK_SPVSERVICE_H__ #include "BackgroundExecutor.h" #include "CoreSpvService.h" #include "Database/DatabaseManager.h" #include <boost/filesystem.hpp> #include <boost/function.hpp> #include <nlohmann/json.hpp> #include <vector> namespace Elastos { namespace ElaWallet { class DatabaseManager; class Transaction; typedef boost::shared_ptr<Transaction> TransactionPtr; class SpvService : public CoreSpvService { public: SpvService(const std::string &walletID, const std::string &chainID, const SubAccountPtr &subAccount, const boost::filesystem::path &dbPath, time_t earliestPeerTime, const ChainConfigPtr &config, const std::string &netType); virtual ~SpvService(); void SyncStart(); void SyncStop(); void ExecutorStop(); time_t GetFirstTxnTimestamp() const; TransactionPtr GetTransaction(const uint256 &hash, const std::string &chainID); size_t GetAllTransactionCount(TxnType type) const; std::vector<TransactionPtr> LoadTxnDesc(const std::string &chainID, TxnType type, size_t offset, size_t limit) const; void RegisterWalletListener(Wallet::Listener *listener); void RegisterPeerManagerListener(PeerManager::Listener *listener); void PublishTransaction(const TransactionPtr &tx); void DatabaseFlush(); public: virtual void onBalanceChanged(const uint256 &asset, const BigInt &balance); virtual void onTxAdded(const TransactionPtr &tx); virtual void onTxUpdated(const std::vector<TransactionPtr> &txns); virtual void onTxDeleted(const TransactionPtr &tx, bool notifyUser, bool recommendRescan); virtual void onAssetRegistered(const AssetPtr &asset, uint64_t amount, const uint168 &controller); public: virtual void syncStarted(); virtual void syncProgress(uint32_t progress, time_t lastBlockTime, uint32_t bytesPerSecond, const std::string &downloadPeer); virtual void syncStopped(const std::string &error); virtual void txStatusUpdate(); virtual void saveBlocks(bool replace, const std::vector<MerkleBlockPtr> &blocks); virtual void savePeers(bool replace, const std::vector<PeerInfo> &peers); virtual void saveBlackPeer(const PeerInfo &peer); virtual bool networkIsReachable(); virtual void txPublished(const std::string &hash, const nlohmann::json &result); virtual void connectStatusChanged(const std::string &status); protected: virtual void DeleteTxn(const uint256 &hash); virtual std::vector<TransactionPtr> loadCoinbaseTxns(const std::string &chainID); virtual std::vector<TransactionPtr> loadConfirmedTxns(const std::string &chainID); virtual std::vector<TransactionPtr> loadPendingTxns(const std::string &chainID); virtual std::vector<MerkleBlockPtr> loadBlocks(const std::string &chainID); virtual std::vector<PeerInfo> loadPeers(); virtual std::set<PeerInfo> loadBlackPeers(); virtual std::vector<AssetPtr> loadAssets(); virtual const PeerManagerListenerPtr &createPeerManagerListener(); // virtual const WalletListenerPtr &createWalletListener(); private: DatabaseManagerPtr _databaseManager; BackgroundExecutor _executor; std::vector<Wallet::Listener *> _walletListeners; std::vector<PeerManager::Listener *> _peerManagerListeners; }; } } #endif //__ELASTOS_SDK_SPVSERVICE_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Plugin/Interface/ELAMessageSerializable.h
// Copyright (c) 2012-2018 The Elastos Open Source Project // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef __ELASTOS_SDK_ELAMESSAGESERIALIZABLE_H__ #define __ELASTOS_SDK_ELAMESSAGESERIALIZABLE_H__ #include <Common/ByteStream.h> #include <nlohmann/json.hpp> #include <istream> #include <ostream> namespace Elastos { namespace ElaWallet { class ELAMessageSerializable { public: virtual ~ELAMessageSerializable() {} virtual size_t EstimateSize() const = 0; virtual void Serialize(ByteStream &ostream) const = 0; virtual bool Deserialize(const ByteStream &istream) = 0; }; } } #endif //__ELASTOS_SDK_ELAMESSAGESERIALIZABLE_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Plugin/Transaction/IDTransaction.h
// Copyright (c) 2012-2019 The Elastos Open Source Project // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef __ELASTOS_SDK_IDTRANSACTION_H__ #define __ELASTOS_SDK_IDTRANSACTION_H__ #include "Transaction.h" namespace Elastos { namespace ElaWallet { class IDTransaction : public Transaction { public: enum { registerIdentification = 0x09, // deprecated didTransaction = 0x0A, }; public: IDTransaction(); IDTransaction(uint8_t type, const PayloadPtr &payload); IDTransaction(const IDTransaction &tx); IDTransaction &operator=(const IDTransaction &tx); virtual ~IDTransaction(); virtual bool DeserializeType(const ByteStream &istream); virtual bool IsDPoSTransaction() const; virtual bool IsCRCTransaction() const; virtual bool IsProposalTransaction() const; virtual bool IsIDTransaction() const; public: virtual PayloadPtr InitPayload(uint8_t type); }; } } #endif //__ELASTOS_SDK_IDTRANSACTION_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
Interface/ISubWalletCallback.h
/* * Copyright (c) 2019 Elastos Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef __ELASTOS_SDK_ISUBWALLETCALLBACK_H__ #define __ELASTOS_SDK_ISUBWALLETCALLBACK_H__ #include <string> #include "nlohmann/json.hpp" namespace Elastos { namespace ElaWallet { #define SPV_API_PUBLIC __attribute__((__visibility__("default"))) class ISubWalletCallback { public: virtual ~ISubWalletCallback() noexcept {} /** * Callback method fired when status of a transaction changed. * @param txid indicate hash of the transaction. * @param status can be "Added", "Deleted" or "Updated". * @param desc is an detail description of transaction status. * @param confirms is confirm count util this callback fired. */ virtual void OnTransactionStatusChanged( const std::string &txid, const std::string &status, const nlohmann::json &desc, uint32_t confirms) = 0; /** * Callback method fired when best block chain height increased. This callback could be used to show progress. * @param progressInfo progress info contain detail as below: * { * "Progress": 50, # 0% ~ 100% * "BytesPerSecond": 12345678, # 12.345678 MByte / s * "LastBlockTime": 1573799697, # timestamp of last block * "DownloadPeer": "127.0.0.1" # IP address of node * } */ virtual void OnBlockSyncProgress(const nlohmann::json &progressInfo) = 0; /** * Callback method fired when balance changed. * @param asset ID. * @param balance after changed. */ virtual void OnBalanceChanged(const std::string &asset, const std::string &balance) = 0; /** * Callback method fired when tx published. * @param hash of published tx. * @param result in json format. */ virtual void OnTxPublished(const std::string &hash, const nlohmann::json &result) = 0; /** * Callback method fired when a new asset registered. * @param asset ID. * @param information of asset. */ virtual void OnAssetRegistered(const std::string &asset, const nlohmann::json &info) = 0; /** * Callback method fired when status of connection changed. * @param status value can be one of below: "Connecting", "Connected", "Disconnected" */ virtual void OnConnectStatusChanged(const std::string &status) = 0; virtual void OnETHSCEventHandled(const nlohmann::json &event) = 0; }; } } #endif //__ELASTOS_SDK_ISUBWALLETCALLBACK_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Database/AssetDataStore.h
<filename>SDK/Database/AssetDataStore.h /* * Copyright (c) 2019 Elastos Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef __ELASTOS_SDK_ASSETDATASTORE_H__ #define __ELASTOS_SDK_ASSETDATASTORE_H__ #include "TableBase.h" #include <Common/BigInt.h> namespace Elastos { namespace ElaWallet { struct AssetEntity { AssetEntity() : Amount(0) { } AssetEntity(const std::string &assetID, const BigInt &amount, const bytes_t &Asset) : AssetID(assetID), Amount(amount), Asset(Asset) { } std::string AssetID; BigInt Amount; bytes_t Asset; }; class AssetDataStore : public TableBase { public: AssetDataStore(Sqlite *sqlite, SqliteTransactionType type = IMMEDIATE); ~AssetDataStore(); virtual void InitializeTable(); bool PutAsset(const std::string &iso, const AssetEntity &asset); bool DeleteAsset(const std::string &assetID); bool DeleteAllAssets(); bool GetAssetDetails(const std::string &assetID, AssetEntity &asset) const; std::vector<AssetEntity> GetAllAssets() const; private: bool SelectAsset(const std::string &assetID, AssetEntity &asset) const; bool InsertAsset(const std::string &iso, const AssetEntity &asset); bool UpdateAsset(const std::string &iso, const AssetEntity &asset); private: /* * asset data table */ const std::string ASSET_OLD_TABLE_NAME = "assetTable"; const std::string ASSET_TABLE_NAME = "registeredAssetTable"; const std::string ASSET_COLUMN_ID = "_id"; const std::string ASSET_AMOUNT = "assetAmount"; const std::string ASSET_BUFF = "assetBuff"; const std::string ASSET_ISO = "assetISO"; const std::string ASSET_DATABASE_CREATE = "create table if not exists " + ASSET_TABLE_NAME + " (" + ASSET_COLUMN_ID + " text not null, " + ASSET_AMOUNT + " text DEFAULT '0', " + ASSET_BUFF + " blob, " + ASSET_ISO + " text DEFAULT 'ELA');"; }; } } #endif //__ELASTOS_SDK_ASSETDATASTORE_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
Test/TestHelper.h
<reponame>fakecoinbase/elastosslashElastos.ELA.SPV.Cpp<filename>Test/TestHelper.h // Copyright (c) 2012-2018 The Elastos Open Source Project // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef __ELASTOS_SDK_TESTHELPER_H__ #define __ELASTOS_SDK_TESTHELPER_H__ #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) #include <Plugin/Block/AuxPow.h> #include <Plugin/Block/MerkleBlock.h> #include <Plugin/Transaction/Transaction.h> #include <Plugin/Transaction/TransactionInput.h> #include <Plugin/Transaction/TransactionOutput.h> #include <Plugin/Transaction/Attribute.h> #include <Plugin/Transaction/Program.h> #include <Plugin/Transaction/Payload/OutputPayload/PayloadVote.h> #include <Plugin/Transaction/Payload/OutputPayload/PayloadDefault.h> #include <Common/BigInt.h> namespace Elastos { namespace ElaWallet { static UInt256 getRandUInt256(void) { UInt256 u; for (size_t i = 0; i < ARRAY_SIZE(u.u32); ++i) { u.u32[i] = rand(); } return u; } static bytes_t getRandBytes(size_t size) { bytes_t block(size); for (size_t i = 0; i < size; ++i) { block[i] = (uint8_t) rand(); } return block; } static bytes_ptr getRandBytesPtr(size_t size) { bytes_ptr data(new bytes_t(size)); for (size_t i = 0; i < size; ++i) (*data)[i] = (uint8_t) rand(); return data; } static uint256 getRanduint256(void) { return uint256(getRandBytes(32)); } static BigInt getRandBigInt() { BigInt bg; bg.setUint64(rand()); return bg; } static std::string getRandHexString(size_t length) { char buf[length]; for (size_t i = 0; i < length; ) { char ch = rand(); if (isxdigit(ch)) { buf[i++] = tolower(ch); } } return std::string(buf, length); } static std::string getRandString(size_t length) { char buf[length]; for (size_t i = 0; i < length; ) { char ch = rand(); if (isalnum(ch)) { buf[i++] = ch; } } return std::string(buf, length); } static uint64_t getRandUInt64() { return uint64_t(rand()); } static uint32_t getRandUInt32() { return uint32_t(rand()); } static uint16_t getRandUInt16() { return uint16_t(rand()); } static uint8_t getRandUInt8() { return uint8_t(rand()); } static uint128 getRandUInt128(void) { return uint128(getRandBytes(16)); } static uint168 getRandUInt168(void) { return uint168(getRandBytes(21)); } static void initTransaction(Transaction &tx, const Transaction::TxVersion &version) { tx.SetVersion(version); tx.SetLockTime(getRandUInt32()); tx.SetBlockHeight(getRandUInt32()); tx.SetTimestamp(getRandUInt32()); tx.SetPayloadVersion(getRandUInt8()); tx.SetFee(getRandUInt64()); for (size_t i = 0; i < 20; ++i) { InputPtr input(new TransactionInput()); input->SetTxHash(getRanduint256()); input->SetIndex(getRandUInt16()); input->SetSequence(getRandUInt32()); tx.AddInput(input); } for (size_t i = 0; i < 20; ++i) { Address addr(getRandUInt168()); OutputPtr output(new TransactionOutput(getRandBigInt(), addr, getRanduint256())); output->SetOutputLock(getRandUInt32()); if (version >= Transaction::TxVersion::V09) { output->SetType(TransactionOutput::Type(i % 2)); if (output->GetType() == TransactionOutput::VoteOutput) { std::vector<CandidateVotes> candidates; uint8_t v = rand() % 2; for (size_t i = 0; i < 50; ++i) { candidates.push_back(CandidateVotes(getRandBytes(33), v == VOTE_PRODUCER_CR_VERSION ? getRandUInt64() : 0)); } VoteContent vc(VoteContent::Delegate, candidates); output->SetPayload(OutputPayloadPtr(new PayloadVote({vc}, v))); } else { output->SetPayload(OutputPayloadPtr(new PayloadDefault())); } } tx.AddOutput(output); } for (size_t i = 0; i < 20; ++i) { bytes_t data = getRandBytes(25); tx.AddAttribute(AttributePtr(new Attribute(Attribute::Script, data))); } for (size_t i = 0; i < 20; ++i) { bytes_t code = getRandBytes(25); bytes_t parameter = getRandBytes(25); tx.AddProgram(ProgramPtr(new Program("", code, parameter))); } tx.GetHash(); } static void verifyTransaction(const Transaction &tx1, const Transaction &tx2, bool checkAll = true) { REQUIRE(tx1.GetLockTime() == tx2.GetLockTime()); REQUIRE(tx1.GetTransactionType() == tx2.GetTransactionType()); REQUIRE(tx1.GetPayloadVersion() == tx2.GetPayloadVersion()); REQUIRE(tx1.GetVersion() == tx2.GetVersion()); if (checkAll) { REQUIRE(tx1.GetBlockHeight() == tx2.GetBlockHeight()); REQUIRE(tx1.GetTimestamp() == tx2.GetTimestamp()); REQUIRE(tx1.GetFee() == tx2.GetFee()); } REQUIRE(tx1.GetOutputs().size() == tx2.GetOutputs().size()); REQUIRE(tx1.GetHash() == tx2.GetHash()); REQUIRE(tx1.GetInputs().size() == tx2.GetInputs().size()); for (size_t i = 0; i < tx1.GetInputs().size(); ++i) { InputPtr in1, in2; in1 = tx1.GetInputs()[i]; in2 = tx2.GetInputs()[i]; REQUIRE(in1->TxHash() == in2->TxHash()); REQUIRE(in1->Index() == in2->Index()); REQUIRE(in1->Sequence() == in2->Sequence()); } REQUIRE(tx1.GetOutputs().size() == tx2.GetOutputs().size()); for (size_t i = 0; i < tx2.GetOutputs().size(); ++i) { OutputPtr o1, o2; o1 = tx1.GetOutputs()[i]; o2 = tx2.GetOutputs()[i]; REQUIRE(o2->AssetID() == o1->AssetID()); REQUIRE(*o2->Addr() == *o1->Addr()); REQUIRE(o2->OutputLock() == o1->OutputLock()); REQUIRE(o2->Amount() == o1->Amount()); REQUIRE(o1->GetType() == o2->GetType()); OutputPayloadPtr p1 = o1->GetPayload(); OutputPayloadPtr p2 = o2->GetPayload(); if (o1->GetType() == TransactionOutput::VoteOutput) { const PayloadVote *pv1 = dynamic_cast<const PayloadVote *>(p1.get()); const PayloadVote *pv2 = dynamic_cast<const PayloadVote *>(p2.get()); REQUIRE(pv1 != nullptr); REQUIRE(pv2 != nullptr); const std::vector<VoteContent> &vc1 = pv1->GetVoteContent(); const std::vector<VoteContent> &vc2 = pv2->GetVoteContent(); REQUIRE(vc1.size() == vc2.size()); for (size_t j = 0; j < vc1.size(); ++j) { REQUIRE(vc1[j].GetType() == vc2[j].GetType()); const std::vector<CandidateVotes> &cand1 = vc1[j].GetCandidateVotes(); const std::vector<CandidateVotes> &cand2 = vc2[j].GetCandidateVotes(); REQUIRE(cand1.size() == cand2.size()); for (size_t k = 0; k < cand1.size(); ++k) { REQUIRE(cand1[k].GetCandidate() == cand2[k].GetCandidate()); REQUIRE(cand1[k].GetVotes() == cand2[k].GetVotes()); } } } else { const PayloadDefault *pd1 = dynamic_cast<const PayloadDefault *>(p1.get()); const PayloadDefault *pd2 = dynamic_cast<const PayloadDefault *>(p2.get()); REQUIRE(pd1 != nullptr); REQUIRE(pd2 != nullptr); } } REQUIRE(tx1.GetAttributes().size() == tx2.GetAttributes().size()); for (size_t i = 0; i < tx1.GetAttributes().size(); ++i) { AttributePtr attr1, attr2; attr1 = tx1.GetAttributes()[i]; attr2 = tx2.GetAttributes()[i]; REQUIRE(attr1->GetUsage() == attr2->GetUsage()); REQUIRE((attr1->GetData() == attr2->GetData())); } REQUIRE(tx1.GetPrograms().size() == tx2.GetPrograms().size()); for (size_t i = 0; i < tx2.GetPrograms().size(); ++i) { ProgramPtr p1, p2; p1 = tx1.GetPrograms()[i]; p2 = tx2.GetPrograms()[i]; REQUIRE((p1->GetCode() == p2->GetCode())); REQUIRE((p1->GetParameter() == p2->GetParameter())); } } static AuxPow createDummyAuxPow() { AuxPow auxPow; std::vector<uint256> hashes(3); for (size_t i = 0; i < hashes.size(); ++i) { hashes[i] = getRanduint256(); } auxPow.SetAuxMerkleBranch(hashes); for (size_t i = 0; i < hashes.size(); ++i) { hashes[i] = getRanduint256(); } auxPow.SetCoinBaseMerkle(hashes); auxPow.SetAuxMerkleIndex(123); auxPow.SetParMerkleIndex(456); auxPow.SetParentHash(getRanduint256()); // init transaction BRTransaction *tx = BRTransactionNew(); tx->txHash = getRandUInt256(); tx->version = rand(); for (size_t i = 0; i < 3; ++i) { bytes_t script = getRandBytes(25); bytes_t signature = getRandBytes(28); BRTransactionAddInput(tx, getRandUInt256(), i, rand(), &script[0], script.size(), &signature[0], signature.size(), nullptr, 0, rand()); } for (size_t i = 0; i < 4; ++i) { bytes_t script = getRandBytes(25); BRTransactionAddOutput(tx, rand(), &script[0], script.size()); } tx->lockTime = rand(); tx->blockHeight = rand(); tx->timestamp = rand(); auxPow.SetBTCTransaction(tx); // init merkle block BRMerkleBlock *block = BRMerkleBlockNew(); block->blockHash = getRandUInt256(); block->version = rand(); block->prevBlock = getRandUInt256(); block->merkleRoot = getRandUInt256(); block->timestamp = rand(); block->target = rand(); block->nonce = rand(); block->totalTx = rand(); UInt256 MBHashes[3]; for (size_t i = 0; i < ARRAY_SIZE(MBHashes); ++i) { MBHashes[i] = getRandUInt256(); } block->hashesCount = ARRAY_SIZE(MBHashes); bytes_t flags = getRandBytes(5); block->flagsLen = flags.size(); BRMerkleBlockSetTxHashes(block, MBHashes, ARRAY_SIZE(MBHashes), &flags[0], flags.size()); block->height = rand(); auxPow.SetParBlockHeader(block); return auxPow; } static void verrifyAuxPowEqual(const AuxPow &auxPow, const AuxPow &auxPowVerify, bool checkAll = true) { const std::vector<uint256> &origMerkleBranch = auxPow.GetAuxMerkleBranch(); const std::vector<uint256> &merkleBranch = auxPowVerify.GetAuxMerkleBranch(); REQUIRE(merkleBranch.size() == origMerkleBranch.size()); for (size_t i = 0; i < merkleBranch.size(); ++i) { REQUIRE(merkleBranch[i] == origMerkleBranch[i]); } const std::vector<uint256> &origCoinBaseMerkle = auxPow.GetParCoinBaseMerkle(); const std::vector<uint256> &coinBaseMerkle = auxPowVerify.GetParCoinBaseMerkle(); REQUIRE(origCoinBaseMerkle.size() == coinBaseMerkle.size()); for (size_t i = 0; i < coinBaseMerkle.size(); ++i) { REQUIRE(coinBaseMerkle[i] == origCoinBaseMerkle[i]); } REQUIRE(auxPow.GetAuxMerkleIndex() == auxPowVerify.GetAuxMerkleIndex()); REQUIRE(auxPow.GetParMerkleIndex() == auxPowVerify.GetParMerkleIndex()); const uint256 &parentHash = auxPow.GetParentHash(); const uint256 &parentHashVerify = auxPowVerify.GetParentHash(); REQUIRE(parentHash == parentHashVerify); // verify transaction BRTransaction *origTxn = auxPow.GetBTCTransaction(); BRTransaction *txn = auxPowVerify.GetBTCTransaction(); if (checkAll) { REQUIRE(origTxn->blockHeight == txn->blockHeight); REQUIRE(UInt256Eq(origTxn->txHash, txn->txHash)); } REQUIRE(origTxn->version == txn->version); REQUIRE(origTxn->inCount == txn->inCount); for (size_t i = 0; i < txn->inCount; ++i) { REQUIRE(UInt256Eq(origTxn->inputs[i].txHash, txn->inputs[i].txHash)); REQUIRE(origTxn->inputs[i].index == txn->inputs[i].index); if (checkAll) { REQUIRE(0 == strcmp(origTxn->inputs[i].address, txn->inputs[i].address)); } if (checkAll) { REQUIRE(origTxn->inputs[i].amount == txn->inputs[i].amount); REQUIRE(origTxn->inputs[i].scriptLen == txn->inputs[i].scriptLen); REQUIRE(0 == memcmp(origTxn->inputs[i].script, txn->inputs[i].script, txn->inputs[i].scriptLen)); } REQUIRE(origTxn->inputs[i].sigLen == txn->inputs[i].sigLen); REQUIRE(0 == memcmp(origTxn->inputs[i].signature, txn->inputs[i].signature, txn->inputs[i].sigLen)); REQUIRE(origTxn->inputs[i].sequence == txn->inputs[i].sequence); } REQUIRE(origTxn->outCount == txn->outCount); for (size_t i = 0; i < txn->outCount; ++i) { REQUIRE(0 == strcmp(origTxn->outputs[i].address, txn->outputs[i].address)); REQUIRE(origTxn->outputs[i].amount == txn->outputs[i].amount); REQUIRE(origTxn->outputs[i].scriptLen == txn->outputs[i].scriptLen); REQUIRE(0 == memcmp(origTxn->outputs[i].script, txn->outputs[i].script, txn->outputs[i].scriptLen)); } REQUIRE(origTxn->lockTime == txn->lockTime); if (checkAll) { REQUIRE(origTxn->blockHeight == txn->blockHeight); REQUIRE(origTxn->timestamp == txn->timestamp); } // verify merkle block BRMerkleBlock *origBlock = auxPow.GetParBlockHeader(); BRMerkleBlock *blockVerify = auxPowVerify.GetParBlockHeader(); if (checkAll) { REQUIRE(UInt256Eq(origBlock->blockHash, blockVerify->blockHash)); } REQUIRE(origBlock->version == blockVerify->version); REQUIRE(UInt256Eq(origBlock->prevBlock, blockVerify->prevBlock)); REQUIRE(UInt256Eq(origBlock->merkleRoot, blockVerify->merkleRoot)); REQUIRE(origBlock->timestamp == blockVerify->timestamp); REQUIRE(origBlock->target == blockVerify->target); REQUIRE(origBlock->nonce == blockVerify->nonce); if (checkAll) { REQUIRE(origBlock->totalTx == blockVerify->totalTx); REQUIRE(origBlock->hashesCount == blockVerify->hashesCount); for (size_t i = 0; i < origBlock->hashesCount; ++i) { REQUIRE(UInt256Eq(origBlock->hashes[i], blockVerify->hashes[i])); } REQUIRE(origBlock->flagsLen == blockVerify->flagsLen); for (size_t i = 0; i < origBlock->flagsLen; ++i) { REQUIRE(origBlock->flags[i] == blockVerify->flags[i]); } REQUIRE(origBlock->height == blockVerify->height); } } static void setMerkleBlockValues(MerkleBlock *block) { block->SetHeight((uint32_t) rand()); block->SetTimestamp((uint32_t) rand()); block->SetVersion((uint32_t) rand()); std::vector<uint8_t> flags; for (size_t i = 0; i < 10; ++i) { flags.push_back((uint8_t) rand()); } std::vector<uint256> hashes; for (size_t i = 0; i < 10; ++i) { hashes.push_back(getRanduint256()); } block->SetRootBlockHash(getRanduint256()); block->SetNonce((uint32_t) rand()); block->SetPrevBlockHash(getRanduint256()); block->SetTarget((uint32_t) rand()); block->SetTransactionCount((uint32_t) rand()); AuxPow auxPow; hashes.clear(); for (size_t i = 0; i < 10; ++i) { hashes.push_back(getRanduint256()); } auxPow.SetAuxMerkleBranch(hashes); hashes.clear(); for (size_t i = 0; i < 10; ++i) { hashes.push_back(getRanduint256()); } auxPow.SetCoinBaseMerkle(hashes); auxPow.SetAuxMerkleIndex(rand()); BRTransaction *tx = BRTransactionNew(); tx->txHash = getRandUInt256(); tx->version = (uint32_t) rand(); for (size_t i = 0; i < 10; ++i) { bytes_t script = getRandBytes(25); bytes_t signature = getRandBytes(35); BRTransactionAddInput(tx, getRandUInt256(), (uint32_t) rand(), (uint64_t) rand(), &script[0], script.size(), &signature[0], signature.size(), nullptr, 0, (uint32_t) rand()); } for (size_t i = 0; i < 10; ++i) { bytes_t script = getRandBytes(25); BRTransactionAddOutput(tx, rand(), &script[0], script.size()); } tx->lockTime = rand(); tx->blockHeight = rand(); tx->timestamp = rand(); auxPow.SetBTCTransaction(tx); block->SetAuxPow(auxPow); } static void verifyELAMerkleBlock(const MerkleBlock &newBlock, const MerkleBlock &block) { REQUIRE(newBlock.GetHash() == block.GetHash()); REQUIRE(newBlock.GetHeight() == block.GetHeight()); REQUIRE(newBlock.GetTimestamp() == block.GetTimestamp()); REQUIRE(newBlock.GetVersion() == block.GetVersion()); REQUIRE(newBlock.GetFlags().size() == block.GetFlags().size()); for (size_t i = 0; i < block.GetFlags().size(); ++i) { REQUIRE(newBlock.GetFlags()[i] == block.GetFlags()[i]); } REQUIRE(newBlock.GetHashes().size() == block.GetHashes().size()); for (size_t i = 0; i < block.GetHashes().size(); ++i) { REQUIRE(newBlock.GetHashes()[i] == block.GetHashes()[i]); } REQUIRE(newBlock.GetRootBlockHash() == block.GetRootBlockHash()); REQUIRE(newBlock.GetNonce() == block.GetNonce()); REQUIRE(newBlock.GetPrevBlockHash() == block.GetPrevBlockHash()); REQUIRE(newBlock.GetTarget() == block.GetTarget()); REQUIRE(newBlock.GetTransactionCount() == block.GetTransactionCount()); verrifyAuxPowEqual(newBlock.GetAuxPow(), block.GetAuxPow(), false); } } } #endif //__ELASTOS_SDK_TESTHELPER_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/SpvService/TestNetConfig.h
<gh_stars>10-100 // Copyright (c) 2012-2019 The Elastos Open Source Project // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef __ELASTOS_SDK_TESTNET_H__ #define __ELASTOS_SDK_TESTNET_H__ namespace Elastos { namespace ElaWallet { const nlohmann::json DefaultTestNetConfig = R"( { "NetType": "TestNet", "ELA": { "Index": 0, "MinFee": 10000, "FeePerKB": 10000, "DisconnectionTime": 300, "GenesisAddress": "", "ChainParameters": { "Services": 0, "MagicNumber": 2018111, "StandardPort": 21338, "TargetTimeSpan": 86400, "TargetTimePerBlock": 120, "DNSSeeds": [ "node-testnet-002.elastos.org", "node-testnet-003.elastos.org", "node-testnet-004.elastos.org" ], "CheckPoints": [ [0,"6418be20291bc857c9a01e5ba205445b85a0593d47cc0b576d55a55e464f31b3",1513936800,486801407], [2016,"99ca9a4467b547c19a6554021fd1b5b455b29d1adddbd910dd437bc143785767",1517940844,503906048], [14112,"20931a5184a88116d76b8669fae9fe038ca3e5209d74a64ec78947142c16a95e",1523380720,494547269], [30240,"5a9f2456d12b5f335a4d1ecfad28cadd600b7a38957a72d0c087573f4aa8280e",1526024685,503359636], [46368,"824f0efd718d680467f7707b5735d0d69c9215e9721ed2be57b1254d74c926a5",1527950360,503351874], [62496,"8cb6da886b6258e8a6daefce9d5566575bd2ba95b4bd684105954ab9e69be042",1529864598,493529298], [78624,"<KEY>",1531850116,503352094], [94752,"372df4fe8ebb396f8298d3fa596ab6c825fb9d16a7d93ba15ed5372ed9382dfb",1533848032,503381789], [110880,"743823d8e5d1e74aa7aa8de9a20ca3b42dad4c1115b1631d6071d66d68f6a4f9",1535780560,503376620], [127008,"<KEY>",1537725085,503381782], [143136,"22a3efa19fcfdbcd5a1be9c4e66dadf317f31c6de53ef41a5603dc1d04d6fa21",1539918360,503378173], [159264,"a72b0aab079818986cca9fbee3155fe9d20c7cfb64a1aed3edfa603d6d688c6e",1541946004,503356074], [175392,"a19f1d199dcea09cca591bfee11ca708d8cba8507247fe958dbf1ad23cf6f5e7",1544083986,503358989], [191520,"0bf0d6ec4aef082a08106100573a27d4fc2a2fd48f144883f28d743cb76b3bcb",1546198659,503557308], [207648,"28525060cada3be8f6318beb11dc848c76eb6404ae418278255a37cfce61a95f",1548515041,520142669], [223776,"d033741010e231d052399e9f5a49cfc6fd2ef1538afd37504fef9270cd823ab1",1550547179,520228596], [239904,"b35329ff34fca9317b0f769a528947e013fe4875a665d140b8b2c9545231f617",1552561580,520414824], [256032,"<KEY>",1554299711,492511404], [272160,"0deb5e022ccdf5ec8b4757468e8bd8e2eab8896d361cc916ccaa2e23cd21f43f",1556404861,487013872], [288288,"6875f3daf52bff1d2e2397b2b66d4e37a1caf8c6121478016193fba6dad0b472",1558816377,488838945], [304416,"<KEY>",1560888482,487920650], [320544,"3fdeebe7233f12b914fd3eca9b59bf0c01de4bda3a0472115cd6da4ccd6cd5fa",1562943936,487173288], [336672,"<KEY>",1565950797,487329084], [352800,"ed4495be26a2c6864873cd7e5f78eeccf79aef69431338a682f8892271f883f7",1567868897,487149516], [368928,"<KEY>",1569807613,487126980], [385056,"8357189792a2596620411252a4ef75b958778d8153d4e8346625591961456648",1571747281,487137072], [401184,"<KEY>",1573441472,471451493], [417312,"7e58806a636ce659fb2d4ade6e45e2d7a34827cf8645ca0c06626696b09568d7",1574715009,436941611], [433440,"<KEY>",1576697012,437185259], [449568,"<KEY>",1578632736,436968872], [465696,"f6270ef342e2184eba495482435d636869757e581f3ffa15e7ecd92cb46f5c4a",1580629152,436997598], [481824,"9b7272b05f384c19c8e626205fb410dac134e3a7b0c465fee9d2612258db6154",1582576699,436991497], [497952,"5453c542345696e06b5fa7860d85caf9097f8ecab2e812d59d62e5c55e336a34",1584542022,437004857], [514080,"8836aab627720caebd711cae5a40adcf47a15dc0bdd84348a2a0d8436b6fbde3",1586501078,436962315], [516096,"f6d9076768c62062cc77b142e0a1de3f2512cf442847487ca8a195a014fb81ba",1586754114,437169356], [518112,"247919a01ae63237e6f875a4027ffd527ca62760e9abf204bdf26cc66913c8ac",1587017769,437269094] ] } }, "IDChain": { "Index": 1, "MinFee": 10000, "FeePerKB": 10000, "DisconnectionTime": 300, "GenesisAddress": "XKUh4GLhFJiqAMTF6HyWQrV9pK9HcGUdfJ", "ChainParameters": { "Services": 0, "MagicNumber": 2018112, "StandardPort": 21608, "TargetTimeSpan": 86400, "TargetTimePerBlock": 120, "DNSSeeds": [ "node-testnet-002.elastos.org", "node-testnet-003.elastos.org", "node-testnet-004.elastos.org" ], "CheckPoints": [ [0,"56be936978c261b2e649d58dbfaf3f23d4a868274f5522cd2adb4308a955c4a3",1530360000,486801407], [2016,"<KEY>",1532276131,505977014], [4032,"<KEY>",1532628770,510283913], [10080,"09cdb3d720a7095c7023241361ca8a317c75273fbdd0e5dc268667683e360780",1533694521,520890958], [16128,"8b78d2fee6751c82d419e5eb98bbf83a1514a046ae9ffd1462aceaeed3f189ec",1534771533,536935584], [22176,"9738541d86b7843be83926be997164615a3102e33edece26da351fdae70d2d6a",1535557289,536997059], [28224,"b98d6c3e7f424d44bf4f21f9093be7b2d29f2134137949769718c33ae22bd205",1536361613,537169686], [34272,"640298c39b33c1298d87e482115053177ae60b721e23801db0061bb4e24d393b",1537146343,537429158], [40320,"<KEY>",1538398560,545259519], [46368,"d177b074f16f0affcaade7c1da0484d7f10f6faf02e421b8b915496d6679bd82",1548462469,545259519], [52416,"5295b35d8ebcedd0ae482416b28491441a2de2c349c3b415bdb6e632ebfb5e7e",1549380587,545259519], [58464,"ce9fc50902e64211e2c0d455a5906585ba0e3522542cdd2a0b6649afe9e8e6c5",1550147031,545259519], [64512,"841adce0de01b403585a27040370058f96fe87681df1e53c724c3890ae81f3ce",1550950944,545259519], [70560,"86a52104b27dd1a41101326011daaea815083808faa6d066e7daa12a76ee34fd",1551840630,545259519], [76608,"1bb6d5fb18604b0b9b4930f39eb10fb449c88124364e507d1630bbe18c33093d",1552621349,545259519], [82656,"2aa7113b0281994032e076972f52716a1ec0b6588523cc09d1d19e09dd95c3d0",1553786369,545259519], [88704,"89f8d646b6a06ac4c3c19fd512d6828fa43837475308cb43f681ea76f6304051",1554723762,537728999], [94752,"1f11f4d37f00121e8759ba95d1689156b6ad936874b306b995bd27fe591fe05c",1555703316,542795017], [100800,"<KEY>",1556876552,545259519], [106848,"<KEY>",1558275465,545259519], [112896,"<KEY>",1559311653,545259519], [118944,"<KEY>",1560258408,545259519], [124992,"cd90dfd0009fd5088cb5a286107434b72e9d8276a8d5453cd6cdec8e4154d1db",1561200731,540483244], [131040,"<KEY>",1562325711,545259519], [137088,"246d653929bca3037fd5ad972872833c0bca0693493d0890ab4c264e0a4febee",1562975573,539694440], [143136,"22a2dfd70b3a675a44099e904dc421ca74e3ff27a7f87bf3fdd700fe05f7d6b7",1563755074,541495017], [149184,"<KEY>",1564526932,544716298], [155232,"<KEY>",1578009176,545259519], [161280,"<KEY>",1578802556,545004494], [167328,"26b533b707ae5f3dee76997425987fddbf711ff06c1f6796dda17aa5ac97f4e3",1579641052,545259519], [173376,"8a7a254d261e24a301a3af9fb87109c34e5392be671050b38731b47c411c6718",1580464884,545259519], [179424,"773dd811934a5fa46ac6e836e706059f071fb0e848a1e12b78c8e30f6ec426b0",1581259764,544208275], [185472,"b2822db543128dea3c037f1d749a965929b62121a105ba1ef863d2644e21877c",1582059935,545259519], [191520,"<KEY>",1582857873,545259519], [197568,"ab5324cad2237b2d6b263439f6431ee20aa570dfba9571f142da6de3d9d06341",1583652377,545259519], [203616,"0e6461ed630a9e2e618e15375bbb7eefd255335fb7ff2310756b6c39c7339e64",1584449303,545259519], [209664,"<KEY>",1585354060,543931614], [215712,"46c4a154bbdce78f640edf832f7835ecd717b0dca76bd338abde9fb4d808d5f7",1586136336,545259519], [217728,"463ece5bd590f548d648a4ccce344e1be2d0a902b4f9378d2eadf30a8b6eaa6a",1586407549,545259519], [219744,"4a8fa68b776efc8447f835e295a0bdb20051b2d7a1c19d08a8ea2428ed7ae0f1",1586683138,545259519], [221760,"c89e7d19a49a7c612ec7bb3f6b7b5cc58b662f5811f0f664dfbe9d5d4766666d",1586969973,545259519] ] } }, "TokenChain": { "Index": 2, "MinFee": 10000, "FeePerKB": 10000, "DisconnectionTime": 300, "GenesisAddress": "XVfmhjxGxBKgzYxyXCJTb6YmaRfWPVunj4", "ChainParameters": { "Services": 0, "MagicNumber": 2019104, "StandardPort": 21618, "TargetTimeSpan": 86400, "TargetTimePerBlock": 120, "DNSSeeds": [ "node-testnet-002.elastos.org", "node-testnet-003.elastos.org", "node-testnet-004.elastos.org", "node-testnet-005.elastos.org", "node-testnet-006.elastos.org", "node-testnet-007.elastos.org", "node-testnet-011.elastos.org" ], "CheckPoints": [ [0, "b569111dfb5e12d40be5cf09e42f7301128e9ac7ab3c6a26f24e77872b9a730e", 1551744000, 486801407] ] } }, "ETHSC": { "Index": 3, "MinFee": 0, "FeePerKB": 0, "DisconnectionTime": 0, "ChainParameters": { "Services": 0, "MagicNumber": 0, "StandardPort": 0, "TargetTimeSpan": 0, "TargetTimePerBlock": 0, "DNSSeeds": [ "127.0.0.1" ], "CheckPoints": [ [0, "698e5ec133064dabb7c42eb4b2bdfa21e7b7c2326b0b719d5ab7f452ae8f5ee4", 1, 1] ] } } } )"_json; } } #endif //__ELASTOS_SDK_TESTNET_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/SpvService/PrvNetConfig.h
<gh_stars>10-100 // Copyright (c) 2012-2019 The Elastos Open Source Project // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef __ELASTOS_SDK_PRVNET_H__ #define __ELASTOS_SDK_PRVNET_H__ namespace Elastos { namespace ElaWallet { const nlohmann::json DefaultPrvNetConfig = R"( { "NetType": "PrvNet", "ELA": { "Index": 0, "MinFee": 10000, "FeePerKB": 10000, "DisconnectionTime": 300, "ChainParameters": { "Services": 0, "MagicNumber": 2018201, "StandardPort": 10018, "TargetTimeSpan": 86400, "TargetTimePerBlock": 120, "DNSSeeds": [ "172.26.0.207" ], "CheckPoints": [ [0, "8df798783097be3a8f382f6537e47c7168d4bf4d741fa3fa8c48c607a06352cf", 1513936800, 486801407] ] } }, "IDChain": { "Index": 1, "MinFee": 10000, "FeePerKB": 10000, "DisconnectionTime": 300, "ChainParameters": { "Services": 0, "MagicNumber": 2018202, "StandardPort": 10138, "TargetTimeSpan": 86400, "TargetTimePerBlock": 120, "DNSSeeds": [ "172.26.0.207" ], "CheckPoints": [ [0, "56be936978c261b2e649d58dbfaf3f23d4a868274f5522cd2adb4308a955c4a3", 1513936800, 486801407] ] } }, "TokenChain": { "Index": 2, "MinFee": 10000, "FeePerKB": 10000, "DisconnectionTime": 300, "ChainParameters": { "Services": 0, "MagicNumber": 2019004, "StandardPort": 30618, "TargetTimeSpan": 86400, "TargetTimePerBlock": 120, "DNSSeeds": [ "172.26.0.165" ], "CheckPoints": [ [0, "b569111dfb5e12d40be5cf09e42f7301128e9ac7ab3c6a26f24e77872b9a730e", 1551744000, 486801407] ] } }, "ETHSC": { "Index": 3, "MinFee": 0, "FeePerKB": 0, "DisconnectionTime": 0, "ChainParameters": { "Services": 0, "MagicNumber": 0, "StandardPort": 0, "TargetTimeSpan": 0, "TargetTimePerBlock": 0, "DNSSeeds": [ "127.0.0.1" ], "CheckPoints": [ [0, "0000000000000000000000000000000000000000000000000000000000000000", 1, 1] ] } } } )"_json; } } #endif
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/rlp/testRlp.c
// // testRlp.c // CoreTests // // Created by <NAME> on 7/23/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // #include <stdio.h> #include <stdlib.h> #include <assert.h> #include <string.h> #include "ethereum/util/BRUtil.h" #include "BRRlp.h" static void showHex (uint8_t *source, size_t sourceLen) { char *prefix = "{"; for (int i = 0; i < sourceLen; i++) { printf("%s%x", prefix, source[i]); prefix = ", "; } printf ("}\n"); } // // RLP Test // #define RLP_S1 "dog" #define RLP_S1_RES { 0x83, 'd', 'o', 'g' }; #define RLP_S2 "" #define RLP_S2_RES { 0x80 } #define RLP_S3 "Lorem ipsum dolor sit amet, consectetur adipisicing elit" #define RLP_S3_RES { 0xb8, 0x38, 'L', 'o', 'r', 'e', 'm', ' ', 'i', 'p', 's', 'u', 'm', ' ', 'd', 'o', 'l', 'o', 'r', \ ' ', 's', 'i', 't', ' ', 'a', 'm', 'e', 't', ',', ' ', 'c', 'o', 'n', 's', 'e', 'c', 't', 'e', 't', 'u', 'r', \ ' ', 'a', 'd', 'i', 'p', 'i', 's', 'i', 'c', 'i', 'n', 'g', ' ', 'e', 'l', 'i', 't' }; #define RLP_V1 0 #define RLP_V1_RES { 0x00 } #define RLP_V2 15 #define RLP_V2_RES { 0x0f } #define RLP_V3 1024 #define RLP_V3_RES { 0x82, 0x04, 0x00 } // 'cat', 'dog' #define RLP_L1_RES { 0xc8, 0x83, 'c', 'a', 't', 0x83, 'd', 'o', 'g' } int equalBytes (uint8_t *a, size_t aLen, uint8_t *b, size_t bLen) { if (aLen != bLen) return 0; for (int i = 0; i < aLen; i++) if (a[i] != b[i]) return 0; return 1; } void rlpCheck (BRRlpCoder coder, BRRlpItem item, uint8_t *result, size_t resultSize) { BRRlpData data = rlpGetData(coder, item); assert (equalBytes(data.bytes, data.bytesCount, result, resultSize)); printf (" => "); showHex (data.bytes, data.bytesCount); free (data.bytes); } void rlpCheckString (BRRlpCoder coder, const char *string, uint8_t *result, size_t resultSize) { printf (" \"%s\"", string); BRRlpItem item = rlpEncodeString(coder, (char*) string); rlpCheck(coder, item, result, resultSize); rlpReleaseItem(coder, item); } void rlpCheckInt (BRRlpCoder coder, uint64_t value, uint8_t *result, size_t resultSize) { printf (" %" PRIu64, value); BRRlpItem item = rlpEncodeUInt64(coder, value, 0); rlpCheck(coder, item, result, resultSize); rlpReleaseItem(coder, item); } void runRlpEncodeTest () { printf (" Encode\n"); BRRlpCoder coder = rlpCoderCreate(); uint8_t s1r[] = RLP_S1_RES; rlpCheckString(coder, RLP_S1, s1r, sizeof(s1r)); uint8_t s2r[] = RLP_S2_RES; rlpCheckString(coder, RLP_S2, s2r, sizeof(s2r)); uint8_t s3r[] = RLP_S3_RES; rlpCheckString(coder, RLP_S3, s3r, sizeof(s3r)); uint8_t t3r[] = RLP_V1_RES; rlpCheckInt(coder, RLP_V1, t3r, sizeof(t3r)); uint8_t t4r[] = RLP_V2_RES; rlpCheckInt(coder, RLP_V2, t4r, sizeof(t4r)); uint8_t t5r[] = RLP_V3_RES; rlpCheckInt(coder, RLP_V3,t5r, sizeof(t5r)); BRRlpItem listCatDog = rlpEncodeList2(coder, rlpEncodeString(coder, "cat"), rlpEncodeString(coder, "dog")); uint8_t resCatDog[] = RLP_L1_RES; printf (" \"%s\"", "[\"cat\" \"dog\"]"); rlpCheck(coder, listCatDog, resCatDog, 9); rlpReleaseItem(coder, listCatDog); BRCoreParseStatus status = CORE_PARSE_OK; char *value = "5968770000000000000000"; UInt256 r = createUInt256Parse(value, 10, &status); BRRlpItem item = rlpEncodeUInt256(coder, r, 0); BRRlpData data = rlpGetData(coder, item); rlpReleaseItem(coder, item); printf (" %s\n => ", value); showHex (data.bytes, data.bytesCount); char *dataHex = encodeHexCreate(NULL, data.bytes, data.bytesCount); printf (" => %s\n", dataHex); assert (0 == strcasecmp (dataHex, "8a01439152d319e84d0000")); free (dataHex); rlpCoderRelease(coder); printf ("\n"); } void runRlpDecodeTest () { printf (" Decode\n"); BRRlpCoder coder = rlpCoderCreate(); size_t c; // cat & dog uint8_t l1b[] = RLP_L1_RES; BRRlpData l1d; l1d.bytes = l1b; l1d.bytesCount = 9; BRRlpItem l1i = rlpGetItem(coder, l1d); const BRRlpItem *l1is = rlpDecodeList (coder, l1i, &c); assert (2 == c); char *liCat = rlpDecodeString(coder, l1is[0]); char *liDog = rlpDecodeString(coder, l1is[1]); assert (0 == strcmp (liCat, "cat")); assert (0 == strcmp (liDog, "dog")); rlpReleaseItem(coder, l1i); free (liCat); free (liDog); uint8_t s3b[] = RLP_S3_RES; BRRlpData s3d; s3d.bytes = s3b; s3d.bytesCount = 58; BRRlpItem s3i = rlpGetItem(coder, s3d); char *s3Lorem = rlpDecodeString(coder, s3i); assert (0 == strcmp (s3Lorem, RLP_S3)); rlpReleaseItem(coder, s3i); free (s3Lorem); // uint8_t v3b[] = RLP_V3_RES; BRRlpData v3d; v3d.bytes = v3b; v3d.bytesCount = 3; BRRlpItem v3i = rlpGetItem(coder, v3d); uint64_t v3v = rlpDecodeUInt64(coder, v3i, 0); assert (1024 == v3v); rlpReleaseItem(coder, v3i); rlpCoderRelease(coder); } void runRlpTests (void) { printf ("==== RLP\n"); runRlpEncodeTest (); runRlpDecodeTest (); }
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Database/PeerBlackList.h
<reponame>fakecoinbase/elastosslashElastos.ELA.SPV.Cpp /* * Copyright (c) 2019 Elastos Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef __ELASTOS_SDK_PEERBLACKLIST_H__ #define __ELASTOS_SDK_PEERBLACKLIST_H__ #include "Sqlite.h" #include "TableBase.h" #include "PeerDataSource.h" namespace Elastos { namespace ElaWallet { class PeerBlackList: public TableBase { public: PeerBlackList(Sqlite *sqlite, SqliteTransactionType type = IMMEDIATE); ~PeerBlackList(); virtual void InitializeTable(); bool PutPeer(const PeerEntity &peerEntity); bool PutPeers(const std::vector<PeerEntity> &peerEntities); bool DeletePeer(const PeerEntity &peerEntity); bool DeleteAllPeers(); size_t GetAllPeersCount() const; std::vector<PeerEntity> GetAllPeers() const; private: bool Contain(const PeerEntity &entity) const; bool PutPeerInternal(const PeerEntity &peerEntity); private: /* * peer black list table */ const std::string _peerBlackListTable = "peerBlackList"; const std::string _columnID = "_id"; const std::string _address = "peerAddress"; const std::string _port = "peerPort"; const std::string _timestamp = "peerTimestamp"; const std::string _tableCreateSql = "create table if not exists " + _peerBlackListTable + " (" + _columnID + " integer primary key autoincrement, " + _address + " blob," + _port + " integer," + _timestamp + " integer);"; }; } } #endif //__ELASTOS_SDK_PEERBLACKLIST_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Implement/MainchainSubWallet.h
<filename>SDK/Implement/MainchainSubWallet.h /* * Copyright (c) 2019 Elastos Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef __ELASTOS_SDK_MAINCHAINSUBWALLET_H__ #define __ELASTOS_SDK_MAINCHAINSUBWALLET_H__ #include "SidechainSubWallet.h" #include <IMainchainSubWallet.h> namespace Elastos { namespace ElaWallet { class IOutputPayload; typedef boost::shared_ptr<IOutputPayload> OutputPayloadPtr; class MainchainSubWallet : public IMainchainSubWallet, public SubWallet { public: ~MainchainSubWallet(); nlohmann::json CreateDepositTransaction( const std::string &fromAddress, const std::string &sideChainID, const std::string &amount, const std::string &sideChainAddress, const std::string &memo) override; public: ////////////////////////////////////////////////// /* Vote */ ////////////////////////////////////////////////// nlohmann::json CreateVoteProducerTransaction( const std::string &fromAddress, const std::string &stake, const nlohmann::json &publicKeys, const std::string &memo, const nlohmann::json &invalidCandidates) override; nlohmann::json GetVotedProducerList() const override; nlohmann::json CreateVoteCRTransaction( const std::string &fromAddress, const nlohmann::json &votes, const std::string &memo, const nlohmann::json &invalidCandidates) override; nlohmann::json GetVotedCRList() const override; nlohmann::json CreateVoteCRCProposalTransaction( const std::string &fromAddress, const nlohmann::json &votes, const std::string &memo, const nlohmann::json &invalidCandidates) override; nlohmann::json CreateImpeachmentCRCTransaction( const std::string &fromAddress, const nlohmann::json &votes, const std::string &memo, const nlohmann::json &invalidCandidates) override; nlohmann::json GetVoteInfo(const std::string &type) const override; public: ////////////////////////////////////////////////// /* Producer */ ////////////////////////////////////////////////// nlohmann::json GenerateProducerPayload(const std::string &ownerPublicKey, const std::string &nodePublicKey, const std::string &nickName, const std::string &url, const std::string &ipAddress, uint64_t location, const std::string &payPasswd) const override; nlohmann::json GenerateCancelProducerPayload(const std::string &ownerPublicKey, const std::string &payPasswd) const override; nlohmann::json CreateRegisterProducerTransaction(const std::string &fromAddress, const nlohmann::json &payload, const std::string &amount, const std::string &memo) override; nlohmann::json CreateUpdateProducerTransaction(const std::string &fromAddress, const nlohmann::json &payload, const std::string &memo) override; nlohmann::json CreateCancelProducerTransaction(const std::string &fromAddress, const nlohmann::json &payload, const std::string &emmo) override; nlohmann::json CreateRetrieveDepositTransaction(const std::string &amount, const std::string &memo) override; std::string GetOwnerPublicKey() const override; std::string GetOwnerAddress() const override; nlohmann::json GetRegisteredProducerInfo() const override; public: ////////////////////////////////////////////////// /* CRC */ ////////////////////////////////////////////////// nlohmann::json GenerateCRInfoPayload(const std::string &crPublicKey, const std::string &did, const std::string &nickName, const std::string &url, uint64_t location) const override; nlohmann::json GenerateUnregisterCRPayload(const std::string &CID) const override; nlohmann::json CreateRegisterCRTransaction(const std::string &fromAddress, const nlohmann::json &payloadJSON, const std::string &amount, const std::string &memo) override; nlohmann::json CreateUpdateCRTransaction(const std::string &fromAddress, const nlohmann::json &payloadJSON, const std::string &memo) override; nlohmann::json CreateUnregisterCRTransaction(const std::string &fromAddress, const nlohmann::json &payloadJSON, const std::string &memo) override; nlohmann::json CreateRetrieveCRDepositTransaction(const std::string &crPublicKey, const std::string &amount, const std::string &memo) override; nlohmann::json GetRegisteredCRInfo() const override; public: ////////////////////////////////////////////////// /* Proposal */ ////////////////////////////////////////////////// std::string ProposalOwnerDigest(const nlohmann::json &payload) const override; std::string ProposalCRCouncilMemberDigest(const nlohmann::json &payload) const override; std::string CalculateProposalHash(const nlohmann::json &payload) const override ; nlohmann::json CreateProposalTransaction(const nlohmann::json &payload, const std::string &memo) override; ////////////////////////////////////////////////// /* Proposal Review */ ////////////////////////////////////////////////// std::string ProposalReviewDigest(const nlohmann::json &payload) const override; nlohmann::json CreateProposalReviewTransaction(const nlohmann::json &payload, const std::string &memo) override; ////////////////////////////////////////////////// /* Proposal Tracking */ ////////////////////////////////////////////////// std::string ProposalTrackingOwnerDigest(const nlohmann::json &payload) const override; std::string ProposalTrackingNewOwnerDigest(const nlohmann::json &payload) const override; std::string ProposalTrackingSecretaryDigest(const nlohmann::json &payload) const override; nlohmann::json CreateProposalTrackingTransaction(const nlohmann::json &payload, const std::string &memo) override; ////////////////////////////////////////////////// /* Proposal Withdraw */ ////////////////////////////////////////////////// std::string ProposalWithdrawDigest(const nlohmann::json &payload) const override; nlohmann::json CreateProposalWithdrawTransaction(const std::string &recipient, const std::string &amount, const nlohmann::json &utxo, const nlohmann::json &payload, const std::string &memo) override; private: void FilterVoteCandidates(TransactionPtr &tx, const nlohmann::json &invalidCandidates) const; protected: friend class MasterWallet; MainchainSubWallet(const CoinInfoPtr &info, const ChainConfigPtr &config, MasterWallet *parent, const std::string &netType); TransactionPtr CreateVoteTx(const VoteContent &voteContent, const std::string &memo, bool max, VoteContentArray &dropedVotes); }; } } #endif //__ELASTOS_SDK_MAINCHAINSUBWALLET_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/les/msg/BREthereumMessagePIP.h
// // BREthereumMessagePIP.h // BRCore // // Created by <NAME> on 9/1/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // // See the LICENSE file at the project root for license information. // See the CONTRIBUTORS file at the project root for a list of contributors. #ifndef BR_Ethereum_Message_PIP_H #define BR_Ethereum_Message_PIP_H #include "ethereum/blockchain/BREthereumBlockChain.h" #include "ethereum/mpt/BREthereumMPT.h" #include "../BREthereumLESBase.h" #include "BREthereumMessageP2P.h" // BREthereumP2PMessageStatus #ifdef __cplusplus extern "C" { #endif /// MARK: PIP Requests typedef uint64_t BREthereumPIPRequestIdentifier; typedef uint64_t BREthereumPIPRequestCredits; typedef enum { PIP_REQUEST_HEADERS = 0x00, PIP_REQUEST_HEADER_PROOF = 0x01, PIP_REQUEST_TRANSACTION_INDEX = 0x02, PIP_REQUEST_BLOCK_RECEIPTS = 0x03, PIP_REQUEST_BLOCK_BODY = 0x04, PIP_REQUEST_ACCOUNT = 0x05, PIP_REQUEST_STORAGE = 0x06, PIP_REQUEST_CODE = 0x07, PIP_REQUEST_EXECUTION = 0x08 } BREthereumPIPRequestType; extern const char * messagePIPGetRequestName (BREthereumPIPRequestType type); /// Headers typedef struct { int useBlockNumber; union { uint64_t number; BREthereumHash hash; } block; uint64_t skip; uint64_t max; BREthereumBoolean reverse; } BREthereumPIPRequestHeadersInput; typedef struct { BRArrayOf(BREthereumBlockHeader) headers; } BREthereumPIPRequestHeadersOutput; extern void messagePIPRequestHeadersOutputConsume (BREthereumPIPRequestHeadersOutput *output, BRArrayOf(BREthereumBlockHeader) *headers); /// Header Proof typedef struct { uint64_t blockNumber; } BREthereumPIPRequestHeaderProofInput; typedef struct { // [U8](U8) // merkle inclusion proof from CHT BREthereumMPTNodePath path; BREthereumHash blockHash; UInt256 blockTotalDifficulty; } BREthereumPIPRequestHeaderProofOutput; extern void messagePIPRequestHeaderProofOutputConsume (BREthereumPIPRequestHeaderProofOutput *output, BREthereumMPTNodePath *path); /// Transaction Index typedef struct { BREthereumHash transactionHash; } BREthereumPIPRequestTransactionIndexInput; typedef struct { uint64_t blockNumber; BREthereumHash blockHash; uint64_t transactionIndex; } BREthereumPIPRequestTransactionIndexOutput; /// Block Receipts typedef struct { BREthereumHash blockHash; } BREthereumPIPRequestBlockReceiptInput; typedef struct { BRArrayOf(BREthereumTransactionReceipt) receipts; } BREthereumPIPRequestBlockReceiptOutput; /// Block Body typedef struct { BREthereumHash blockHash; } BREthereumPIPRequestBlockBodyInput; typedef struct { BRArrayOf(BREthereumBlockHeader) headers; BRArrayOf(BREthereumTransaction) transactions; } BREthereumPIPRequestBlockBodyOutput; /// Account typedef struct { BREthereumHash blockHash; BREthereumHash addressHash; } BREthereumPIPRequestAccountInput; typedef struct { // [U8](U8) // merkle inclusion proof from state trie uint64_t nonce; UInt256 balance; BREthereumHash codeHash; BREthereumHash storageRootHash; } BREthereumPIPRequestAccountOutput; /// Storage typedef struct { BREthereumHash blockHash; BREthereumHash addressHash; BREthereumHash storageRootHash; // storageKey? } BREthereumPIPRequestStorageInput; typedef struct { // [U8](U8) // merkle inclusion proof from storage trie BREthereumHash storageValueHash; } BREthereumPIPRequestStorageOutput; /// Code typedef struct { BREthereumHash blockHash; BREthereumHash codeHash; } BREthereumPIPRequestCodeInput; typedef struct { BRArrayOf(uint8_t) bytecode; } BREthereumPIPRequestCodeOutput; /// Execution typedef struct { BREthereumHash blockHash; BREthereumAddress address; int isCall; union { BREthereumAddress address; // empty } call; uint64_t gasToProve; uint64_t gasPrice; uint64_t valueToTransfer; BRArrayOf(uint8_t) callData; } BREthereumPIPRequestExecutionInput; typedef struct { // [U8](U8) // state items necessary to prove execution } BREthereumPIPRequestExecutionOutput; /// MARK: Request Input / Output typedef struct { BREthereumPIPRequestType identifier; union { BREthereumPIPRequestHeadersInput headers; BREthereumPIPRequestHeaderProofInput headerProof; BREthereumPIPRequestTransactionIndexInput transactionIndex; BREthereumPIPRequestBlockReceiptInput blockReceipt; BREthereumPIPRequestBlockBodyInput blockBody; BREthereumPIPRequestAccountInput account; BREthereumPIPRequestStorageInput storage; BREthereumPIPRequestCodeInput code; BREthereumPIPRequestExecutionInput execution; } u; } BREthereumPIPRequestInput; typedef struct { BREthereumPIPRequestType identifier; union { BREthereumPIPRequestHeadersOutput headers; BREthereumPIPRequestHeaderProofOutput headerProof; BREthereumPIPRequestTransactionIndexOutput transactionIndex; BREthereumPIPRequestBlockReceiptOutput blockReceipt; BREthereumPIPRequestBlockBodyOutput blockBody; BREthereumPIPRequestAccountOutput account; BREthereumPIPRequestStorageOutput storage; BREthereumPIPRequestCodeOutput code; BREthereumPIPRequestExecutionOutput execution; } u; } BREthereumPIPRequestOutput; /// MARK: PIP Messages typedef enum { PIP_MESSAGE_STATUS = 0x00, PIP_MESSAGE_ANNOUNCE = 0x01, PIP_MESSAGE_REQUEST = 0x02, PIP_MESSAGE_RESPONSE = 0x03, PIP_MESSAGE_UPDATE_CREDIT_PARAMETERS = 0x04, PIP_MESSAGE_ACKNOWLEDGE_UPDATE = 0x05, PIP_MESSAGE_RELAY_TRANSACTIONS = 0x06, } BREthereumPIPMessageType; typedef struct { BREthereumP2PMessageStatus p2p; } BREthereumPIPMessageStatus; extern void messagePIPStatusShow(BREthereumPIPMessageStatus *status); typedef struct { BREthereumHash headHash; uint64_t headNumber; UInt256 headTotalDifficulty; uint64_t reorgDepth; BRArrayOf(BREthereumP2PMessageStatusKeyValuePair) pairs; } BREthereumPIPMessageAnnounce; typedef struct { BREthereumPIPRequestIdentifier reqId; BRArrayOf(BREthereumPIPRequestInput) inputs; } BREthereumPIPMessageRequest; typedef struct { BREthereumPIPRequestIdentifier reqId; BREthereumPIPRequestCredits credits; BRArrayOf(BREthereumPIPRequestOutput) outputs; } BREthereumPIPMessageResponse; /** * Consume the `message` `outputs`. Modify message so that a subsequent `messagePIPRelease()` * recognizes the `outputs` are now owned elsewhere. */ extern void messagePIPResponseConsume (BREthereumPIPMessageResponse *message, BRArrayOf(BREthereumPIPRequestOutput) *outputs); typedef struct { UInt256 max; UInt256 recharge; // cost table } BREthereumPIPMessageUpdateCreditParameters; typedef struct {} BREthereumPIPMessageAcknowledgeUpdate; typedef struct { BRArrayOf(BREthereumTransaction) transactions; } BREthereumPIPMessageRelayTransactions; /** * An PIP Message is one of the above PIP message types. */ typedef struct { BREthereumPIPMessageType type; union { BREthereumPIPMessageStatus status; BREthereumPIPMessageAnnounce announce; BREthereumPIPMessageRequest request; BREthereumPIPMessageResponse response; BREthereumPIPMessageUpdateCreditParameters updateCreditParameters; BREthereumPIPMessageAcknowledgeUpdate acknowledgeUpdate; BREthereumPIPMessageRelayTransactions relayTransactions; } u; } BREthereumPIPMessage; extern BRRlpItem messagePIPEncode (BREthereumPIPMessage message, BREthereumMessageCoder coder); extern BREthereumPIPMessage messagePIPDecode (BRRlpItem item, BREthereumMessageCoder coder, BREthereumPIPMessageType identifier); extern void messagePIPRelease (BREthereumPIPMessage *message); extern uint64_t messagePIPGetCredits (const BREthereumPIPMessage *message); extern uint64_t messagePIPGetCreditsCount (const BREthereumPIPMessage *message); #define PIP_MESSAGE_NO_REQUEST_ID (-1) extern size_t messagePIPGetRequestId (const BREthereumPIPMessage *message); extern const char * messagePIPGetIdentifierName (BREthereumPIPMessage message); #ifdef __cplusplus } #endif #endif /* BR_Ethereum_Message_PIP_H */
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/blockchain/BREthereumBloomFilter.h
// // BREthereumBloomFilter.h // BRCore // // Created by <NAME> on 5/10/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // // See the LICENSE file at the project root for license information. // See the CONTRIBUTORS file at the project root for a list of contributors. #ifndef BR_Ethereum_Bloom_Filter_h #define BR_Ethereum_Bloom_Filter_h #include "ethereum/base/BREthereumBase.h" #ifdef __cplusplus extern "C" { #endif #define ETHEREUM_BLOOM_FILTER_BITS 2048 #define ETHEREUM_BLOOM_FILTER_BYTES (ETHEREUM_BLOOM_FILTER_BITS / 8) /** * An Etereum Bloom Filter is a 2048-bit 'fuzzy' representation of one or more addresses. */ typedef struct { uint8_t bytes[ETHEREUM_BLOOM_FILTER_BYTES]; } BREthereumBloomFilter; #define EMPTY_BLOOM_FILTER_INIT ((const BREthereumBloomFilter) { \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ }) /** * Create an empty BloomFilter */ extern BREthereumBloomFilter bloomFilterCreateEmpty (void); /** * Create a BloomFilter from `hash` */ extern BREthereumBloomFilter bloomFilterCreateHash (const BREthereumHash hash); /** * Create a BloomFilter from `data` - computes the hash of `data` */ extern BREthereumBloomFilter bloomFilterCreateData (const BRRlpData data); /** * Create a BloomFilter from `address` - computes the hash of `address` */ extern BREthereumBloomFilter bloomFilterCreateAddress (const BREthereumAddress address); /** * Create a BloomFilter from a hex-encoded, non-0x-prefaced string. */ extern BREthereumBloomFilter bloomFilterCreateString (const char *string); extern BREthereumBloomFilter bloomFilterOr (const BREthereumBloomFilter filter1, const BREthereumBloomFilter filter2); extern void bloomFilterOrInPlace (BREthereumBloomFilter filter1, const BREthereumBloomFilter filter2); extern BREthereumBoolean bloomFilterEqual (const BREthereumBloomFilter filter1, const BREthereumBloomFilter filter2); /** * Check if `other` is contained in `filter`. Typically `filter` would be the bloom filter * for a block header and `other` would be an address (source,target,contract) of * interest. * * @parameter filter * * @parameter other * * @returns TRUE if `other` matches `filter`; otherwise FALSE */ extern BREthereumBoolean bloomFilterMatch (const BREthereumBloomFilter filter, const BREthereumBloomFilter other); extern BRRlpItem bloomFilterRlpEncode(BREthereumBloomFilter filter, BRRlpCoder coder); extern BREthereumBloomFilter bloomFilterRlpDecode (BRRlpItem item, BRRlpCoder coder); /** * Return a hex-encode string representation of `filter`. */ extern char * bloomFilterAsString (BREthereumBloomFilter filter); #ifdef __cplusplus } #endif #endif /* BR_Ethereum_Bloom_Filter_h */
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Plugin/Transaction/Payload/CRCProposalWithdraw.h
<filename>SDK/Plugin/Transaction/Payload/CRCProposalWithdraw.h /* * Copyright (c) 2020 Elastos Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef __ELASTOS_SPVSDK_CRCPROPOSALWITHDRAW_H__ #define __ELASTOS_SPVSDK_CRCPROPOSALWITHDRAW_H__ #include "IPayload.h" namespace Elastos { namespace ElaWallet { #define CRCProposalWithdrawVersion 0 class CRCProposalWithdraw : public IPayload { public: CRCProposalWithdraw(); ~CRCProposalWithdraw(); void SetProposalHash(const uint256 &hash); const uint256 &GetProposalHash() const; void SetOwnerPublicKey(const bytes_t &pubkey); const bytes_t &GetOwnerPublicKey() const; void SetSignature(const bytes_t &signature); const bytes_t &GetSignature() const; const uint256 &DigestUnsigned(uint8_t version) const; public: virtual size_t EstimateSize(uint8_t version) const; void SerializeUnsigned(ByteStream &stream, uint8_t version) const; virtual void Serialize(ByteStream &stream, uint8_t version) const; bool DeserializeUnsigned(const ByteStream &stream, uint8_t version); virtual bool Deserialize(const ByteStream &stream, uint8_t version); nlohmann::json ToJsonUnsigned(uint8_t version) const; virtual nlohmann::json ToJson(uint8_t version) const; void FromJsonUnsigned(const nlohmann::json &j, uint8_t version); virtual void FromJson(const nlohmann::json &j, uint8_t version); bool IsValidUnsigned(uint8_t versin) const; virtual bool IsValid(uint8_t version) const; virtual IPayload &operator=(const IPayload &payload); CRCProposalWithdraw &operator=(const CRCProposalWithdraw &payload); private: mutable uint256 _digest; private: uint256 _proposalHash; bytes_t _ownerPubkey; bytes_t _signature; }; } } #endif
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Database/TableBase.h
/* * Copyright (c) 2019 Elastos Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef __ELASTOS_SDK_TABLEBASE_H__ #define __ELASTOS_SDK_TABLEBASE_H__ #include "Sqlite.h" #include <CMakeConfig.h> #include <boost/function.hpp> namespace Elastos { namespace ElaWallet { #define ISO_OLD "ela" #define ISO "ela1" class TableBase { public: TableBase(Sqlite *sqlite); TableBase(SqliteTransactionType type, Sqlite *sqlite); virtual void InitializeTable(); virtual ~TableBase(); void flush(); protected: bool ContainTable(const std::string &tableName) const; void InitializeTable(const std::string &constructScript); bool DoTransaction(const boost::function<bool()> &fun) const; bool DeleteAll(const std::string &tableName); protected: Sqlite *_sqlite; SqliteTransactionType _txType; }; } } #endif //__ELASTOS_SDK_TABLEBASE_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Common/JsonGenerator.h
<reponame>fakecoinbase/elastosslashElastos.ELA.SPV.Cpp /* * Copyright (c) 2019 Elastos Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef __JSON_GENERATOR_H__ #define __JSON_GENERATOR_H__ #include <stddef.h> #include <stdio.h> #include <stdint.h> #include <stdbool.h> #ifdef __cplusplus extern "C" { #endif #define JSON_GENERATOR_MAX_DEEPS 32 typedef struct JsonGenerator { size_t capacity; size_t pos; short deep; uint8_t state[JSON_GENERATOR_MAX_DEEPS]; char *buffer; } JsonGenerator; JsonGenerator *JsonGenerator_Initialize(JsonGenerator *generator); int JsonGenerator_WriteStartObject(JsonGenerator *generator); int JsonGenerator_WriteEndObject(JsonGenerator *generator); int JsonGenerator_WriteStartArray(JsonGenerator *generator); int JsonGenerator_WriteEndArray(JsonGenerator *generator); int JsonGenerator_WriteFieldName(JsonGenerator *generator, const char *name); int JsonGenerator_WriteString(JsonGenerator *generator, const char *value); int JsonGenerator_WriteNumber(JsonGenerator *generator, int value); int JsonGenerator_WriteDouble(JsonGenerator *generator, double value); int JsonGenerator_WriteBoolean(JsonGenerator *generator, bool value); int JsonGenerator_WriteStringField(JsonGenerator *generator, const char *name, const char *value); const char *JsonGenerator_Finish(JsonGenerator *generator); void JsonGenerator_Destroy(JsonGenerator *generator); /* void JsonGenerator_Destroy(JsonGenerator *generator); */ #ifdef __cplusplus } #endif #endif //__JSON_GENERATOR_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/support/BRFileService.c
<reponame>fakecoinbase/elastosslashElastos.ELA.SPV.Cpp // // BRFileService.c // Core // // Created by <NAME> on 1/4/19. // Copyright ยฉ 2019 breadwallet LLC // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. #include "BRFileService.h" #include "BRArray.h" #include <stdio.h> #include <string.h> #include <dirent.h> #include <sys/stat.h> #include <errno.h> #define FILE_SERVICE_INITIAL_TYPE_COUNT (5) #define FILE_SERVICE_INITIAL_HANDLER_COUNT (2) /// Return 0 on success, -1 otherwise static int directoryMake (const char *path) { struct stat dirStat; if (0 == stat (path, &dirStat)) return 0; // if exists, success if (0 != mkdir (path, 0700)) return -1; // if can't create, error if (0 == stat (path, &dirStat)) return 0; // if exists, success return -1; // otherwise error } // This must be coercible to/from a uint8_t forever. typedef enum { HEADER_FORMAT_1 } BRFileServiceHeaderFormatVersion; static BRFileServiceHeaderFormatVersion currentHeaderFormatVersion = HEADER_FORMAT_1; /// /// The handlers for a particular entity's version /// typedef struct { BRFileServiceVersion version; BRFileServiceContext context; BRFileServiceIdentifier identifier; BRFileServiceReader reader; BRFileServiceWriter writer; } BRFileServiceEntityHandler; /// /// The set of handlers, by version, for a particular entity. /// typedef struct { char *type; BRFileServiceVersion currentVersion; BRArrayOf(BRFileServiceEntityHandler) handlers; } BRFileServiceEntityType; static void fileServiceEntityTypeRelease (const BRFileServiceEntityType *entityType) { free (entityType->type); if (NULL != entityType->handlers) array_free(entityType->handlers); } static BRFileServiceEntityHandler * fileServiceEntityTypeLookupHandler (const BRFileServiceEntityType *entityType, BRFileServiceVersion version) { size_t handlersCount = array_count(entityType->handlers); for (size_t index = 0; index < handlersCount; index++) if (version == entityType->handlers[index].version) return &entityType->handlers[index]; return NULL; } static void fileServiceEntityTypeAddHandler (BRFileServiceEntityType *entityType, const BRFileServiceEntityHandler *handler) { // Lookup an existing handler: BRFileServiceEntityHandler *existingHandler = fileServiceEntityTypeLookupHandler(entityType, handler->version); if (NULL == existingHandler) // if none, add one array_add (entityType->handlers, *handler); else // if some, update *existingHandler = *handler; } /// /// /// struct BRFileServiceRecord { const char *pathToType; BRArrayOf(BRFileServiceEntityType) entityTypes; BRFileServiceContext context; BRFileServiceErrorHandler handler; }; extern BRFileService fileServiceCreate (const char *basePath, const char *currency, const char *network, BRFileServiceContext context, BRFileServiceErrorHandler handler) { // Reasonable limits on `network` and `currency` (ensure subsequent stack allocation works). if (strlen(network) > FILENAME_MAX || strlen(currency) > FILENAME_MAX) return NULL; // Make directory if needed. if (-1 == directoryMake(basePath)) return NULL; // Require `basePath` to be an existing directory. DIR *dir = opendir(basePath); if (NULL == dir) return NULL; closedir(dir); // Create the directory hierarchy size_t pathToTypeSize = strlen(basePath) + 1 + strlen(currency) + 1 + strlen(network) + 1; char dirPath[pathToTypeSize]; sprintf (dirPath, "%s/%s", basePath, currency); if (-1 == directoryMake(dirPath)) return NULL; sprintf(dirPath, "%s/%s/%s", basePath, currency, network); if (-1 == directoryMake(dirPath)) return NULL; BRFileService fs = calloc (1, sizeof (struct BRFileServiceRecord)); fs->pathToType = strdup(dirPath); array_new (fs->entityTypes, FILE_SERVICE_INITIAL_TYPE_COUNT); fileServiceSetErrorHandler (fs, context, handler); return fs; } extern void fileServiceRelease (BRFileService fs) { size_t typesCount = array_count(fs->entityTypes); for (size_t index = 0; index < typesCount; index++) fileServiceEntityTypeRelease (&fs->entityTypes[index]); free ((char *) fs->pathToType); if (NULL != fs->entityTypes) array_free (fs->entityTypes); free (fs); } extern void fileServiceSetErrorHandler (BRFileService fs, BRFileServiceContext context, BRFileServiceErrorHandler handler) { fs->context = context; fs->handler = handler; } static BRFileServiceEntityType * fileServiceLookupType (const BRFileService fs, const char *type) { size_t typeCount = array_count(fs->entityTypes); for (size_t index = 0; index < typeCount; index++) if (0 == strcmp (type, fs->entityTypes[index].type)) return &fs->entityTypes[index]; return NULL; } static BRFileServiceEntityType * fileServiceAddType (const BRFileService fs, const char *type, BRFileServiceVersion version) { BRFileServiceEntityType entityType = { strdup (type), version, NULL }; array_new (entityType.handlers, FILE_SERVICE_INITIAL_HANDLER_COUNT); array_add (fs->entityTypes, entityType); return &fs->entityTypes[array_count(fs->entityTypes) - 1]; } static BRFileServiceEntityHandler * fileServiceLookupEntityHandler (const BRFileService fs, const char *type, BRFileServiceVersion version) { BRFileServiceEntityType *entityType = fileServiceLookupType (fs, type); return (NULL == entityType ? NULL : fileServiceEntityTypeLookupHandler (entityType, version)); } /// MARK: - Failure Reporting static int fileServiceFailedInternal (BRFileService fs, void* bufferToFree, FILE* fileToClose, BRFileServiceError error) { if (NULL != bufferToFree) free (bufferToFree); if (NULL != fileToClose) fclose (fileToClose); if (NULL != fs->handler) fs->handler (fs->context, fs, error); return 0; } static int fileServiceFailedImpl(BRFileService fs, void* bufferToFree, FILE* fileToClose, const char *reason) { return fileServiceFailedInternal (fs, bufferToFree, fileToClose, (BRFileServiceError) { FILE_SERVICE_IMPL, { .impl = { reason }} }); } static int fileServiceFailedUnix(BRFileService fs, void* bufferToFree, FILE* fileToClose, int error) { return fileServiceFailedInternal (fs, bufferToFree, fileToClose, (BRFileServiceError) { FILE_SERVICE_UNIX, { ._unix = {error }} }); } static int fileServiceFailedEntity(BRFileService fs, void* bufferToFree, FILE* fileToClose, const char *type, const char *reason) { return fileServiceFailedInternal (fs, bufferToFree, fileToClose, (BRFileServiceError) { FILE_SERVICE_ENTITY, { .entity = { type, reason }} }); } /// MARK: - Load extern int fileServiceLoad (BRFileService fs, BRSet *results, const char *type, int updateVersion) { BRFileServiceEntityType *entityType = fileServiceLookupType (fs, type); if (NULL == entityType) return fileServiceFailedImpl (fs, NULL, NULL, "missed type"); BRFileServiceEntityHandler *entityHandlerCurrent = fileServiceEntityTypeLookupHandler(entityType, entityType->currentVersion); if (NULL == entityHandlerCurrent) return fileServiceFailedImpl (fs, NULL, NULL, "missed type handler"); DIR *dir; struct dirent *dirEntry; char dirPath[strlen(fs->pathToType) + 1 + strlen(type) + 1]; sprintf (dirPath, "%s/%s", fs->pathToType, type); char filename[strlen(dirPath) + 1 + 2 * sizeof(UInt256) + 1]; if (-1 == directoryMake(dirPath) || NULL == (dir = opendir(dirPath))) return fileServiceFailedUnix (fs, NULL, NULL, errno); // Allocate some storage for entity bytes; size_t bufferSize = 8 * 1024; uint8_t *buffer = malloc (bufferSize); if (NULL == buffer) return fileServiceFailedUnix (fs, NULL, NULL, ENOMEM); // Process each directory entry. while (NULL != (dirEntry = readdir(dir))) if (dirEntry->d_type == DT_REG) { sprintf (filename, "%s/%s", dirPath, dirEntry->d_name); FILE *file = fopen (filename, "rb"); if (NULL == file) return fileServiceFailedUnix (fs, buffer, NULL, errno); BRFileServiceVersion version; uint32_t bytesCount; // read the header version BRFileServiceHeaderFormatVersion headerVersion; if (1 != fread (&headerVersion, sizeof(BRFileServiceHeaderFormatVersion), 1, file)) return fileServiceFailedUnix (fs, buffer, file, errno); // read the header switch (headerVersion) { case HEADER_FORMAT_1: { // read the version if (1 != fread (&version, sizeof(BRFileServiceVersion), 1, file) || // read the checksum // read the bytesCount 1 != fread (&bytesCount, sizeof(uint32_t), 1, file)) return fileServiceFailedUnix (fs, buffer, file, errno); break; } } // Ensure `buffer` is large enough if (bytesCount > bufferSize) { bufferSize = bytesCount; uint8_t *bufferNew = realloc (buffer, bufferSize); if (NULL == bufferNew) return fileServiceFailedUnix (fs, buffer, NULL, ENOMEM); buffer = bufferNew; } // read the bytes - multiple might be required if (bytesCount != fread (buffer, 1, bytesCount, file)) return fileServiceFailedUnix (fs, buffer, file, errno); // All file reading is complete; next read should be EOF. // Done with file. if (0 != fclose (file)) return fileServiceFailedUnix (fs, buffer, NULL, errno); // We now have everything // This will need some later rework. If a header includes some data, like a checksum, // we won't have that value in this context when needed. // Do something header specific switch (headerVersion) { case HEADER_FORMAT_1: // compute the checksum // compare the checksum break; } // Look up the entity handler BRFileServiceEntityHandler *handler = fileServiceEntityTypeLookupHandler(entityType, version); if (NULL == handler) return fileServiceFailedImpl (fs, buffer, NULL, "missed type handler"); // Read the entity from buffer and add to results. void *entity = handler->reader (handler->context, fs, buffer, bytesCount); if (NULL == entity) return fileServiceFailedEntity (fs, buffer, NULL, type, "reader"); // Update restuls with the newly restored entity BRSetAdd (results, entity); // If the read version is not the current version, update if (updateVersion && (version != entityType->currentVersion || headerVersion != currentHeaderFormatVersion)) fileServiceSave (fs, type, entity); } free (buffer); closedir (dir); return 1; } /// MARK: - Save extern void /* error code? */ fileServiceSave (BRFileService fs, const char *type, /* block, peers, transactions, logs, ... */ const void *entity) { /* BRMerkleBlock*, BRTransaction, BREthereumTransaction, ... */ BRFileServiceEntityType *entityType = fileServiceLookupType (fs, type); if (NULL == entityType) { fileServiceFailedImpl (fs, NULL, NULL, "missed type"); return; }; BRFileServiceEntityHandler *handler = fileServiceEntityTypeLookupHandler(entityType, entityType->currentVersion); if (NULL == handler) { fileServiceFailedImpl (fs, NULL, NULL, "missed type handler"); return; }; UInt256 identifier = handler->identifier (handler->context, fs, entity); uint32_t bytesCount; uint8_t *bytes = handler->writer (handler->context, fs, entity, &bytesCount); char filename[strlen(fs->pathToType) + 1 + strlen(type) + 1 + 2*sizeof(UInt256) + 1]; sprintf (filename, "%s/%s/%s", fs->pathToType, type, u256hex(identifier)); FILE *file = fopen (filename, "wb"); if (NULL == file) { fileServiceFailedUnix (fs, bytes, NULL, errno); return; } // Always, always write the header for the currentHeaderFormatVersion if (// write the header version 1 != fwrite(&currentHeaderFormatVersion, sizeof(BRFileServiceHeaderFormatVersion), 1, file) || // then the version 1 != fwrite (&entityType->currentVersion, sizeof(BRFileServiceVersion), 1, file) || // then the checksum? // write the bytesCount 1 != fwrite(&bytesCount, sizeof (uint32_t), 1, file)) { fileServiceFailedUnix (fs, bytes, file, errno); return; } // write the bytes. if (bytesCount != fwrite(bytes, 1, bytesCount, file)) { fileServiceFailedUnix (fs, bytes, file, errno); return; } if (0 != fclose (file)) { fileServiceFailedUnix (fs, bytes, NULL, errno); return; } free (bytes); } /// MARK: - Remove, Clear extern void fileServiceRemove (BRFileService fs, const char *type, UInt256 identifier) { BRFileServiceEntityType *entityType = fileServiceLookupType (fs, type); if (NULL == entityType) { fileServiceFailedImpl (fs, NULL, NULL, "missed type"); return; }; char filename[strlen(fs->pathToType) + 1 + strlen(type) + 1 + 2*sizeof(UInt256) + 1]; sprintf (filename, "%s/%s/%s", fs->pathToType, type, u256hex(identifier)); // If failed, then what? remove (filename); } static void fileServiceClearForType (BRFileService fs, BRFileServiceEntityType *entityType) { DIR *dir; struct dirent *dirEntry; char dirPath[strlen(fs->pathToType) + 1 + strlen(entityType->type) + 1]; sprintf (dirPath, "%s/%s", fs->pathToType, entityType->type); if (-1 == directoryMake(dirPath) || NULL == (dir = opendir(dirPath))) { fileServiceFailedUnix (fs, NULL, NULL, errno); return; } while (NULL != (dirEntry = readdir(dir))) if (dirEntry->d_type == DT_REG) remove (dirEntry->d_name); // If failed, then what? closedir(dir); } extern void fileServiceClear (BRFileService fs, const char *type) { BRFileServiceEntityType *entityType = fileServiceLookupType (fs, type); if (NULL == entityType) { fileServiceFailedImpl (fs, NULL, NULL, "missed type"); return; }; fileServiceClearForType(fs, entityType); } extern void fileServiceClearAll (BRFileService fs) { size_t typeCount = array_count(fs->entityTypes); for (size_t index = 0; index < typeCount; index++) fileServiceClearForType (fs, &fs->entityTypes[index]); } extern int fileServiceDefineType (BRFileService fs, const char *type, BRFileServiceVersion version, BRFileServiceContext context, BRFileServiceIdentifier identifier, BRFileServiceReader reader, BRFileServiceWriter writer) { // Lookup the entityType for `type` BRFileServiceEntityType *entityType = fileServiceLookupType (fs, type); // If there isn't an entityType, create one. if (NULL == entityType) entityType = fileServiceAddType (fs, type, version); // Create a handler for the entity BRFileServiceEntityHandler newEntityHander = { version, context, identifier, reader, writer }; // Lookup an existing entityHandler for `version` BRFileServiceEntityHandler *entityHandler = fileServiceLookupEntityHandler (fs, type, version); // If there is an entityHandler, update it. if (NULL != entityHandler) *entityHandler = newEntityHander; // otherwise add one else { // Confirm that the directory can be made. char dirPath[strlen(fs->pathToType) + 1 + strlen(type) + 1]; sprintf (dirPath, "%s/%s", fs->pathToType, type); if (-1 == directoryMake(dirPath)) return fileServiceFailedUnix (fs, NULL, NULL, errno); fileServiceEntityTypeAddHandler (entityType, &newEntityHander); } return 1; } extern int fileServiceDefineCurrentVersion (BRFileService fs, const char *type, BRFileServiceVersion version) { // Find the entityType for `type` BRFileServiceEntityType *entityType = fileServiceLookupType (fs, type); if (NULL == entityType) return fileServiceFailedImpl (fs, NULL, NULL, "missed type"); // Find the entityHandler, for version. BRFileServiceEntityHandler *entityHandler = fileServiceEntityTypeLookupHandler (entityType, version); if (NULL == entityHandler) return fileServiceFailedImpl (fs, NULL, NULL, "missed type handler"); // We have a handler, therefore it can be the current one. entityType->currentVersion = version; return 1; }
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/bcs/BREthereumBlockChainSlice.h
// // BREthereumBlockChainSlice.h // BRCore // // Created by <NAME> on 5/24/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // // See the LICENSE file at the project root for license information. // See the CONTRIBUTORS file at the project root for a list of contributors. #ifndef BR_Ethereum_BlockChain_Slice_h #define BR_Ethereum_BlockChain_Slice_h #include "BREthereumBCS.h" #endif /* BR_Ethereum_BlockChain_Slice_h */
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/test.c
// // test // breadwallet-core Ethereum // // Created by <NAME> on 2/27/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // // See the LICENSE file at the project root for license information. // See the CONTRIBUTORS file at the project root for a list of contributors. #include <stdio.h> #include <stdlib.h> #include <string.h> #include <inttypes.h> #include <errno.h> #include <time.h> #include <unistd.h> #include <arpa/inet.h> #include <assert.h> #include <pthread.h> #include "support/BRInt.h" #include "support/BRArray.h" #include "support/BRSet.h" #include "support/BRCrypto.h" #include "support/BRBIP39WordsEn.h" #include "ethereum/event/BREventAlarm.h" #include "ethereum/blockchain/BREthereumBlockChain.h" #include "ethereum/ewm/BREthereumAccount.h" #include "ethereum/ewm/BREthereumWallet.h" #include "ethereum/ewm/BREthereumTransfer.h" #include "BREthereum.h" #include "test.h" extern const char *tokenBRDAddress; // // Ether & Token Parse // /* m/44'/60'/0'/0/0 :: 0x2161DedC3Be05B7Bb5aa16154BcbD254E9e9eb68 0x03c026c4b041059c84a187252682b6f80cbbe64eb81497111ab6914b050a8936fd 0x73bf21bf06769f98dabcfac16c2f74e852da823effed12794e56876ede02d45d m/44'/60'/0'/0/1 :: 0x9595F373a4eAe74511561A52998cc6fB4F9C2bdD */ // // Account Test // #define TEST_PAPER_KEY "army van defense carry jealous true garbage claim echo media make crunch" #define TEST_ETH_ADDR_CHK "0x2161DedC3Be05B7Bb5aa16154BcbD254E9e9eb68" #define TEST_ETH_ADDR "0x2161dedc3be05b7bb5aa16154bcbd254e9e9eb68" // This is a compressed public key; we generate uncompress public keys as { 04 x y } #define TEST_ETH_PUBKEY "<KEY>" #define TEST_ETH_PRIKEY "0x73bf21bf06769f98dabcfac16c2f74e852da823effed12794e56876ede02d45d" void runAddressTests (BREthereumAccount account) { BREthereumAddress address = accountGetPrimaryAddress(account); printf ("== Address\n"); printf (" String: %p\n", &address); printf (" PaperKey: %p, %s\n", TEST_PAPER_KEY, TEST_PAPER_KEY); #if defined (DEBUG) const char *publicKeyString = accountGetPrimaryAddressPublicKeyString(account, 1); printf (" Public Key: %p, %s\n", publicKeyString, publicKeyString); assert (0 == strcmp (TEST_ETH_PUBKEY, publicKeyString)); free ((void *) publicKeyString); #endif const char *addressString = addressGetEncodedString(address, 1); printf (" Address: %s\n", addressString); assert (0 == strcmp (TEST_ETH_ADDR, addressString) || 0 == strcmp (TEST_ETH_ADDR_CHK, addressString)); assert (0 == accountGetAddressNonce(account, address)); assert (0 == accountGetThenIncrementAddressNonce(account, address)); assert (1 == accountGetAddressNonce(account, address)); accountSetAddressNonce(account, address, 0, ETHEREUM_BOOLEAN_FALSE); assert (1 == accountGetAddressNonce(account, address)); accountSetAddressNonce(account, address, 0, ETHEREUM_BOOLEAN_TRUE); assert (0 == accountGetAddressNonce(account, address)); accountSetAddressNonce(account, address, 2, ETHEREUM_BOOLEAN_FALSE); assert (2 == accountGetAddressNonce(account, address)); free ((void *) addressString); } // // Transaction Tests // // Take some transactions from 'etherscan.io'; duplicate their content; ensure we process them // correctly. Check the // Consider a transaction with nonce = 9, gasprice = 20 * 10**9, startgas = 21000, // to = 0x3535353535353535353535353535353535353535, value = 10**18, data='' (empty). // // The "signing data" becomes: // 0xec 09 8504a817c800 825208 943535353535353535353535353535353535353535 880de0b6b3a7640000 80 01 80 80 // 09 8504a817c800 825208 943535353535353535353535353535353535353535 880de0b6b3a7640000 80 // 09 8504a817c800 825208 943535353535353535353535353535353535353535 880de0b6b3a7640000 80 // The "signing hash" becomes: // 0x2691916f9e6e5b304f135496c08f632040f02d78e36ae5bbbb38f919730c8fa0 #define TEST_TRANS1_NONCE 9 #define TEST_TRANS1_GAS_PRICE_VALUE 20000000000 // 20 GWEI #define TEST_TRANS1_GAS_PRICE_UNIT WEI #define TEST_TRANS1_GAS_LIMIT 21000 #define TEST_TRANS1_TARGET_ADDRESS "0x3535353535353535353535353535353535353535" #define TEST_TRANS1_ETHER_AMOUNT 1000000000000000000u // 1 ETHER #define TEST_TRANS1_ETHER_AMOUNT_UNIT WEI #define TEST_TRANS1_DATA "" #define TEST_TRANS1_RESULT "ec098504a817c800825208943535353535353535353535353535353535353535880de0b6b3a764000080018080" void runTransactionTests1 (BREthereumAccount account, BREthereumNetwork network) { printf (" TEST 1\n"); BREthereumWallet wallet = walletCreate(account, network); walletSetDefaultGasLimit(wallet, gasCreate(TEST_TRANS1_GAS_LIMIT)); walletSetDefaultGasPrice(wallet, gasPriceCreate(etherCreateNumber(TEST_TRANS1_GAS_PRICE_VALUE, TEST_TRANS1_GAS_PRICE_UNIT))); BREthereumTransfer transfer = walletCreateTransfer(wallet, addressCreate(TEST_TRANS1_TARGET_ADDRESS), amountCreateEther(etherCreateNumber(TEST_TRANS1_ETHER_AMOUNT, TEST_TRANS1_ETHER_AMOUNT_UNIT))); BREthereumTransaction transaction = transferGetOriginatingTransaction(transfer); transactionSetNonce(transaction, TEST_TRANS1_NONCE); assert (1 == networkGetChainId(network)); BRRlpCoder coder = rlpCoderCreate(); BRRlpItem item = transactionRlpEncode(transaction, network, RLP_TYPE_TRANSACTION_UNSIGNED, coder); BRRlpData dataUnsignedTransaction = rlpGetData(coder, item); char result[2 * dataUnsignedTransaction.bytesCount + 1]; encodeHex(result, 2 * dataUnsignedTransaction.bytesCount + 1, dataUnsignedTransaction.bytes, dataUnsignedTransaction.bytesCount); printf (" Tx1 Raw (unsigned): %s\n", result); assert (0 == strcmp (result, TEST_TRANS1_RESULT)); rlpDataRelease(dataUnsignedTransaction); // Check the gasLimit margin assert (21000ull == transactionGetGasLimit(transaction).amountOfGas); assert (0ull == transferGetGasEstimate(transfer).amountOfGas); // Will update gasLimt with margin // TODO: Redo // transferSetGasEstimate(transfer, gasCreate(21000ull)); // assert (((100 + GAS_LIMIT_MARGIN_PERCENT) * 21000ull /100) == transactionGetGasLimit(transaction).amountOfGas); walletUnhandleTransfer(wallet, transfer); transferRelease(transfer); rlpReleaseItem(coder, item); rlpCoderRelease(coder); } // https://etherscan.io/tx/0xc070b1e539e9a329b14c95ec960779359a65be193137779bf2860dc239248d7c // Hash: 0xc070b1e539e9a329b14c95ec960779359a65be193137779bf2860dc239248d7c // From: 0x23c2a202c38331b91980a8a23d31f4ca3d0ecc2b // to: 0x873feb0644a6fbb9532bb31d1c03d4538aadec30 // Amnt: 0.5 Ether ($429.90) // GasL: 21000 // GasP: 2 Gwei // Nonc: 1 // Data: 0x // // Raw: 0xf86b 01 8477359400 825208 94,873feb0644a6fbb9532bb31d1c03d4538aadec30 8806f05b59d3b20000 80 26a030013044b571726723302bcf8dfad8765cf676db0844277a6f8cf63d04894008a069edd285604fdf010d96b8b7d9c547f9599b8ac51c50b8b97076bb9955c0bdde // List Nonc GasP GasL RecvAddr Amount Data <signature> // Rslt: 01 8477359400 825208 94,873feb0644a6fbb9532bb31d1c03d4538aadec30 8806f05b59d3b20000 80 #define TEST_TRANS2_NONCE 1 #define TEST_TRANS2_GAS_PRICE_VALUE 2000000000 // 20 GWEI #define TEST_TRANS2_GAS_PRICE_UNIT WEI #define TEST_TRANS2_GAS_LIMIT 21000 #define TEST_TRANS2_TARGET_ADDRESS "0x873feb0644a6fbb9532bb31d1c03d4538aadec30" #define TEST_TRANS2_ETHER_AMOUNT 500000000000000000u // 0.5 ETHER #define TEST_TRANS2_ETHER_AMOUNT_UNIT WEI #define TEST_TRANS2_DATA "" #define TEST_TRANS2_RESULT_SIGNED "f86b01847735940082520894873feb0644a6fbb9532bb31d1c03d4538aadec308806f05b59d3b200008026a030013044b571726723302bcf8dfad8765cf676db0844277a6f8cf63d04894008a069edd285604fdf010d96b8b7d9c547f9599b8ac51c50b8b97076bb9955c0bdde" #define TEST_TRANS2_RESULT_UNSIGNED "eb01847735940082520894873feb0644a6fbb9532bb31d1c03d4538aadec308806f05b59d3b2000080018080" void runTransactionTests2 (BREthereumAccount account, BREthereumNetwork network) { printf (" TEST 2\n"); BREthereumWallet wallet = walletCreate(account, network); walletSetDefaultGasLimit(wallet, gasCreate(TEST_TRANS2_GAS_LIMIT)); walletSetDefaultGasPrice(wallet, gasPriceCreate(etherCreateNumber(TEST_TRANS2_GAS_PRICE_VALUE, TEST_TRANS2_GAS_PRICE_UNIT))); BREthereumTransfer transfer = walletCreateTransfer(wallet, addressCreate(TEST_TRANS2_TARGET_ADDRESS), amountCreateEther(etherCreateNumber(TEST_TRANS2_ETHER_AMOUNT, TEST_TRANS2_ETHER_AMOUNT_UNIT))); BREthereumTransaction transaction = transferGetOriginatingTransaction(transfer); transactionSetNonce(transaction, TEST_TRANS2_NONCE); assert (1 == networkGetChainId(network)); BRRlpCoder coder = rlpCoderCreate(); BRRlpItem item = transactionRlpEncode(transaction, network, RLP_TYPE_TRANSACTION_UNSIGNED, coder); BRRlpData data = rlpGetData(coder, item); char result[2 * data.bytesCount + 1]; encodeHex(result, 2 * data.bytesCount + 1, data.bytes, data.bytesCount); printf (" Tx2 Raw (unsigned): %s\n", result); assert (0 == strcmp (result, TEST_TRANS2_RESULT_UNSIGNED)); rlpDataRelease(data); data.bytes = decodeHexCreate(&data.bytesCount, TEST_TRANS2_RESULT_SIGNED, strlen (TEST_TRANS2_RESULT_SIGNED)); rlpShow(data, "Trans2Test"); rlpDataRelease(data); walletUnhandleTransfer(wallet, transfer); transferRelease(transfer); rlpReleaseItem(coder, item); rlpCoderRelease(coder); } /* From: 0xd551234ae421e3bcba99a0da6d736074f22192ff To: Contract 0x558ec3152e2eb2174905cd19aea4e34a23de9ad6 (BreadToken) Recv: 0x932a27e1bc84f5b74c29af3d888926b1307f4a5c Amnt: 5,968.77 Raw Hash: 0xf8ad83067642850ba43b74008301246a94558ec3152e2eb2174905cd19aea4e34a23de9ad68 // RLP Header - 'data' 0b844 a9059cbb 000000000000000000000000932a27e1bc84f5b74c29af3d888926b1307f4a5c 0000000000000000000000000000000000000000000001439152d319e84d0000 // v, r, s signature 25, a0a352fe7973fe554d3d5d21effb82667b3a17cc7b259eec482baf41a5ac80e155a0772ba32bfe32ccf7c4b764db155cd3e39b66c3b10abaa44ce27bc3013dd9ae7b Input Data: Function: transfer(address _to, uint256 _value) *** MethodID: 0xa9059cbb [0]: 000000000000000000000000932a27e1bc84f5b74c29af3d888926b1307f4a5c [1]: 0000000000000000000000000000000000000000000001439152d319e84d0000 */ #define TEST_TRANS3_TARGET_ADDRESS "0x932a27e1bc84f5b74c29af3d888926b1307f4a5c" #define TEST_TRANS3_GAS_PRICE_VALUE 50 // 20 GWEI #define TEST_TRANS3_GAS_PRICE_UNIT GWEI #define TEST_TRANS3_GAS_LIMIT 74858 #define TEST_TRANS3_NONCE 423490 #define TEST_TRANS3_DECIMAL_AMOUNT "5968.77" #define TEST_TRANS3_UNSIGNED_TX_MAINNET "f86d83067642850ba43b74008301246a94558ec3152e2eb2174905cd19aea4e34a23de9ad680b844a9059cbb000000000000000000000000932a27e1bc84f5b74c29af3d888926b1307f4a5c0000000000000000000000000000000000000000000001439152d319e84d0000018080" #define TEST_TRANS3_UNSIGNED_TX_TESTNET "f86d83067642850ba43b74008301246a947108ca7c4718efa810457f228305c9c71390931a80b844a9059cbb000000000000000000000000932a27e1bc84f5b74c29af3d888926b1307f4a5c0000000000000000000000000000000000000000000001439152d319e84d0000018080" // Add 018080 (v,r,s); adjust header count // Answer: "0xf8ad 83067642 850ba43b7400 8301246a 94,558ec3152e2eb2174905cd19aea4e34a23de9ad6_80_b844a9059cbb000000000000000000000000932a27e1bc84f5b74c29af3d888926b1307f4a5c0000000000000000000000000000000000000000000001439152d319e84d0000" // "0xf86d 83067642 850ba43b7400 8301246a 94,0000000000000000000000000000000000000000_80_b844a9059cbb000000000000000000000000932a27e1bc84f5b74c29af3d888926b1307f4a5c0000000000000000000000000000000000000000000001439152d319e84d0000018080" 0x0000000143334f20 // Error : f86d 83067642 850ba43b7400 8301246a 94,558ec3152e2eb2174905cd19aea4e34a23de9ad6_00_b844a9059cbb000000000000000000000000932a27e1bc84f5b74c29af3d888926b1307f4a5c0000000000000000000000000000000000000000000001439152d319e84d0000018080 // ** => amount = 0 => encoded as empty bytes, not numeric 0 void runTransactionTests3 (BREthereumAccount account, BREthereumNetwork network) { printf (" TEST 3\n"); BRCoreParseStatus status; BREthereumToken token = tokenLookup(tokenBRDAddress); BREthereumWallet wallet = walletCreateHoldingToken (account, network, token); UInt256 value = createUInt256Parse ("5968770000000000000000", 10, &status); BREthereumAmount amount = amountCreateToken(createTokenQuantity (token, value)); walletSetDefaultGasLimit(wallet, gasCreate(TEST_TRANS3_GAS_LIMIT)); walletSetDefaultGasPrice(wallet, gasPriceCreate(etherCreateNumber(TEST_TRANS3_GAS_PRICE_VALUE, TEST_TRANS3_GAS_PRICE_UNIT))); BREthereumTransfer transfer = walletCreateTransfer(wallet, addressCreate(TEST_TRANS3_TARGET_ADDRESS), amount); BREthereumTransaction transaction = transferGetOriginatingTransaction(transfer); transactionSetNonce(transaction, TEST_TRANS3_NONCE); assert (1 == networkGetChainId(network)); BRRlpCoder coder = rlpCoderCreate(); BRRlpItem item = transactionRlpEncode(transaction, network, RLP_TYPE_TRANSACTION_UNSIGNED, coder); BRRlpData dataUnsignedTransaction = rlpGetData (coder, item); char *rawTx = encodeHexCreate(NULL, dataUnsignedTransaction.bytes, dataUnsignedTransaction.bytesCount); printf (" Tx3 Raw (unsigned): %s\n", rawTx); assert (0 == strcasecmp(rawTx, (0 == strcmp (tokenBRDAddress, "0x558ec3152e2eb2174905cd19aea4e34a23de9ad6") ? TEST_TRANS3_UNSIGNED_TX_MAINNET : TEST_TRANS3_UNSIGNED_TX_TESTNET))); free (rawTx); rlpDataRelease(dataUnsignedTransaction); walletUnhandleTransfer(wallet, transfer); transferRelease(transfer); rlpReleaseItem(coder, item); rlpCoderRelease(coder); } #define TEST_TRANS4_SIGNED_TX "f8a90184773594008301676094dd974d5c2e2928dea5f71b9825b8b646686bd20080b844a9059cbb00000000000000000000000049f4c50d9bcc7afdbcf77e0d6e364c29d5a660df00000000000000000000000000000000000000000000000002c68af0bb14000025a09d4477bf97f638e1007d897bfd29a2053e2187a6d92c0e186ec98d81d291bf87a07f8c9e24255970b6282d3a21aa146add70b65f74a463eac54b2b11015bc37fbe" #define TEST_TRANS4_HASH "0xe5a045bdd432a8edc345ff830641d1b75847ab5c9d8380241323fa4c9e6cee1e" void runTransactionTests4 (BREthereumAccount account, BREthereumNetwork network) { printf (" TEST 4\n"); BRRlpData data; data.bytes = decodeHexCreate(&data.bytesCount, TEST_TRANS4_SIGNED_TX, strlen (TEST_TRANS4_SIGNED_TX)); BRRlpCoder coder = rlpCoderCreate(); BRRlpItem item = rlpGetItem(coder, data); BREthereumTransaction tx = transactionRlpDecode(item, network, RLP_TYPE_TRANSACTION_SIGNED, coder); assert (ETHEREUM_BOOLEAN_IS_TRUE (hashEqual(transactionGetHash(tx), hashCreate(TEST_TRANS4_HASH)))); rlpDataRelease(data); transactionRelease(tx); rlpReleaseItem(coder, item); rlpCoderRelease(coder); } void runTransactionTests (BREthereumAccount account, BREthereumNetwork network) { printf ("\n== Transaction\n"); runTransactionTests1 (account, network); runTransactionTests2 (account, network); runTransactionTests3 (account, network); runTransactionTests4 (account, network); } // // Account Tests // void runAccountTests () { BREthereumAccount account = createAccount(TEST_PAPER_KEY); BREthereumNetwork network = ethereumMainnet; printf ("==== Account: %p\n", account); runAddressTests(account); runTransactionTests(account, network); accountFree (account); printf ("\n\n"); } // // EWM Tests // #define NODE_PAPER_KEY "ginger settle marine tissue robot crane night number ramp coast roast critic" #define NODE_NONCE TEST_TRANS2_NONCE // 1 #define NODE_GAS_PRICE_VALUE TEST_TRANS2_GAS_PRICE_VALUE // 20 GWEI #define NODE_GAS_PRICE_UNIT TEST_TRANS2_GAS_PRICE_UNIT // WEI #define NODE_GAS_LIMIT TEST_TRANS2_GAS_LIMIT #define NODE_RECV_ADDR TEST_TRANS2_TARGET_ADDRESS #define NODE_ETHER_AMOUNT_UNIT TEST_TRANS2_ETHER_AMOUNT_UNIT #define NODE_ETHER_AMOUNT TEST_TRANS2_ETHER_AMOUNT #define GAS_PRICE_20_GWEI 2000000000 #define GAS_PRICE_10_GWEI 1000000000 #define GAS_PRICE_5_GWEI 500000000 #define GAS_LIMIT_DEFAULT 21000 // Result f86b 01 8477359400 825208 94,873feb0644a6fbb9532bb31d1c03d4538aadec30 8806f05b59d3b20000 80 1b,a053ee5877032551f52da516c83620273312c8ab5a773d482dd60a772bb4a39938a07e187ee2335bfcfa3d20119e0e424d9ef5a81452dadee91ef2daf40081fdc454 // Raw: 0xf86b 01 8477359400 825208 94,873feb0644a6fbb9532bb31d1c03d4538aadec30 8806f05b59d3b20000 80 26,a030013044b571726723302bcf8dfad8765cf676db0844277a6f8cf63d04894008a069edd285604fdf010d96b8b7d9c547f9599b8ac51c50b8b97076bb9955c0bdde #define NODE_RESULT "01 8477359400 825208 94,873feb0644a6fbb9532bb31d1c03d4538aadec30 8806f05b59d3b20000 80 1b,a0594c2fe40942a9dbd75b9cdd09397016592fc98ae24226f41706c5004c6608d0a072861c46ae62f4aae06eba04e5708b9421d2fcf21fa7f02aed1ff04accd405e3" void testTransactionCodingEther () { printf (" Coding Transaction\n"); BREthereumAccount account = createAccount (NODE_PAPER_KEY); BREthereumWallet wallet = walletCreate(account, ethereumMainnet); BREthereumAddress txRecvAddr = addressCreate(NODE_RECV_ADDR); BREthereumAmount txAmount = amountCreateEther(etherCreate(createUInt256(NODE_ETHER_AMOUNT))); BREthereumGasPrice txGasPrice = gasPriceCreate(etherCreate(createUInt256(NODE_GAS_PRICE_VALUE))); BREthereumGas txGas = gasCreate(NODE_GAS_LIMIT); walletSetDefaultGasPrice(wallet, txGasPrice); walletSetDefaultGasLimit(wallet, txGas); BREthereumTransfer transfer = walletCreateTransfer(wallet, txRecvAddr, txAmount); // NOTE: Owned by `transfer` BREthereumTransaction transaction = transferGetOriginatingTransaction(transfer); transactionSetNonce(transaction, NODE_NONCE); walletSignTransfer(wallet, transfer, NODE_PAPER_KEY); BRRlpCoder coder = rlpCoderCreate(); BRRlpItem item = transactionRlpEncode(transaction, ethereumMainnet, RLP_TYPE_TRANSACTION_SIGNED, coder); BRRlpData data = rlpGetData (coder, item); char *rawTx = encodeHexCreate(NULL, data.bytes, data.bytesCount); printf (" Raw Transaction: 0x%s\n", rawTx); BREthereumTransaction decodedTransaction = transactionRlpDecode(item, ethereumMainnet, RLP_TYPE_TRANSACTION_SIGNED, coder); rlpReleaseItem(coder, item); assert (transactionGetNonce(transaction) == transactionGetNonce(decodedTransaction)); assert (ETHEREUM_COMPARISON_EQ == gasPriceCompare(transactionGetGasPrice(transaction), transactionGetGasPrice(decodedTransaction))); assert (ETHEREUM_COMPARISON_EQ == gasCompare(transactionGetGasLimit(transaction), transactionGetGasLimit(decodedTransaction))); assert (ETHEREUM_COMPARISON_EQ == etherCompare(transactionGetAmount(transaction), transactionGetAmount(decodedTransaction))); assert (ETHEREUM_BOOLEAN_TRUE == addressEqual(transactionGetTargetAddress(transaction), transactionGetTargetAddress(decodedTransaction))); // Signature assert (ETHEREUM_BOOLEAN_TRUE == signatureEqual(transactionGetSignature (transaction), transactionGetSignature (decodedTransaction))); // Address recovery BREthereumAddress transactionSourceAddress = transactionGetSourceAddress(transaction); BREthereumAddress decodedTransactionSourceAddress = transactionGetSourceAddress(decodedTransaction); assert (ETHEREUM_BOOLEAN_IS_TRUE(addressEqual(transactionSourceAddress, decodedTransactionSourceAddress))); assert (ETHEREUM_BOOLEAN_IS_TRUE(accountHasAddress(account, transactionSourceAddress))); // Archive BREthereumHash someBlockHash = HASH_INIT("fc45a8c5ebb5f920931e3d5f48992f3a89b544b4e21dc2c11c5bf8165a7245d6"); BREthereumTransactionStatus status = transactionStatusCreateIncluded(someBlockHash, 11592, 21, 0, gasCreate(0)); transactionSetStatus(transaction, status); item = transactionRlpEncode(transaction, ethereumMainnet, RLP_TYPE_ARCHIVE, coder); BREthereumTransaction archivedTransaction = transactionRlpDecode(item, ethereumMainnet, RLP_TYPE_ARCHIVE, coder); rlpReleaseItem(coder, item); BREthereumTransactionStatus archivedStatus = transactionGetStatus(archivedTransaction); assert (ETHEREUM_BOOLEAN_IS_TRUE(transactionStatusEqual(status, archivedStatus))); assert (ETHEREUM_BOOLEAN_IS_TRUE(addressEqual(transactionGetTargetAddress(transaction), transactionGetTargetAddress(archivedTransaction)))); assert (ETHEREUM_BOOLEAN_IS_TRUE(hashEqual(status.u.included.blockHash, someBlockHash))); walletUnhandleTransfer(wallet, transfer); transferRelease(transfer); transactionRelease(decodedTransaction); rlpCoderRelease(coder); } void testTransactionCodingToken () { printf (" Coding Transaction\n"); BREthereumToken token = tokenLookup(tokenBRDAddress); BREthereumAccount account = createAccount (NODE_PAPER_KEY); BREthereumWallet wallet = walletCreateHoldingToken(account, ethereumMainnet, token); BREthereumAddress txRecvAddr = addressCreate(NODE_RECV_ADDR); BREthereumAmount txAmount = amountCreateToken(createTokenQuantity(token, createUInt256(NODE_ETHER_AMOUNT))); BREthereumGasPrice txGasPrice = gasPriceCreate(etherCreate(createUInt256(NODE_GAS_PRICE_VALUE))); BREthereumGas txGas = gasCreate(NODE_GAS_LIMIT); walletSetDefaultGasPrice(wallet, txGasPrice); walletSetDefaultGasLimit(wallet, txGas); BREthereumTransfer transfer = walletCreateTransfer(wallet, txRecvAddr, txAmount); // NOTE: Owned by `transfer` BREthereumTransaction transaction = transferGetOriginatingTransaction(transfer); transactionSetNonce(transaction, NODE_NONCE); walletSignTransfer(wallet, transfer, NODE_PAPER_KEY); BRRlpCoder coder = rlpCoderCreate(); BRRlpItem item = transactionRlpEncode(transaction, ethereumMainnet, RLP_TYPE_TRANSACTION_SIGNED, coder); BRRlpData data = rlpGetData (coder, item); char *rawTx = encodeHexCreate(NULL, data.bytes, data.bytesCount); printf (" Raw Transaction: 0x%s\n", rawTx); BREthereumTransaction decodedTransaction = transactionRlpDecode(item, ethereumMainnet, RLP_TYPE_TRANSACTION_SIGNED, coder); rlpReleaseItem(coder, item); assert (transactionGetNonce(transaction) == transactionGetNonce(decodedTransaction)); assert (ETHEREUM_COMPARISON_EQ == gasPriceCompare(transactionGetGasPrice(transaction), transactionGetGasPrice(decodedTransaction))); assert (ETHEREUM_COMPARISON_EQ == gasCompare(transactionGetGasLimit(transaction), transactionGetGasLimit(decodedTransaction))); // int typeMismatch = 0; #if defined (TRANSACTION_ENCODE_TOKEN) assert (ETHEREUM_COMPARISON_EQ == amountCompare(transactionGetAmount(transaction), transactionGetAmount(decodedTransaction), &typeMismatch)); assert (ETHEREUM_BOOLEAN_TRUE == addressEqual(transactionGetTargetAddress(transaction), transactionGetTargetAddress(decodedTransaction))); #endif // Signature assert (ETHEREUM_BOOLEAN_TRUE == signatureEqual(transactionGetSignature (transaction), transactionGetSignature (decodedTransaction))); walletUnhandleTransfer(wallet, transfer); transferRelease(transfer); transactionRelease(decodedTransaction); rlpCoderRelease(coder); } // // All Tests // extern void runPerfTestsCoder (int repeat, int many) { BRRlpCoder coder = rlpCoderCreate(); BRRlpCoder coderSaved = coder; BRRlpData data; data.bytes = decodeHexCreate(&data.bytesCount, TEST_TRANS4_SIGNED_TX, strlen (TEST_TRANS4_SIGNED_TX)); BRRlpItem item = rlpGetItem(coder, data); BREthereumTransaction transaction = transactionRlpDecode(item, ethereumMainnet, RLP_TYPE_TRANSACTION_SIGNED, coder); BRRlpItem items [100]; while (repeat-- > 0) { if (many) coder = rlpCoderCreate(); for (int i = 0; i < 100; i++) items[i] = transactionRlpEncode(transaction, ethereumMainnet, RLP_TYPE_TRANSACTION_SIGNED, coder); for (int i = 0; i < 100; i++) transactionRelease(transactionRlpDecode(item, ethereumMainnet, RLP_TYPE_TRANSACTION_SIGNED, coder)); for (int i = 0; i < 100; i++) rlpReleaseItem(coder, items[i]); if (many) rlpCoderRelease(coder); } rlpReleaseItem(coderSaved, item); rlpCoderRelease(coderSaved); } extern void installTokensForTest (void); extern void runTests (int reallySend) { installSharedWordList(BRBIP39WordsEn, BIP39_WORDLIST_COUNT); installTokensForTest (); // Initialize tokens // tokenGet(0); runAccountTests(); testTransactionCodingEther (); testTransactionCodingToken (); //* if (reallySend) testReallySend(); printf ("Done\n"); } extern void installTokensForTest (void); #if defined (TEST_ETHEREUM_NEED_MAIN) int main(int argc, const char *argv[]) { installTokensForTest (); runUtilTests(); runRlpTests(); runEventTests(); runBcTests(); runContractTests(); runEWMTests(NODE_PAPER_KEY, "/tmp"); runTests(0); } #endif
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Plugin/Transaction/TransactionOutput.h
// Copyright (c) 2012-2018 The Elastos Open Source Project // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef __ELASTOS_SDK_TRANSACTIONOUTPUT_H__ #define __ELASTOS_SDK_TRANSACTIONOUTPUT_H__ #include <Plugin/Interface/ELAMessageSerializable.h> #include <Plugin/Transaction/Payload/OutputPayload/IOutputPayload.h> #include <Plugin/Transaction/Asset.h> #include <WalletCore/Address.h> #include <Common/BigInt.h> #include <boost/shared_ptr.hpp> namespace Elastos { namespace ElaWallet { class TransactionOutput : public JsonSerializer { public: enum Type { Default = 0x00, VoteOutput = 0x01, }; public: TransactionOutput(); TransactionOutput(const TransactionOutput &output); TransactionOutput &operator=(const TransactionOutput &tx); TransactionOutput(const BigInt &amount, const Address &toAddress, const uint256 &assetID = Asset::GetELAAssetID(), Type type = Default, const OutputPayloadPtr &payload = nullptr); ~TransactionOutput(); size_t EstimateSize() const; void Serialize(ByteStream &ostream, uint8_t txVersion, bool extend = false) const; bool Deserialize(const ByteStream &istream, uint8_t txVersion, bool extend = false); bool IsValid() const; const AddressPtr &Addr() const; const BigInt &Amount() const; void SetAmount(const BigInt &amount); const uint256 &AssetID() const; void SetAssetID(const uint256 &assetId); uint32_t OutputLock() const; void SetOutputLock(uint32_t outputLock); const Type &GetType() const; void SetType(const Type &type); const OutputPayloadPtr &GetPayload() const; OutputPayloadPtr &GetPayload(); void SetPayload(const OutputPayloadPtr &payload); OutputPayloadPtr GeneratePayload(const Type &type); nlohmann::json ToJson() const; void FromJson(const nlohmann::json &j); size_t GetSize() const; uint16_t FixedIndex() const; void SetFixedIndex(uint16_t index); private: uint16_t _fixedIndex; BigInt _amount; // to support token chain uint256 _assetID; uint32_t _outputLock; AddressPtr _addr; Type _outputType; OutputPayloadPtr _payload; }; typedef boost::shared_ptr<TransactionOutput> OutputPtr; typedef std::vector<OutputPtr> OutputArray; } } #endif //__ELASTOS_SDK_TRANSACTIONOUTPUT_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/blockchain/BREthereumTransactionStatus.h
// // BREthereumTransactionStatus.h // BRCore // // Created by <NAME> on 5/15/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // // See the LICENSE file at the project root for license information. // See the CONTRIBUTORS file at the project root for a list of contributors. #ifndef BR_Ethereum_Transaction_Status_h #define BR_Ethereum_Transaction_Status_h #include "ethereum/base/BREthereumBase.h" #ifdef __cplusplus extern "C" { #endif /** * An Ethereum Transaction Status Type is an enumeration of the results of transaction * submission to the Ethereum P2P network. [In practice, these may only be specified in * the Geth LESv{1,2} specification; not more generally in the Ethereum specifcation}. */ typedef enum { /** * Unknown (0): transaction is unknown */ TRANSACTION_STATUS_UNKNOWN = 0, /** *Queued (1): transaction is queued (not processable yet) */ TRANSACTION_STATUS_QUEUED = 1, /** * Pending (2): transaction is pending (processable) */ TRANSACTION_STATUS_PENDING = 2, /** * Included (3): transaction is already included in the canonical chain. data contains an * RLP-encoded [blockHash: B_32, blockNumber: P, txIndex: P] structure. */ TRANSACTION_STATUS_INCLUDED = 3, /** * Error (4): transaction sending failed. data contains a text error message */ TRANSACTION_STATUS_ERRORED = 4, } BREthereumTransactionStatusType; /** * Extracted from observation of Geth error reports, from Geth source code, and from Parity * source code (see below for Geth+Parity declaration). Currently Parity, in PIPv1, provides * no transactions error status (https://github.com/paritytech/parity-ethereum/issues/9817 */ typedef enum { TRANSACTION_ERROR_INVALID_SIGNATURE = 0, TRANSACTION_ERROR_NONCE_TOO_LOW, TRANSACTION_ERROR_BALANCE_TOO_LOW, TRANSACTION_ERROR_GAS_PRICE_TOO_LOW, TRANSACTION_ERROR_GAS_TOO_LOW, TRANSACTION_ERROR_REPLACEMENT_UNDER_PRICED, TRANSACTION_ERROR_DROPPED, TRANSACTION_ERROR_ALREADY_KNOWN, // Geth: submit arrives after shared (from other peer) TRANSACTION_ERROR_UNKNOWN, } BREthereumTransactionErrorType; extern const char * transactionGetErrorName (BREthereumTransactionErrorType type); /** In `Status` we'll include a 'reason' string; limit the string to filling out the union. */ #define TRANSACTION_STATUS_DETAIL_BYTES \ (sizeof (BREthereumGas) + sizeof (BREthereumHash) + 3 * sizeof(uint64_t) - sizeof (BREthereumTransactionErrorType)) /** * An Ethereum Transaction Status is the status of a transaction submitted to the Ethereum * P2P network. It consists of the type and then data specific to the type. For example, if * the type is 'included' then {blockHash, blockNumber, blockTransactionIndex, blockTimestamp, * gasUsed} is part of the status. */ typedef struct BREthereumTransactionStatusLESRecord { BREthereumTransactionStatusType type; union { struct { BREthereumHash blockHash; uint64_t blockNumber; uint64_t transactionIndex; uint64_t blockTimestamp; BREthereumGas gasUsed; // Internal } included; struct { BREthereumTransactionErrorType type; char detail[TRANSACTION_STATUS_DETAIL_BYTES + 1]; } errored; } u; } BREthereumTransactionStatus; #define TRANSACTION_STATUS_BLOCK_TIMESTAMP_UNKNOWN (0) extern BREthereumTransactionStatus transactionStatusCreate (BREthereumTransactionStatusType type); extern BREthereumTransactionStatus transactionStatusCreateIncluded (BREthereumHash blockHash, uint64_t blockNumber, uint64_t transactionIndex, uint64_t blockTimestamp, BREthereumGas gasUsed); extern BREthereumTransactionStatus transactionStatusCreateErrored (BREthereumTransactionErrorType type, const char *detail); static inline BREthereumBoolean transactionStatusHasType (const BREthereumTransactionStatus *status, BREthereumTransactionStatusType type) { return AS_ETHEREUM_BOOLEAN(status->type == type); } extern int transactionStatusExtractIncluded(const BREthereumTransactionStatus *status, BREthereumHash *blockHash, uint64_t *blockNumber, uint64_t *blockTransactionIndex, uint64_t *blockTimestamp, BREthereumGas *gas); extern BREthereumBoolean transactionStatusEqual (BREthereumTransactionStatus ts1, BREthereumTransactionStatus ts2); extern BREthereumTransactionStatus transactionStatusRLPDecode (BRRlpItem item, const char *reasons[], BRRlpCoder coder); extern BRRlpItem transactionStatusRLPEncode (BREthereumTransactionStatus status, BRRlpCoder coder); extern BRArrayOf (BREthereumTransactionStatus) transactionStatusDecodeList (BRRlpItem item, const char *reasons[], BRRlpCoder coder); /* Quasi-Statis - used when the BRD endpoint returns an error */ extern BREthereumTransactionErrorType lookupTransactionErrorType (const char *reasons[], const char *reason); #ifdef __cplusplus } #endif #endif /* BR_Ethereum_Transaction_Status_h */ // Geth //var ( // // ErrInvalidSender is returned if the transaction contains an invalid signature. //** ErrInvalidSender = errors.New("invalid sender") // // // ErrNonceTooLow is returned if the nonce of a transaction is lower than the // // one present in the local chain. // ** ErrNonceTooLow = errors.New("nonce too low") // // // ErrUnderpriced is returned if a transaction's gas price is below the minimum // // configured for the transaction pool. //** ErrUnderpriced = errors.New("transaction underpriced") // // // ErrReplaceUnderpriced is returned if a transaction is attempted to be replaced // // with a different one without the required price bump. //** ErrReplaceUnderpriced = errors.New("replacement transaction underpriced") // // // ErrInsufficientFunds is returned if the total cost of executing a transaction // // is higher than the balance of the user's account. // ** ErrInsufficientFunds = errors.New("insufficient funds for gas * price + value") // // // ErrIntrinsicGas is returned if the transaction is specified to use less gas // // than required to start the invocation. //** ErrIntrinsicGas = errors.New("intrinsic gas too low") // // // ErrGasLimit is returned if a transaction's requested gas limit exceeds the // // maximum allowance of the current block. // ErrGasLimit = errors.New("exceeds block gas limit") // // // ErrNegativeValue is a sanity error to ensure noone is able to specify a // // transaction with a negative value. // ErrNegativeValue = errors.New("negative value") // // // ErrOversizedData is returned if the input data of a transaction is greater // // than some meaningful limit a user might use. This is not a consensus error // // making the transaction invalid, rather a DOS protection. // ErrOversizedData = [errors.New("oversized data") // } // Parity //pub enum Error { // /// Transaction is already imported to the queue // AlreadyImported, // /// Transaction is not valid anymore (state already has higher nonce) //** Old, // /// Transaction has too low fee // /// (there is already a transaction with the same sender-nonce but higher gas price) // TooCheapToReplace, // /// Transaction was not imported to the queue because limit has been reached. // LimitReached, // /// Transaction's gas price is below threshold. //** InsufficientGasPrice { // /// Minimal expected gas price // minimal: U256, // /// Transaction gas price // got: U256, // }, // /// Transaction's gas is below currently set minimal gas requirement. // InsufficientGas { // /// Minimal expected gas // minimal: U256, // /// Transaction gas // got: U256, // }, // /// Sender doesn't have enough funds to pay for this transaction // ** InsufficientBalance { // /// Senders balance // balance: U256, // /// Transaction cost // cost: U256, // }, // /// Transactions gas is higher then current gas limit // GasLimitExceeded { // /// Current gas limit // limit: U256, // /// Declared transaction gas // got: U256, // }, // /// Transaction's gas limit (aka gas) is invalid. // InvalidGasLimit(OutOfBounds<U256>), // /// Transaction sender is banned. // SenderBanned, // /// Transaction receipient is banned. // RecipientBanned, // /// Contract creation code is banned. // CodeBanned, // /// Invalid chain ID given. // InvalidChainId, // /// Not enough permissions given by permission contract. // NotAllowed, // /// Signature error //** InvalidSignature(String), // /// Transaction too big // TooBig, // /// Invalid RLP encoding // InvalidRlp(String), //} //impl fmt::Display for Error { // fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // use self::Error::*; // let msg = match *self { // AlreadyImported => "Already imported".into(), // Old => "No longer valid".into(), // TooCheapToReplace => "Gas price too low to replace".into(), // LimitReached => "Transaction limit reached".into(), // InsufficientGasPrice { minimal, got } => // format!("Insufficient gas price. Min={}, Given={}", minimal, got), // InsufficientGas { minimal, got } => // format!("Insufficient gas. Min={}, Given={}", minimal, got), // InsufficientBalance { balance, cost } => // format!("Insufficient balance for transaction. Balance={}, Cost={}", // balance, cost), // GasLimitExceeded { limit, got } => // format!("Gas limit exceeded. Limit={}, Given={}", limit, got), // InvalidGasLimit(ref err) => format!("Invalid gas limit. {}", err), // SenderBanned => "Sender is temporarily banned.".into(), // RecipientBanned => "Recipient is temporarily banned.".into(), // CodeBanned => "Contract code is temporarily banned.".into(), // InvalidChainId => "Transaction of this chain ID is not allowed on this chain.".into(), // InvalidSignature(ref err) => format!("Transaction has invalid signature: {}.", err), // NotAllowed => "Sender does not have permissions to execute this type of transction".into(), // TooBig => "Transaction too big".into(), // InvalidRlp(ref err) => format!("Transaction has invalid RLP structure: {}.", err), // }; // // f.write_fmt(format_args!("Transaction error ({})", msg)) // } //}
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/BREthereum.h
// // BREthereum // breadwallet-core Ethereum // // Created by <NAME> on 2/24/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // // See the LICENSE file at the project root for license information. // See the CONTRIBUTORS file at the project root for a list of contributors. #ifndef BR_Ethereum_H #define BR_Ethereum_H #include "base/BREthereumBase.h" #include "ewm/BREthereumEWM.h" #include "ewm/BREthereumAccount.h" #ifdef __cplusplus extern "C" { #endif /** * Install 'wordList' as the default BIP39 Word List. THIS IS SHARED MEMORY; DO NOT FREE wordList. * * @param wordList * @param wordListLength * @return */ extern int installSharedWordList (const char *wordList[], int wordListLength); static inline UInt512 zeroUInt512 (void) { return UINT512_ZERO; } #ifdef __cplusplus } #endif #endif // BR_Ethereum_H
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Plugin/Transaction/Payload/RechargeToSideChain.h
<gh_stars>10-100 // Copyright (c) 2012-2018 The Elastos Open Source Project // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef __ELASTOS_SDK_RECHARGETOSIDECHAIN_H #define __ELASTOS_SDK_RECHARGETOSIDECHAIN_H #include <Common/uint256.h> #include "IPayload.h" namespace Elastos { namespace ElaWallet { class RechargeToSideChain : public IPayload { public: enum Version { V0, V1, }; public: RechargeToSideChain(); RechargeToSideChain(const bytes_t &merkeProff, const bytes_t &mainChainTransaction); RechargeToSideChain(const RechargeToSideChain &payload); ~RechargeToSideChain(); virtual size_t EstimateSize(uint8_t version) const; virtual void Serialize(ByteStream &ostream, uint8_t version) const; virtual bool Deserialize(const ByteStream &istream, uint8_t version); virtual nlohmann::json ToJson(uint8_t version) const; virtual void FromJson(const nlohmann::json &j, uint8_t version); virtual IPayload &operator=(const IPayload &payload); RechargeToSideChain &operator=(const RechargeToSideChain &payload); private: bytes_t _merkeProof; bytes_t _mainChainTransaction; uint256 _mainChainTxHash; }; } } #endif //__ELASTOS_SDK_PAYLOADISSUETOKEN_H
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/ewm/BREthereumTransfer.c
// // BREthereumTransfer.c // Core // // Created by <NAME> on 7/9/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // // See the LICENSE file at the project root for license information. // See the CONTRIBUTORS file at the project root for a list of contributors. #include <string.h> #include <assert.h> #include "ethereum/blockchain/BREthereumTransaction.h" #include "ethereum/blockchain/BREthereumLog.h" #include "BREthereumTransfer.h" static void transferProvideOriginatingTransaction (BREthereumTransfer transfer); /// MARK: - Status //#define TRANSFER_STATUS_DETAIL_BYTES \ //(sizeof (BREthereumGas) + sizeof (BREthereumHash) + 2 * sizeof(uint64_t)) // //typedef struct BREthereumTransferStatusRecord { // BREthereumTransferStatusType type; // union { // struct { // BREthereumGas gasUsed; // Internal // BREthereumHash blockHash; // uint64_t blockNumber; // uint64_t transactionIndex; // } included; // // struct { // BREthereumTransactionErrorType type; // char detail[TRANSFER_STATUS_DETAIL_BYTES + 1]; // } errored; // } u; //} BREthereumTransferStatus; extern BREthereumTransferStatus transferStatusCreate (BREthereumTransactionStatus status) { switch (status.type) { case TRANSACTION_STATUS_UNKNOWN: return TRANSFER_STATUS_CREATED; case TRANSACTION_STATUS_QUEUED: case TRANSACTION_STATUS_PENDING: return TRANSFER_STATUS_SUBMITTED; case TRANSACTION_STATUS_INCLUDED: return TRANSFER_STATUS_INCLUDED; case TRANSACTION_STATUS_ERRORED: return TRANSFER_STATUS_ERRORED; default: return TRANSFER_STATUS_CREATED; } } /// MARK: - Basis typedef struct { BREthereumTransferBasisType type; union { BREthereumTransaction transaction; BREthereumLog log; } u; } BREthereumTransferBasis; static void transferBasisRelease (BREthereumTransferBasis *basis) { switch (basis->type) { case TRANSFER_BASIS_TRANSACTION: transactionRelease (basis->u.transaction); basis->u.transaction = NULL; break; case TRANSFER_BASIS_LOG: logRelease (basis->u.log); basis->u.log = NULL; break; } } static BREthereumHash transferBasisGetHash (BREthereumTransferBasis *basis) { switch (basis->type) { case TRANSFER_BASIS_TRANSACTION: { if (NULL == basis->u.transaction) return EMPTY_HASH_INIT; return transactionGetHash (basis->u.transaction); } case TRANSFER_BASIS_LOG: { if (NULL == basis->u.log) return EMPTY_HASH_INIT; BREthereumHash hash = EMPTY_HASH_INIT; logExtractIdentifier(basis->u.log, &hash, NULL); return hash; } } } // // Transfer // struct BREthereumTransferRecord { /** * The source */ BREthereumAddress sourceAddress; /* * The target */ BREthereumAddress targetAddress; /** * The amount - which includes a 'currency' and will/must be consistent with the * wallet holding this transfer */ BREthereumAmount amount; /** * The feeBasis as a pair of { gasLimit, gasPrice }. */ BREthereumFeeBasis feeBasis; /** * The gasEstimate represents the expected Ethereum VM computation required to process this * transfer. */ BREthereumGas gasEstimate; /** * The transaction that originated this transfer. For a transfer representing an ERC20 * transfer, the originatingTransaction will be the transaction the produces a Log event * for the transfer. * * If a transfer is newly created, the originatingTransfer will exist but will not have been * submitted to the Ethereum network. It won't have an assigned 'nonce' until the transfer * is signed. * * An originatingTransaction will ONLY EXIST if the User created the transaction. Transactions * that are found (in the P2P network or via the BRD endpoint) that target User, will not * have an originatingTransaction. * * For a transfer representing an ERC20 transfer originated by User, the Log transfer will * have an originatingTransaction and, once confirmed in the blockchain, the transfer * representing the ETH fee WILL NOT have an originating transaction. * * Note: The originatingTransaction might be idential ('eq?') to the basis transaction. Double * Note: No the originatingTransaction should never be eq? to the basis (too much memory * management to ensure). */ BREthereumTransaction originatingTransaction; /** * The basis - either a transaction or a log. A Basis exists if-and-only-if this transfer * has been included in the block chain. For an ERC20 transfer, the basis will be a Log; for * an ETH transfer, the basis will be a transaction. * * The basis and the originatingTransaction are independent. That is, one can have a basis * w/o an originating transaction, such as when ETH or TOK are *sent* to User; one can have * an originating transaction w/o a basis, such as when the User created but has not submitted * a transfer or if the submitted originating transaction failed. */ BREthereumTransferBasis basis; /** * The status */ BREthereumTransferStatus status; }; /** * Create a transfer of `amount` from `source` to `target. The `originatingTransaction` can be * provided but may be NULL. There will be no `basis` (but this function is static and all * public function should provide the basis). */ static BREthereumTransfer transferCreateDetailed (BREthereumAddress sourceAddress, BREthereumAddress targetAddress, BREthereumAmount amount, BREthereumFeeBasis feeBasis, OwnershipGiven BREthereumTransaction originatingTransaction) { BREthereumTransfer transfer = calloc (1, sizeof(struct BREthereumTransferRecord)); transfer->sourceAddress = sourceAddress; transfer->targetAddress = targetAddress; transfer->amount = amount; transfer->feeBasis = feeBasis; transfer->gasEstimate = gasCreate(0); transfer->originatingTransaction = originatingTransaction; transfer->status = TRANSFER_STATUS_CREATED; // NOTE: transfer->basis is unassigned; hence this function is 'static'. return transfer; } extern BREthereumTransfer transferCreate (BREthereumAddress sourceAddress, BREthereumAddress targetAddress, BREthereumAmount amount, BREthereumFeeBasis feeBasis, BREthereumTransferBasisType transferBasisType) { BREthereumTransfer transfer = transferCreateDetailed (sourceAddress, targetAddress, amount, feeBasis, NULL); // Assigns originatingTransaction transferProvideOriginatingTransaction(transfer); // Basis. Note: if the transferBasisType is BASIS_TRANSACTION, then we *could* fill in the // .transaction field; however, for 'reasons of symmetry' we won't fill in the .transaction // field except in circumstances where we could fill in the .log field. // // We used to fill in .transaction with a copy of the originating transaction. transfer->basis.type = transferBasisType; // Former comment on TRANSFER_BASIS_LOG: // // We cannot possibly know what the log is; knowing would require us to implement // the Ethereum virtual machine. Granted we are only creating ERC20 transfers and // thus could compute the log? // Status transfer->status = transferStatusCreate(transactionGetStatus(transfer->originatingTransaction)); return transfer; } // TODO: Is this `transaction` the basis? Used for 'cancel' - how to cancel a token transfer? extern BREthereumTransfer transferCreateWithTransactionOriginating (OwnershipGiven BREthereumTransaction transaction, BREthereumTransferBasisType transferBasisType) { BREthereumFeeBasis feeBasis = { FEE_BASIS_GAS, { .gas = { transactionGetGasLimit(transaction), transactionGetGasPrice(transaction) }} }; // Use `transaction` as the `originatingTransaction`; takes ownership BREthereumTransfer transfer = transferCreateDetailed (transactionGetSourceAddress(transaction), transactionGetTargetAddress(transaction), amountCreateEther (transactionGetAmount(transaction)), feeBasis, transaction); // Basis: See comments above in `transferCreate()` transfer->basis.type = transferBasisType; // Status transfer->status = transferStatusCreate(transactionGetStatus(transaction)); return transfer; } extern BREthereumTransfer transferCreateWithTransaction (OwnershipGiven BREthereumTransaction transaction) { BREthereumFeeBasis feeBasis = { FEE_BASIS_GAS, { .gas = { transactionGetGasLimit(transaction), transactionGetGasPrice(transaction) }} }; // No originating transaction BREthereumTransfer transfer = transferCreateDetailed (transactionGetSourceAddress(transaction), transactionGetTargetAddress(transaction), amountCreateEther (transactionGetAmount(transaction)), feeBasis, NULL); // Basis - the transfer now owns the transaction. transfer->basis = (BREthereumTransferBasis) { TRANSFER_BASIS_TRANSACTION, { .transaction = transaction } }; // Status transfer->status = transferStatusCreate(transactionGetStatus(transaction)); return transfer; } extern BREthereumTransfer transferCreateWithLog (OwnershipGiven BREthereumLog log, BREthereumToken token, BRRlpCoder coder) { BREthereumFeeBasis feeBasis = { FEE_BASIS_NONE }; assert (3 == logGetTopicsCount(log)); // TODO: Is this a log of interest? // BREthereumAddress contractAddress = logGetAddress(log); BREthereumAddress sourceAddress = logTopicAsAddress(logGetTopic(log, 1)); BREthereumAddress targetAddress = logTopicAsAddress(logGetTopic(log, 2)); // Only at this point do we know that log->data is a number. BRRlpItem item = rlpGetItem (coder, logGetDataShared(log)); UInt256 value = rlpDecodeUInt256(coder, item, 1); rlpReleaseItem (coder, item); BREthereumAmount amount = amountCreateToken (createTokenQuantity(token, value)); // No originating transaction BREthereumTransfer transfer = transferCreateDetailed (sourceAddress, targetAddress, amount, feeBasis, NULL); // Basis - the transfer now owns the log transfer->basis = (BREthereumTransferBasis) { TRANSFER_BASIS_LOG, { .log = log } }; // Status transfer->status = transferStatusCreate(logGetStatus(log)); return transfer; } extern void transferRelease (BREthereumTransfer transfer) { transactionRelease (transfer->originatingTransaction); transferBasisRelease (&transfer->basis); free (transfer); } extern BREthereumAddress transferGetSourceAddress (BREthereumTransfer transfer) { return transfer->sourceAddress; } extern BREthereumAddress transferGetTargetAddress (BREthereumTransfer transfer) { return transfer->targetAddress; } extern BREthereumAmount transferGetAmount (BREthereumTransfer transfer) { return transfer->amount; } extern BREthereumToken transferGetToken (BREthereumTransfer transfer) { return (AMOUNT_TOKEN == amountGetType(transfer->amount) ? amountGetToken(transfer->amount) : NULL); } extern BREthereumFeeBasis transferGetFeeBasis (BREthereumTransfer transfer) { return transfer->feeBasis; } extern BREthereumGas transferGetGasEstimate (BREthereumTransfer transfer) { return transfer->gasEstimate; } extern void transferSetGasEstimate (BREthereumTransfer transfer, BREthereumGas gasEstimate) { transfer->gasEstimate = gasEstimate; // Generally, you'd only set the gas estimate for a transfer that a) you have originated and // b) that you haven't submitted. Perhaps we should constrain setting the estimate to only // transfers that you have originated? On the other hand, if for display purposed you want // to set an estimate and then get the estimate to display, then perhaps originating the // transfer should not be required. if (NULL != transfer->originatingTransaction) transactionSetGasEstimate (transfer->originatingTransaction, gasEstimate); } extern BREthereumTransaction transferGetOriginatingTransaction (BREthereumTransfer transfer) { return transfer->originatingTransaction; } extern BREthereumTransaction transferGetBasisTransaction (BREthereumTransfer transfer) { return (TRANSFER_BASIS_TRANSACTION == transfer->basis.type ? transfer->basis.u.transaction : NULL); } extern BREthereumLog transferGetBasisLog (BREthereumTransfer transfer) { return (TRANSFER_BASIS_LOG == transfer->basis.type ? transfer->basis.u.log : NULL); } extern void transferSign (BREthereumTransfer transfer, BREthereumNetwork network, BREthereumAccount account, BREthereumAddress address, const char *paperKey) { if (TRANSACTION_NONCE_IS_NOT_ASSIGNED == transactionGetNonce(transfer->originatingTransaction)) transactionSetNonce (transfer->originatingTransaction, accountGetThenIncrementAddressNonce(account, address)); // RLP Encode the UNSIGNED transfer BRRlpCoder coder = rlpCoderCreate(); BRRlpItem item = transactionRlpEncode (transfer->originatingTransaction, network, RLP_TYPE_TRANSACTION_UNSIGNED, coder); BRRlpData data = rlpGetDataSharedDontRelease(coder, item); // Sign the RLP Encoded bytes. BREthereumSignature signature = accountSignBytes (account, address, SIGNATURE_TYPE_RECOVERABLE_VRS_EIP, data.bytes, data.bytesCount, paperKey); rlpReleaseItem(coder, item); // Attach the signature transactionSign (transfer->originatingTransaction, signature); // Compute the hash item = transactionRlpEncode (transfer->originatingTransaction, network, RLP_TYPE_TRANSACTION_SIGNED, coder); transactionSetHash (transfer->originatingTransaction, hashCreateFromData (rlpGetDataSharedDontRelease (coder, item))); rlpReleaseItem(coder, item); rlpCoderRelease(coder); } extern void transferSignWithKey (BREthereumTransfer transfer, BREthereumNetwork network, BREthereumAccount account, BREthereumAddress address, BRKey privateKey) { if (TRANSACTION_NONCE_IS_NOT_ASSIGNED == transactionGetNonce(transfer->originatingTransaction)) transactionSetNonce (transfer->originatingTransaction, accountGetThenIncrementAddressNonce(account, address)); // RLP Encode the UNSIGNED transfer BRRlpCoder coder = rlpCoderCreate(); BRRlpItem item = transactionRlpEncode (transfer->originatingTransaction, network, RLP_TYPE_TRANSACTION_UNSIGNED, coder); BRRlpData data = rlpGetDataSharedDontRelease (coder, item); // Sign the RLP Encoded bytes. BREthereumSignature signature = accountSignBytesWithPrivateKey (account, address, SIGNATURE_TYPE_RECOVERABLE_VRS_EIP, data.bytes, data.bytesCount, privateKey); rlpReleaseItem(coder, item); // Attach the signature transactionSign(transfer->originatingTransaction, signature); // Compute the hash item = transactionRlpEncode (transfer->originatingTransaction, network, RLP_TYPE_TRANSACTION_SIGNED, coder); transactionSetHash (transfer->originatingTransaction, hashCreateFromData (rlpGetDataSharedDontRelease (coder, item))); rlpReleaseItem(coder, item); rlpCoderRelease(coder); } /** * The transfer's unique identifier, as a hash. This identifier CAN ONLY EXIST once the transfer * has been included Essentially, a transfer based on a log cannot have a unique identifier until * the log has an `indexInBlock`. If we thought that the log's identifier could be the * originating transaction's log; we'd be wrong because in general one transaction can produce * multiple logs (although, for ERC20 transfers it is one transaction <==> one log). * * @param transfer * * @return a hash, may be EMPTY_HASH_INIT */ extern const BREthereumHash transferGetIdentifier (BREthereumTransfer transfer) { switch (transfer->basis.type) { case TRANSFER_BASIS_TRANSACTION: return (NULL == transfer->basis.u.transaction ? EMPTY_HASH_INIT : transactionGetHash(transfer->basis.u.transaction)); case TRANSFER_BASIS_LOG: return (NULL == transfer->basis.u.log ? EMPTY_HASH_INIT : logGetHash(transfer->basis.u.log)); } } extern const BREthereumHash transferGetOriginatingTransactionHash (BREthereumTransfer transfer) { // If we have an originatingTransaction - becasue we created the transfer - then return its // hash. Otherwise use the transfer's basis to get the hash return (NULL != transfer->originatingTransaction ? transactionGetHash (transfer->originatingTransaction) : transferBasisGetHash(&transfer->basis)); } extern uint64_t transferGetNonce (BREthereumTransfer transfer) { return (NULL != transfer->originatingTransaction ? transactionGetNonce (transfer->originatingTransaction) : (TRANSFER_BASIS_TRANSACTION == transfer->basis.type && NULL != transfer->basis.u.transaction ? transactionGetNonce(transfer->basis.u.transaction) : TRANSACTION_NONCE_IS_NOT_ASSIGNED)); } extern BREthereumEther transferGetFee (BREthereumTransfer transfer, int *overflow) { if (NULL != overflow) *overflow = 0; // If we have a basis, then the transfer is confirmed; use the actual fee. if (TRANSFER_BASIS_LOG == transfer->basis.type && NULL != transfer->basis.u.log) return etherCreateZero(); else if (TRANSFER_BASIS_TRANSACTION == transfer->basis.type && NULL != transfer->basis.u.transaction) return transactionGetFee (transfer->basis.u.transaction, overflow); else if (NULL != transfer->originatingTransaction) return transactionGetFee (transfer->originatingTransaction, overflow); else return etherCreateZero(); } /// MARK: - Basis extern void transferSetBasisForTransaction (BREthereumTransfer transfer, OwnershipGiven BREthereumTransaction transaction) { // The transfer must already have a TRANSACTION basis. assert (TRANSFER_BASIS_TRANSACTION == transfer->basis.type); assert (NULL != transaction); // Release a pre-existing transaction if (transfer->basis.u.transaction != transaction) transferBasisRelease (&transfer->basis); transfer->basis = (BREthereumTransferBasis) { TRANSFER_BASIS_TRANSACTION, { .transaction = transaction } }; transfer->status = transferStatusCreate (transactionGetStatus(transaction)); } extern void transferSetBasisForLog (BREthereumTransfer transfer, OwnershipGiven BREthereumLog log) { assert (TRANSFER_BASIS_LOG == transfer->basis.type); assert (NULL != log); // Release a pre-existing log if (transfer->basis.u.log != log) transferBasisRelease (&transfer->basis); transfer->basis = (BREthereumTransferBasis) { TRANSFER_BASIS_LOG, { .log = log } }; transfer->status = transferStatusCreate (logGetStatus(log)); } /// MARK: - Status extern BREthereumTransactionStatus transferGetStatusForBasis (BREthereumTransfer transfer) { switch (transfer->basis.type) { case TRANSFER_BASIS_TRANSACTION: assert (NULL != transfer->basis.u.transaction || NULL != transfer->originatingTransaction); return (NULL != transfer->basis.u.transaction ? transactionGetStatus (transfer->basis.u.transaction) : transactionGetStatus (transfer->originatingTransaction)); case TRANSFER_BASIS_LOG: assert (NULL != transfer->basis.u.log || NULL != transfer->originatingTransaction); return (NULL != transfer->basis.u.log ? logGetStatus (transfer->basis.u.log) : transactionGetStatus (transfer->originatingTransaction)); } } extern void transferSetStatusForBasis (BREthereumTransfer transfer, BREthereumTransactionStatus status) { transfer->status = transferStatusCreate(status); } extern void transferSetStatus (BREthereumTransfer transfer, BREthereumTransferStatus status) { transfer->status = status; } extern BREthereumTransferStatus transferGetStatus (BREthereumTransfer transfer) { return transfer->status; } extern BREthereumBoolean transferHasStatus (BREthereumTransfer transfer, BREthereumTransferStatus type) { return AS_ETHEREUM_BOOLEAN(transfer->status == type); } extern BREthereumBoolean transferHasStatusOrTwo (BREthereumTransfer transfer, BREthereumTransferStatus type1, BREthereumTransferStatus type2) { return AS_ETHEREUM_BOOLEAN(transfer->status == type1 || transfer->status == type2); } extern int transferExtractStatusIncluded (BREthereumTransfer transfer, BREthereumHash *blockHash, uint64_t *blockNumber, uint64_t *transactionIndex, uint64_t *blockTimestamp, BREthereumGas *gasUsed) { if (TRANSFER_STATUS_INCLUDED != transfer->status) return 0; BREthereumTransactionStatus status = transferGetStatusForBasis (transfer); if (NULL != blockHash) *blockHash = status.u.included.blockHash; if (NULL != blockNumber) *blockNumber = status.u.included.blockNumber; if (NULL != transactionIndex) *transactionIndex = status.u.included.transactionIndex; if (NULL != blockTimestamp) *blockTimestamp = status.u.included.blockTimestamp; if (NULL != gasUsed) *gasUsed = status.u.included.gasUsed; return 1; } extern int transferExtractStatusError (BREthereumTransfer transfer, char **reason) { if (TRANSFER_STATUS_ERRORED != transfer->status) return 0; BREthereumTransactionStatus status = transferGetStatusForBasis (transfer); if (NULL != reason) *reason = strdup (transactionGetErrorName (status.u.errored.type)); return 1; } extern int transferExtractStatusErrorType (BREthereumTransfer transfer, BREthereumTransactionErrorType *type) { if (TRANSFER_STATUS_ERRORED != transfer->status) return 0; BREthereumTransactionStatus status = transferGetStatusForBasis (transfer); if (NULL != type) *type = status.u.errored.type; return 1; } /// MARK: - Originating Transaction static char * transferProvideOriginatingTransactionData (BREthereumTransfer transfer) { switch (amountGetType(transfer->amount)) { case AMOUNT_ETHER: return strdup (""); case AMOUNT_TOKEN: { UInt256 value = amountGetTokenQuantity(transfer->amount).valueAsInteger; char address[ADDRESS_ENCODED_CHARS]; addressFillEncodedString(transfer->targetAddress, 0, address); // Data is a HEX ENCODED string return (char *) contractEncode (contractERC20, functionERC20Transfer, // Address (uint8_t *) &address[2], strlen(address) - 2, // Amount (uint8_t *) &value, sizeof (UInt256), NULL); } } } static BREthereumAddress transferProvideOriginatingTransactionTargetAddress (BREthereumTransfer transfer) { switch (amountGetType(transfer->amount)) { case AMOUNT_ETHER: return transfer->targetAddress; case AMOUNT_TOKEN: return tokenGetAddressRaw(amountGetToken(transfer->amount)); } } static BREthereumEther transferProvideOriginatingTransactionAmount (BREthereumTransfer transfer) { switch (amountGetType(transfer->amount)) { case AMOUNT_ETHER: return transfer->amount.u.ether; case AMOUNT_TOKEN: return etherCreateZero(); } } static void transferProvideOriginatingTransaction (BREthereumTransfer transfer) { if (NULL != transfer->originatingTransaction) transactionRelease (transfer->originatingTransaction); char *data = transferProvideOriginatingTransactionData(transfer); transfer->originatingTransaction = transactionCreate (transfer->sourceAddress, transferProvideOriginatingTransactionTargetAddress (transfer), transferProvideOriginatingTransactionAmount (transfer), feeBasisGetGasPrice(transfer->feeBasis), feeBasisGetGasLimit(transfer->feeBasis), data, TRANSACTION_NONCE_IS_NOT_ASSIGNED); free (data); } private_extern BREthereumEther transferGetEffectiveAmountInEther(BREthereumTransfer transfer) { switch (transfer->basis.type) { case TRANSFER_BASIS_LOG: return etherCreateZero(); case TRANSFER_BASIS_TRANSACTION: return transactionGetAmount(NULL != transfer->basis.u.transaction ? transfer->basis.u.transaction : transfer->originatingTransaction); } } extern BREthereumComparison transferCompare (BREthereumTransfer t1, BREthereumTransfer t2) { assert (t1->basis.type == t2->basis.type); switch (t1->basis.type) { case TRANSFER_BASIS_TRANSACTION: return transactionCompare (t1->basis.u.transaction, t2->basis.u.transaction); case TRANSFER_BASIS_LOG: return logCompare (t1->basis.u.log, t2->basis.u.log); } } extern void transfersRelease (OwnershipGiven BRArrayOf(BREthereumTransfer) transfers) { if (NULL != transfers) { size_t count = array_count (transfers); for (size_t index = 0; index < count; index++) transferRelease(transfers[index]); array_free (transfers); } } extern BREthereumBoolean transferStatusEqual (BREthereumTransferStatus status1, BREthereumTransferStatus status2) { return AS_ETHEREUM_BOOLEAN (status1 == status2); }
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Plugin/Transaction/TransactionInput.h
<reponame>fakecoinbase/elastosslashElastos.ELA.SPV.Cpp // Copyright (c) 2012-2018 The Elastos Open Source Project // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef __ELASTOS_SDK_TRANSACTIONINPUT_H__ #define __ELASTOS_SDK_TRANSACTIONINPUT_H__ #include <Common/ByteStream.h> #include <Common/JsonSerializer.h> #include <Plugin/Interface/ELAMessageSerializable.h> #include <nlohmann/json.hpp> #include <string> namespace Elastos { namespace ElaWallet { class TransactionInput : public ELAMessageSerializable, public JsonSerializer { public: TransactionInput(); TransactionInput(const TransactionInput &input); TransactionInput &operator=(const TransactionInput &tx); TransactionInput(const uint256 &txHash, uint16_t index); ~TransactionInput(); const uint256 &TxHash() const; void SetTxHash(const uint256 &hash); uint16_t Index() const; void SetIndex(uint16_t index); uint32_t Sequence() const; void SetSequence(uint32_t sequence); size_t EstimateSize() const; void Serialize(ByteStream &ostream) const; bool Deserialize(const ByteStream &istream); nlohmann::json ToJson() const; void FromJson(const nlohmann::json &j); size_t GetSize() const; private: uint256 _txHash; uint16_t _index; uint32_t _sequence; }; typedef boost::shared_ptr<TransactionInput> InputPtr; typedef std::vector<InputPtr> InputArray; } } #endif //__ELASTOS_SDK_TRANSACTIONINPUT_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Plugin/Transaction/Payload/CRCProposal.h
/* * Copyright (c) 2019 Elastos Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef __ELASTOS_SDK_CRCPROPOSAL_H__ #define __ELASTOS_SDK_CRCPROPOSAL_H__ #include "IPayload.h" #include <Common/BigInt.h> #include <Common/JsonSerializer.h> #include <WalletCore/Address.h> namespace Elastos { namespace ElaWallet { #define CRCProposalDefaultVersion 0 class Budget : public JsonSerializer { public: enum Type { imprest = 0x00, normalPayment = 0x01, finalPayment = 0x02, maxType }; Budget(); Budget(Budget::Type type, uint8_t stage, const BigInt &amount); ~Budget(); Budget::Type GetType() const; uint8_t GetStage() const; BigInt GetAmount() const; void Serialize(ByteStream &ostream) const; bool Deserialize(const ByteStream &istream); bool IsValid() const; nlohmann::json ToJson() const override; void FromJson(const nlohmann::json &j) override; private: Budget::Type _type; uint8_t _stage; BigInt _amount; }; class CRCProposal : public IPayload { public: enum Type { normal = 0x0000, elip = 0x0100, // flowElip = 0x0101, // infoElip = 0x0102, // mainChainUpgradeCode = 0x0200, // sideChainUpgradeCode = 0x0300, // registerSideChain = 0x0301, // secretaryGeneral = 0x0400, // changeSponsor = 0x0401, // closeProposal = 0x0402, // dappConsensus = 0x0500, maxType }; CRCProposal(); ~CRCProposal(); void SetTpye(CRCProposal::Type type); CRCProposal::Type GetType() const; void SetCategoryData(const std::string &categoryData); const std::string &GetCategoryData() const; void SetOwnerPublicKey(const bytes_t &publicKey); const bytes_t &GetOwnerPublicKey() const; void SetCRCouncilMemberDID(const Address &crSponsorDID); const Address &GetCRCouncilMemberDID() const; void SetDraftHash(const uint256 &draftHash); const uint256 &GetDraftHash() const; void SetBudgets(const std::vector<Budget> &budgets); const std::vector<Budget> &GetBudgets() const; void SetRecipient(const Address &recipient); const Address &GetRecipient() const; void SetSignature(const bytes_t &signature); const bytes_t &GetSignature() const; void SetCRCouncilMemberSignature(const bytes_t &signature); const bytes_t &GetCRCouncilMemberSignature() const; const uint256 &DigestOwnerUnsigned(uint8_t version) const; const uint256 &DigestCRCouncilMemberUnsigned(uint8_t version) const; public: size_t EstimateSize(uint8_t version) const override; void SerializeOwnerUnsigned(ByteStream &ostream, uint8_t version) const; bool DeserializeOwnerUnsigned(const ByteStream &istream, uint8_t version); void SerializeCRCouncilMemberUnsigned(ByteStream &ostream, uint8_t version) const; bool DeserializeCRCouncilMemberUnsigned(const ByteStream &istream, uint8_t version); void Serialize(ByteStream &ostream, uint8_t version) const override; bool Deserialize(const ByteStream &istream, uint8_t version) override; nlohmann::json ToJsonOwnerUnsigned(uint8_t version) const; void FromJsonOwnerUnsigned(const nlohmann::json &j, uint8_t version); nlohmann::json ToJsonCRCouncilMemberUnsigned(uint8_t version) const; void FromJsonCRCouncilMemberUnsigned(const nlohmann::json &j, uint8_t version); nlohmann::json ToJson(uint8_t version) const override; void FromJson(const nlohmann::json &j, uint8_t version) override; bool IsValidOwnerUnsigned(uint8_t version) const; bool IsValidCRCouncilMemberUnsigned(uint8_t version) const; bool IsValid(uint8_t version) const override; IPayload &operator=(const IPayload &payload) override; CRCProposal &operator=(const CRCProposal &payload); private: mutable uint256 _digestOwnerUnsigned; mutable uint256 _digestCRCouncilMemberUnsigned; private: CRCProposal::Type _type; std::string _categoryData; bytes_t _ownerPublicKey; uint256 _draftHash; std::vector <Budget> _budgets; Address _recipient; bytes_t _signature; // cr council member did Address _crCouncilMemberDID; bytes_t _crCouncilMemberSignature; }; } } namespace nlohmann { template<> struct adl_serializer<Elastos::ElaWallet::Budget> { static void to_json(json &j, const Elastos::ElaWallet::Budget &budget) { j = budget.ToJson(); } static void from_json(const json &j, Elastos::ElaWallet::Budget &budget) { budget.FromJson(j); } }; } #endif //__ELASTOS_SDK_CRCPROPOSAL_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
Interface/IIDChainSubWallet.h
/* * Copyright (c) 2019 Elastos Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef __ELASTOS_SDK_IIDCHAINSUBWALLET_H__ #define __ELASTOS_SDK_IIDCHAINSUBWALLET_H__ #include "ISidechainSubWallet.h" namespace Elastos { namespace ElaWallet { class IIDChainSubWallet : public virtual ISidechainSubWallet { public: /** * Virtual destructor. */ virtual ~IIDChainSubWallet() noexcept {} /** * Create a id transaction and return the content of transaction in json format, this is a special transaction to register id related information on id chain. * @param payloadJson is payload for register id related information in json format, the content of payload should have Id, Path, DataHash, Proof, and Sign. * @param memo input memo attribute for describing. * @return If success return the content of transaction in json format. */ virtual nlohmann::json CreateIDTransaction( const nlohmann::json &payloadJson, const std::string &memo = "") = 0; /** * Get all DID derived of current subwallet. * @param start specify start index of all DID list. * @param count specify count of DID we need. * @return If success return all DID in JSON format. * * example: * GetAllDID(0, 3) will return below * { * "DID": ["iZDgaZZjRPGCE4x8id6YYJ158RxfTjTnCt", "iPbdmxUVBzfNrVdqJzZEySyWGYeuKAeKqv", "iT42VNGXNUeqJ5yP4iGrqja6qhSEdSQmeP"], * "MaxCount": 100 * } */ virtual nlohmann::json GetAllDID(uint32_t start, uint32_t count) const = 0; virtual nlohmann::json GetAllCID(uint32_t start, uint32_t count) const = 0; /** * Sign message with private key of did. * @param DIDOrCID will sign the message with public key of this did/cid. * @param message to be signed. * @param payPassword pay password. * @return If success, signature will be returned. */ virtual std::string Sign( const std::string &DIDOrCID, const std::string &message, const std::string &payPassword) const = 0; /** * Sign message with private key of did. * @param DIDOrCID will sign the message with public key of this did/cid. * @param digest hex string of sha256 * @param payPassword pay password. * @return If success, signature will be returned. */ virtual std::string SignDigest( const std::string &DIDOrCID, const std::string &digest, const std::string &payPassword) const = 0; /** * Verify signature with specify public key * @param publicKey public key. * @param message message to be verified. * @param signature signature to be verified. * @return true or false. */ virtual bool VerifySignature( const std::string &publicKey, const std::string &message, const std::string &signature) = 0; /** * Get DID by public key * @param pubkey public key * @return did string */ virtual std::string GetPublicKeyDID(const std::string &pubkey) const = 0; /** * Get CID by public key * @param pubkey * @return cid string */ virtual std::string GetPublicKeyCID(const std::string &pubkey) const = 0; }; } } #endif //__ELASTOS_SDK_IIDCHAINSUBWALLET_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Implement/IDChainSubWallet.h
<filename>SDK/Implement/IDChainSubWallet.h<gh_stars>0 /* * Copyright (c) 2019 Elastos Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef __ELASTOS_SDK_IDCHAINSUBWALLET_H__ #define __ELASTOS_SDK_IDCHAINSUBWALLET_H__ #include "SidechainSubWallet.h" #include "IIDChainSubWallet.h" namespace Elastos { namespace ElaWallet { class CredentialSubject; class VerifiableCredential; class DIDInfo; class IDChainSubWallet : public SidechainSubWallet, public IIDChainSubWallet { public: virtual ~IDChainSubWallet(); virtual nlohmann::json CreateIDTransaction( const nlohmann::json &payloadJson, const std::string &memo = ""); virtual nlohmann::json GetAllDID(uint32_t start, uint32_t count) const; virtual nlohmann::json GetAllCID(uint32_t start, uint32_t count) const; virtual std::string Sign(const std::string &DIDOrCID, const std::string &message, const std::string &payPassword) const; virtual std::string SignDigest(const std::string &DIDOrCID, const std::string &digest, const std::string &payPassword) const; virtual bool VerifySignature(const std::string &publicKey, const std::string &message, const std::string &signature); virtual std::string GetPublicKeyDID(const std::string &pubkey) const; virtual std::string GetPublicKeyCID(const std::string &pubkey) const; protected: friend class MasterWallet; IDChainSubWallet(const CoinInfoPtr &info, const ChainConfigPtr &config, MasterWallet *parent, const std::string &netType); }; } } #endif //__ELASTOS_SDK_IDCHAINSUBWALLET_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Database/PeerDataSource.h
<filename>SDK/Database/PeerDataSource.h /* * Copyright (c) 2019 Elastos Foundation * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ #ifndef __ELASTOS_SDK_PEERDATASOURCE_H__ #define __ELASTOS_SDK_PEERDATASOURCE_H__ #include "Sqlite.h" #include "TableBase.h" #include <Common/uint256.h> namespace Elastos { namespace ElaWallet { struct PeerEntity { PeerEntity() : id(0), port(0), timeStamp(0) { } PeerEntity(long i, const uint128 &addr, uint16_t p, uint64_t ts) : id(i), address(addr), port(p), timeStamp(ts) { } long id; uint128 address; uint16_t port; uint64_t timeStamp; }; class PeerDataSource : public TableBase { public: PeerDataSource(Sqlite *sqlite, SqliteTransactionType type = IMMEDIATE); ~PeerDataSource(); virtual void InitializeTable(); bool PutPeer(const PeerEntity &peerEntity); bool PutPeers(const std::vector<PeerEntity> &peerEntities); bool DeletePeer(const PeerEntity &peerEntity); bool DeleteAllPeers(); size_t GetAllPeersCount() const; std::vector<PeerEntity> GetAllPeers() const; private: bool Contain(const PeerEntity &entity) const; bool PutPeerInternal(const PeerEntity &peerEntity); private: /* * peer table */ const std::string PEER_TABLE_NAME = "peerTable"; const std::string PEER_COLUMN_ID = "_id"; const std::string PEER_ADDRESS = "peerAddress"; const std::string PEER_PORT = "peerPort"; const std::string PEER_TIMESTAMP = "peerTimestamp"; const std::string PEER_ISO = "peerISO"; const std::string PEER_DATABASE_CREATE = "create table if not exists " + PEER_TABLE_NAME + " (" + PEER_COLUMN_ID + " integer primary key autoincrement, " + PEER_ADDRESS + " blob," + PEER_PORT + " integer," + PEER_TIMESTAMP + " integer," + PEER_ISO + " text default 'ELA');"; }; } } #endif //__ELASTOS_SDK_PEERDATASOURCE_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Plugin/Transaction/Transaction.h
// Copyright (c) 2012-2018 The Elastos Open Source Project // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef __ELASTOS_SDK_TRANSACTION_H__ #define __ELASTOS_SDK_TRANSACTION_H__ #include <Common/JsonSerializer.h> #include <Plugin/Interface/ELAMessageSerializable.h> #include <Plugin/Transaction/Payload/IPayload.h> #include <boost/shared_ptr.hpp> namespace Elastos { namespace ElaWallet { class Wallet; class TransactionOutput; class TransactionInput; class Program; class Attribute; typedef boost::shared_ptr<Wallet> WalletPtr; typedef boost::shared_ptr<TransactionOutput> OutputPtr; typedef std::vector<OutputPtr> OutputArray; typedef boost::shared_ptr<TransactionInput> InputPtr; typedef std::vector<InputPtr> InputArray; typedef boost::shared_ptr<Program> ProgramPtr; typedef std::vector<ProgramPtr> ProgramArray; typedef boost::shared_ptr<Attribute> AttributePtr; typedef std::vector<AttributePtr> AttributeArray; class Transaction : public JsonSerializer { public: enum { coinBase = 0x00, registerAsset = 0x01, transferAsset = 0x02, record = 0x03, deploy = 0x04, sideChainPow = 0x05, rechargeToSideChain = 0x06, withdrawFromSideChain = 0x07, transferCrossChainAsset = 0x08, registerProducer = 0x09, cancelProducer = 0x0a, updateProducer = 0x0b, returnDepositCoin = 0x0c, activateProducer = 0x0d, IllegalProposalEvidence = 0x0e, IllegalVoteEvidence = 0x0f, IllegalBlockEvidence = 0x10, IllegalSidechainEvidence = 0x11, InactiveArbitrators = 0x12, UpdateVersion = 0x13, registerCR = 0x21, unregisterCR = 0x22, updateCR = 0x23, returnCRDepositCoin = 0x24, crcProposal = 0x25, crcProposalReview = 0x26, crcProposalTracking = 0x27, crcAppropriation = 0x28, crcProposalWithdraw = 0x29, TypeMaxCount }; enum TxVersion { Default = 0x00, V09 = 0x09, }; public: Transaction(); Transaction(uint8_t type, const PayloadPtr &payload); Transaction(const Transaction &tx); Transaction &operator=(const Transaction &tx); virtual ~Transaction(); void Serialize(ByteStream &ostream, bool extend = false) const; bool Deserialize(const ByteStream &istream, bool extend = false); virtual bool DeserializeType(const ByteStream &istream); uint64_t CalculateFee(uint64_t feePerKb); uint64_t GetTxFee(const boost::shared_ptr<Wallet> &wallet); bool IsRegistered() const; bool &IsRegistered(); const uint256 &GetHash() const; void SetHash(const uint256 &hash); void ResetHash(); const TxVersion &GetVersion() const; void SetVersion(const TxVersion &version); const std::vector<OutputPtr> &GetOutputs() const; void FixIndex(); OutputPtr OutputOfIndex(uint16_t fixedIndex) const; void SetOutputs(const std::vector<OutputPtr> &outputs); void AddOutput(const OutputPtr &output); void RemoveOutput(const OutputPtr &output); const std::vector<InputPtr> &GetInputs() const; std::vector<InputPtr> &GetInputs(); void AddInput(const InputPtr &Input); bool ContainInput(const uint256 &hash, uint32_t n) const; uint8_t GetTransactionType() const; virtual bool IsDPoSTransaction() const; virtual bool IsCRCTransaction() const; virtual bool IsProposalTransaction() const; virtual bool IsIDTransaction() const; uint32_t GetLockTime() const; void SetLockTime(uint32_t lockTime); uint32_t GetBlockHeight() const; void SetBlockHeight(uint32_t height); time_t GetTimestamp() const; void SetTimestamp(time_t timestamp); size_t EstimateSize() const; nlohmann::json GetSignedInfo() const; bool IsSigned() const; bool IsCoinBase() const; bool IsUnconfirmed() const; bool IsValid() const; virtual nlohmann::json ToJson() const; virtual void FromJson(const nlohmann::json &j); static uint64_t GetMinOutputAmount(); const IPayload *GetPayload() const; IPayload *GetPayload(); const PayloadPtr &GetPayloadPtr() const; void SetPayload(const PayloadPtr &payload); void AddAttribute(const AttributePtr &attribute); bool AddUniqueProgram(const ProgramPtr &program); void AddProgram(const ProgramPtr &program); void ClearPrograms(); const std::vector<AttributePtr> &GetAttributes() const; const std::vector<ProgramPtr> &GetPrograms() const; nlohmann::json GetSummary(const WalletPtr &wallet, uint32_t confirms, bool detail); uint8_t GetPayloadVersion() const; void SetPayloadVersion(uint8_t version); uint64_t GetFee() const; void SetFee(uint64_t fee); void SerializeUnsigned(ByteStream &ostream, bool extend = false) const; uint256 GetShaData() const; void Cleanup(); bool IsEqual(const Transaction &tx) const; uint32_t GetConfirms(uint32_t walletBlockHeight) const; std::string GetConfirmStatus(uint32_t walletBlockHeight) const; public: virtual PayloadPtr InitPayload(uint8_t type); private: void Reinit(); protected: bool _isRegistered; mutable uint256 _txHash; TxVersion _version; // uint8_t uint32_t _lockTime; uint32_t _blockHeight; time_t _timestamp; // time interval since unix epoch uint8_t _type; uint8_t _payloadVersion; uint64_t _fee; PayloadPtr _payload; OutputArray _outputs; InputArray _inputs; AttributeArray _attributes; ProgramArray _programs; }; typedef boost::shared_ptr<Transaction> TransactionPtr; } } namespace nlohmann { template<> struct adl_serializer<Elastos::ElaWallet::Transaction> { static void to_json(json &j, const Elastos::ElaWallet::Transaction &tx) { j = tx.ToJson(); } static void from_json(const json &j, Elastos::ElaWallet::Transaction &tx) { tx.FromJson(j); } }; } #endif //__ELASTOS_SDK_TRANSACTION_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/WalletCore/WordLists/Japanese.h
<filename>SDK/WalletCore/WordLists/Japanese.h // Copyright (c) 2012-2018 The Elastos Open Source Project // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef __ELASTOS_SDK_JAPANESE_H__ #define __ELASTOS_SDK_JAPANESE_H__ namespace Elastos { namespace ElaWallet { const std::vector<std::string> JapaneseWordLists = { "ใ‚ใ„ใ“ใใ—ใ‚“", "ใ‚ใ„ใ•ใค", "ใ‚ใ„ใŸใ‚™", "ใ‚ใŠใใ‚™ใ‚‰", "ใ‚ใ‹ใกใ‚ƒใ‚“", "ใ‚ใใ‚‹", "ใ‚ใ‘ใ‹ใ‚™ใŸ", "ใ‚ใ‘ใ‚‹", "ใ‚ใ“ใ‹ใ‚™ใ‚Œใ‚‹", "ใ‚ใ•ใ„", "ใ‚ใ•ใฒ", "ใ‚ใ—ใ‚ใจ", "ใ‚ใ—ใ‚™ใ‚ใ†", "ใ‚ใ™ใ‚™ใ‹ใ‚‹", "ใ‚ใ™ใ‚™ใ", "ใ‚ใใตใ‚™", "ใ‚ใŸใˆใ‚‹", "ใ‚ใŸใŸใ‚ใ‚‹", "ใ‚ใŸใ‚Šใพใˆ", "ใ‚ใŸใ‚‹", "ใ‚ใคใ„", "ใ‚ใคใ‹ใ†", "ใ‚ใฃใ—ใ‚…ใ", "ใ‚ใคใพใ‚Š", "ใ‚ใคใ‚ใ‚‹", "ใ‚ใฆใช", "ใ‚ใฆใฏใพใ‚‹", "ใ‚ใฒใ‚‹", "ใ‚ใตใ‚™ใ‚‰", "ใ‚ใตใ‚™ใ‚‹", "ใ‚ใตใ‚Œใ‚‹", "ใ‚ใพใ„", "ใ‚ใพใจใ‚™", "ใ‚ใพใ‚„ใ‹ใ™", "ใ‚ใพใ‚Š", "ใ‚ใฟใ‚‚ใฎ", "ใ‚ใ‚ใ‚Šใ‹", "ใ‚ใ‚„ใพใ‚‹", "ใ‚ใ‚†ใ‚€", "ใ‚ใ‚‰ใ„ใใ‚™ใพ", "ใ‚ใ‚‰ใ—", "ใ‚ใ‚‰ใ™ใ—ใ‚™", "ใ‚ใ‚‰ใŸใ‚ใ‚‹", "ใ‚ใ‚‰ใ‚†ใ‚‹", "ใ‚ใ‚‰ใ‚ใ™", "ใ‚ใ‚Šใ‹ใ‚™ใจใ†", "ใ‚ใ‚ใ›ใ‚‹", "ใ‚ใ‚ใฆใ‚‹", "ใ‚ใ‚“ใ„", "ใ‚ใ‚“ใ‹ใ‚™ใ„", "ใ‚ใ‚“ใ“", "ใ‚ใ‚“ใ›ใ‚™ใ‚“", "ใ‚ใ‚“ใฆใ„", "ใ‚ใ‚“ใชใ„", "ใ‚ใ‚“ใพใ‚Š", "ใ„ใ„ใŸใ‚™ใ™", "ใ„ใŠใ‚“", "ใ„ใ‹ใ‚™ใ„", "ใ„ใ‹ใ‚™ใ", "ใ„ใใŠใ„", "ใ„ใใชใ‚Š", "ใ„ใใ‚‚ใฎ", "ใ„ใใ‚‹", "ใ„ใใ—ใ‚™", "ใ„ใใตใ‚™ใ‚“", "ใ„ใ‘ใฏใ‚™ใช", "ใ„ใ‘ใ‚“", "ใ„ใ“ใ†", "ใ„ใ“ใ", "ใ„ใ“ใค", "ใ„ใ•ใพใ—ใ„", "ใ„ใ•ใ‚“", "ใ„ใ—ใ", "ใ„ใ—ใ‚™ใ‚…ใ†", "ใ„ใ—ใ‚™ใ‚‡ใ†", "ใ„ใ—ใ‚™ใ‚ใ‚‹", "ใ„ใ™ใ‚™ใฟ", "ใ„ใ™ใ‚™ใ‚Œ", "ใ„ใ›ใ„", "ใ„ใ›ใˆใฒใ‚™", "ใ„ใ›ใ‹ใ„", "ใ„ใ›ใ", "ใ„ใ›ใ‚™ใ‚“", "ใ„ใใ†ใ‚ใ†", "ใ„ใใ‹ใ‚™ใ—ใ„", "ใ„ใŸใ‚™ใ„", "ใ„ใŸใ‚™ใ", "ใ„ใŸใ™ใ‚™ใ‚‰", "ใ„ใŸใฟ", "ใ„ใŸใ‚Šใ‚", "ใ„ใกใŠใ†", "ใ„ใกใ—ใ‚™", "ใ„ใกใจใ‚™", "ใ„ใกใฏใ‚™", "ใ„ใกใตใ‚™", "ใ„ใกใ‚Šใ‚…ใ†", "ใ„ใคใ‹", "ใ„ใฃใ—ใ‚…ใ‚“", "ใ„ใฃใ›ใ„", "ใ„ใฃใใ†", "ใ„ใฃใŸใ‚“", "ใ„ใฃใก", "ใ„ใฃใฆใ„", "ใ„ใฃใปใ‚šใ†", "ใ„ใฆใ•ใ‚™", "ใ„ใฆใ‚“", "ใ„ใจใ‚™ใ†", "ใ„ใจใ“", "ใ„ใชใ„", "ใ„ใชใ‹", "ใ„ใญใ‚€ใ‚Š", "ใ„ใฎใก", "ใ„ใฎใ‚‹", "ใ„ใฏใค", "ใ„ใฏใ‚™ใ‚‹", "ใ„ใฏใ‚“", "ใ„ใฒใ‚™ใ", "ใ„ใฒใ‚“", "ใ„ใตใ", "ใ„ใธใ‚“", "ใ„ใปใ†", "ใ„ใฟใ‚“", "ใ„ใ‚‚ใ†ใจ", "ใ„ใ‚‚ใŸใ‚Œ", "ใ„ใ‚‚ใ‚Š", "ใ„ใ‚„ใ‹ใ‚™ใ‚‹", "ใ„ใ‚„ใ™", "ใ„ใ‚ˆใ‹ใ‚“", "ใ„ใ‚ˆใ", "ใ„ใ‚‰ใ„", "ใ„ใ‚‰ใ™ใจ", "ใ„ใ‚Šใใ‚™ใก", "ใ„ใ‚Šใ‚‡ใ†", "ใ„ใ‚Œใ„", "ใ„ใ‚Œใ‚‚ใฎ", "ใ„ใ‚Œใ‚‹", "ใ„ใ‚ใˆใ‚“ใฒใ‚šใค", "ใ„ใ‚ใ„", "ใ„ใ‚ใ†", "ใ„ใ‚ใ‹ใ‚“", "ใ„ใ‚ใฏใ‚™", "ใ„ใ‚ใ‚†ใ‚‹", "ใ„ใ‚“ใ‘ใ‚™ใ‚“ใพใ‚", "ใ„ใ‚“ใ•ใค", "ใ„ใ‚“ใ—ใ‚‡ใ†", "ใ„ใ‚“ใ‚ˆใ†", "ใ†ใˆใ", "ใ†ใˆใ‚‹", "ใ†ใŠใ•ใ‚™", "ใ†ใ‹ใ‚™ใ„", "ใ†ใ‹ใตใ‚™", "ใ†ใ‹ใธใ‚™ใ‚‹", "ใ†ใใ‚", "ใ†ใใ‚‰ใ„ใช", "ใ†ใใ‚Œใ‚Œ", "ใ†ใ‘ใŸใพใ‚ใ‚‹", "ใ†ใ‘ใคใ‘", "ใ†ใ‘ใจใ‚‹", "ใ†ใ‘ใ‚‚ใค", "ใ†ใ‘ใ‚‹", "ใ†ใ“ใ‚™ใ‹ใ™", "ใ†ใ“ใ‚™ใ", "ใ†ใ“ใ‚“", "ใ†ใ•ใใ‚™", "ใ†ใ—ใชใ†", "ใ†ใ—ใ‚ใ‹ใ‚™ใฟ", "ใ†ใ™ใ„", "ใ†ใ™ใใ‚™", "ใ†ใ™ใใ‚™ใ‚‰ใ„", "ใ†ใ™ใ‚ใ‚‹", "ใ†ใ›ใค", "ใ†ใกใ‚ใ‚ใ›", "ใ†ใกใ‹ใ‚™ใ‚", "ใ†ใกใ", "ใ†ใกใ‚…ใ†", "ใ†ใฃใ‹ใ‚Š", "ใ†ใคใใ—ใ„", "ใ†ใฃใŸใˆใ‚‹", "ใ†ใคใ‚‹", "ใ†ใจใ‚™ใ‚“", "ใ†ใชใใ‚™", "ใ†ใชใ—ใ‚™", "ใ†ใชใ™ใ‚™ใ", "ใ†ใชใ‚‹", "ใ†ใญใ‚‹", "ใ†ใฎใ†", "ใ†ใตใ‚™ใ‘ใ‚™", "ใ†ใตใ‚™ใ“ใ‚™ใˆ", "ใ†ใพใ‚Œใ‚‹", "ใ†ใ‚ใ‚‹", "ใ†ใ‚‚ใ†", "ใ†ใ‚„ใพใ†", "ใ†ใ‚ˆใ", "ใ†ใ‚‰ใ‹ใ‚™ใˆใ™", "ใ†ใ‚‰ใใ‚™ใก", "ใ†ใ‚‰ใชใ„", "ใ†ใ‚Šใ‚ใ‘ใ‚™", "ใ†ใ‚Šใใ‚Œ", "ใ†ใ‚‹ใ•ใ„", "ใ†ใ‚Œใ—ใ„", "ใ†ใ‚Œใ‚†ใ", "ใ†ใ‚Œใ‚‹", "ใ†ใ‚ใ“", "ใ†ใ‚ใ", "ใ†ใ‚ใ•", "ใ†ใ‚“ใ“ใ†", "ใ†ใ‚“ใกใ‚“", "ใ†ใ‚“ใฆใ‚“", "ใ†ใ‚“ใจใ‚™ใ†", "ใˆใ„ใˆใ‚“", "ใˆใ„ใ‹ใ‚™", "ใˆใ„ใใ‚‡ใ†", "ใˆใ„ใ“ใ‚™", "ใˆใ„ใ›ใ„", "ใˆใ„ใตใ‚™ใ‚“", "ใˆใ„ใ‚ˆใ†", "ใˆใ„ใ‚", "ใˆใŠใ‚Š", "ใˆใ‹ใ‚™ใŠ", "ใˆใ‹ใ‚™ใ", "ใˆใใŸใ„", "ใˆใใ›ใ‚‹", "ใˆใ—ใ‚ƒใ", "ใˆใ™ใฆ", "ใˆใคใ‚‰ใ‚“", "ใˆใฎใใ‚™", "ใˆใปใ†ใพใ", "ใˆใปใ‚“", "ใˆใพใ", "ใˆใ‚‚ใ—ใ‚™", "ใˆใ‚‚ใฎ", "ใˆใ‚‰ใ„", "ใˆใ‚‰ใตใ‚™", "ใˆใ‚Šใ‚", "ใˆใ‚“ใˆใ‚“", "ใˆใ‚“ใ‹ใ„", "ใˆใ‚“ใใ‚™", "ใˆใ‚“ใ‘ใ‚™ใ", "ใˆใ‚“ใ—ใ‚…ใ†", "ใˆใ‚“ใ›ใ‚™ใค", "ใˆใ‚“ใใ", "ใˆใ‚“ใกใ‚‡ใ†", "ใˆใ‚“ใจใค", "ใŠใ„ใ‹ใ‘ใ‚‹", "ใŠใ„ใ“ใ™", "ใŠใ„ใ—ใ„", "ใŠใ„ใคใ", "ใŠใ†ใˆใ‚“", "ใŠใ†ใ•ใพ", "ใŠใ†ใ—ใ‚™", "ใŠใ†ใ›ใค", "ใŠใ†ใŸใ„", "ใŠใ†ใตใ", "ใŠใ†ใธใ‚™ใ„", "ใŠใ†ใ‚ˆใ†", "ใŠใˆใ‚‹", "ใŠใŠใ„", "ใŠใŠใ†", "ใŠใŠใจใ‚™ใŠใ‚Š", "ใŠใŠใ‚„", "ใŠใŠใ‚ˆใ", "ใŠใ‹ใˆใ‚Š", "ใŠใ‹ใ™ใ‚™", "ใŠใ‹ใ‚™ใ‚€", "ใŠใ‹ใ‚ใ‚Š", "ใŠใใ‚™ใชใ†", "ใŠใใ‚‹", "ใŠใใ•ใพ", "ใŠใใ—ใ‚™ใ‚‡ใ†", "ใŠใใ‚Šใ‹ใ‚™ใช", "ใŠใใ‚‹", "ใŠใใ‚Œใ‚‹", "ใŠใ“ใ™", "ใŠใ“ใชใ†", "ใŠใ“ใ‚‹", "ใŠใ•ใˆใ‚‹", "ใŠใ•ใชใ„", "ใŠใ•ใ‚ใ‚‹", "ใŠใ—ใ„ใ‚Œ", "ใŠใ—ใˆใ‚‹", "ใŠใ—ใ‚™ใใ‚™", "ใŠใ—ใ‚™ใ•ใ‚“", "ใŠใ—ใ‚ƒใ‚Œ", "ใŠใใ‚‰ใ", "ใŠใใ‚ใ‚‹", "ใŠใŸใ‹ใ‚™ใ„", "ใŠใŸใ", "ใŠใŸใ‚™ใ‚„ใ‹", "ใŠใกใคใ", "ใŠใฃใจ", "ใŠใคใ‚Š", "ใŠใฆใ‚™ใ‹ใ‘", "ใŠใจใ—ใ‚‚ใฎ", "ใŠใจใชใ—ใ„", "ใŠใจใ‚™ใ‚Š", "ใŠใจใ‚™ใ‚ใ‹ใ™", "ใŠใฏใ‚™ใ•ใ‚“", "ใŠใพใ„ใ‚Š", "ใŠใ‚ใฆใ‚™ใจใ†", "ใŠใ‚‚ใ„ใฆใ‚™", "ใŠใ‚‚ใ†", "ใŠใ‚‚ใŸใ„", "ใŠใ‚‚ใกใ‚ƒ", "ใŠใ‚„ใค", "ใŠใ‚„ใ‚†ใฒใ‚™", "ใŠใ‚ˆใปใ‚™ใ™", "ใŠใ‚‰ใ‚“ใŸใ‚™", "ใŠใ‚ใ™", "ใŠใ‚“ใ‹ใ‚™ใ", "ใŠใ‚“ใ‘ใ„", "ใŠใ‚“ใ—ใ‚ƒ", "ใŠใ‚“ใ›ใ‚“", "ใŠใ‚“ใŸใ‚™ใ‚“", "ใŠใ‚“ใกใ‚…ใ†", "ใŠใ‚“ใจใ‚™ใ‘ใ„", "ใ‹ใ‚ใค", "ใ‹ใ„ใ‹ใ‚™", "ใ‹ใ‚™ใ„ใ", "ใ‹ใ‚™ใ„ใ‘ใ‚“", "ใ‹ใ‚™ใ„ใ“ใ†", "ใ‹ใ„ใ•ใค", "ใ‹ใ„ใ—ใ‚ƒ", "ใ‹ใ„ใ™ใ„ใ‚ˆใ", "ใ‹ใ„ใ›ใ‚™ใ‚“", "ใ‹ใ„ใใ‚™ใ†ใจใ‚™", "ใ‹ใ„ใคใ†", "ใ‹ใ„ใฆใ‚“", "ใ‹ใ„ใจใ†", "ใ‹ใ„ใตใ", "ใ‹ใ‚™ใ„ใธใ", "ใ‹ใ„ใปใ†", "ใ‹ใ„ใ‚ˆใ†", "ใ‹ใ‚™ใ„ใ‚‰ใ„", "ใ‹ใ„ใ‚", "ใ‹ใˆใ‚‹", "ใ‹ใŠใ‚Š", "ใ‹ใ‹ใˆใ‚‹", "ใ‹ใ‹ใ‚™ใ", "ใ‹ใ‹ใ‚™ใ—", "ใ‹ใ‹ใ‚™ใฟ", "ใ‹ใใ“ใ‚™", "ใ‹ใใจใ", "ใ‹ใ•ใ‚™ใ‚‹", "ใ‹ใ‚™ใใ‚™ใ†", "ใ‹ใŸใ„", "ใ‹ใŸใก", "ใ‹ใ‚™ใกใ‚‡ใ†", "ใ‹ใ‚™ใฃใใ‚…ใ†", "ใ‹ใ‚™ใฃใ“ใ†", "ใ‹ใ‚™ใฃใ•ใ‚“", "ใ‹ใ‚™ใฃใ—ใ‚‡ใ†", "ใ‹ใชใ•ใ‚™ใ‚ใ—", "ใ‹ใฎใ†", "ใ‹ใ‚™ใฏใ", "ใ‹ใตใ‚™ใ‹", "ใ‹ใปใ†", "ใ‹ใปใ“ใ‚™", "ใ‹ใพใ†", "ใ‹ใพใปใ‚™ใ“", "ใ‹ใ‚ใ‚ŒใŠใ‚“", "ใ‹ใ‚†ใ„", "ใ‹ใ‚ˆใ†ใฒใ‚™", "ใ‹ใ‚‰ใ„", "ใ‹ใ‚‹ใ„", "ใ‹ใ‚ใ†", "ใ‹ใ‚ใ", "ใ‹ใ‚ใ‚‰", "ใ‹ใ‚™ใ‚“ใ‹", "ใ‹ใ‚“ใ‘ใ„", "ใ‹ใ‚“ใ“ใ†", "ใ‹ใ‚“ใ—ใ‚ƒ", "ใ‹ใ‚“ใใ†", "ใ‹ใ‚“ใŸใ‚“", "ใ‹ใ‚“ใก", "ใ‹ใ‚™ใ‚“ใฏใ‚™ใ‚‹", "ใใ‚ใ„", "ใใ‚ใค", "ใใ„ใ‚", "ใใ‚™ใ„ใ‚“", "ใใ†ใ„", "ใใ†ใ‚“", "ใใˆใ‚‹", "ใใŠใ†", "ใใŠใ", "ใใŠใก", "ใใŠใ‚“", "ใใ‹ใ„", "ใใ‹ใ", "ใใ‹ใ‚“ใ—ใ‚ƒ", "ใใใฆ", "ใใใฏใ‚™ใ‚Š", "ใใใ‚‰ใ‘ใ‚™", "ใใ‘ใ‚“ใ›ใ„", "ใใ“ใ†", "ใใ“ใˆใ‚‹", "ใใ“ใ", "ใใ•ใ„", "ใใ•ใ", "ใใ•ใพ", "ใใ•ใ‚‰ใใ‚™", "ใใ‚™ใ—ใ‚™ใ‹ใ‹ใ‚™ใ", "ใใ‚™ใ—ใ", "ใใ‚™ใ—ใ‚™ใŸใ„ใ‘ใ‚“", "ใใ‚™ใ—ใ‚™ใซใฃใฆใ„", "ใใ‚™ใ—ใ‚™ใ‚…ใคใ—ใ‚ƒ", "ใใ™ใ†", "ใใ›ใ„", "ใใ›ใ", "ใใ›ใค", "ใใใ†", "ใใใ‚™ใ", "ใใใ‚™ใ‚“", "ใใŸใˆใ‚‹", "ใใกใ‚‡ใ†", "ใใคใˆใ‚“", "ใใ‚™ใฃใกใ‚Š", "ใใคใคใ", "ใใคใญ", "ใใฆใ„", "ใใจใ‚™ใ†", "ใใจใ‚™ใ", "ใใชใ„", "ใใชใ‹ใ‚™", "ใใชใ“", "ใใฌใ“ใ‚™ใ—", "ใใญใ‚“", "ใใฎใ†", "ใใฎใ—ใŸ", "ใใฏใ", "ใใฒใ‚™ใ—ใ„", "ใใฒใ‚“", "ใใตใ", "ใใตใ‚™ใ‚“", "ใใปใ‚™ใ†", "ใใปใ‚“", "ใใพใ‚‹", "ใใฟใค", "ใใ‚€ใ™ใ‚™ใ‹ใ—ใ„", "ใใ‚ใ‚‹", "ใใ‚‚ใŸใ‚™ใ‚ใ—", "ใใ‚‚ใก", "ใใ‚‚ใฎ", "ใใ‚ƒใ", "ใใ‚„ใ", "ใใ‚™ใ‚…ใ†ใซใ", "ใใ‚ˆใ†", "ใใ‚‡ใ†ใ‚Šใ‚…ใ†", "ใใ‚‰ใ„", "ใใ‚‰ใ", "ใใ‚Šใ‚“", "ใใ‚Œใ„", "ใใ‚Œใค", "ใใ‚ใ", "ใใ‚™ใ‚ใ‚“", "ใใ‚ใ‚ใ‚‹", "ใใ‚™ใ‚“ใ„ใ‚", "ใใ‚“ใ‹ใใ—ใ‚™", "ใใ‚“ใ—ใ‚™ใ‚‡", "ใใ‚“ใ‚ˆใ†ใฒใ‚™", "ใใ‚™ใ‚ใ„", "ใใ„ใ™ใ‚™", "ใใ†ใ‹ใ‚“", "ใใ†ใ", "ใใ†ใใ‚™ใ‚“", "ใใ†ใ“ใ†", "ใใ‚™ใ†ใ›ใ„", "ใใ†ใใ†", "ใใ‚™ใ†ใŸใ‚‰", "ใใ†ใตใ", "ใใ†ใปใ‚™", "ใใ‹ใ‚“", "ใใใ‚‡ใ†", "ใใ‘ใ‚™ใ‚“", "ใใ‚™ใ“ใ†", "ใใ•ใ„", "ใใ•ใ", "ใใ•ใฏใ‚™ใช", "ใใ•ใ‚‹", "ใใ—ใ‚ƒใฟ", "ใใ—ใ‚‡ใ†", "ใใ™ใฎใ", "ใใ™ใ‚Šใ‚†ใฒใ‚™", "ใใ›ใ‘ใ‚™", "ใใ›ใ‚“", "ใใ‚™ใŸใ„ใฆใ", "ใใŸใ‚™ใ•ใ‚‹", "ใใŸใฒใ‚™ใ‚Œใ‚‹", "ใใกใ“ใฟ", "ใใกใ•ใ", "ใใคใ—ใŸ", "ใใ‚™ใฃใ™ใ‚Š", "ใใคใ‚ใใ‚™", "ใใจใ†ใฆใ‚“", "ใใจใ‚™ใ", "ใใชใ‚“", "ใใญใใญ", "ใใฎใ†", "ใใตใ†", "ใใฟใ‚ใ‚ใ›", "ใใฟใŸใฆใ‚‹", "ใใ‚ใ‚‹", "ใใ‚„ใใ—ใ‚‡", "ใใ‚‰ใ™", "ใใ‚‰ใธใ‚™ใ‚‹", "ใใ‚‹ใพ", "ใใ‚Œใ‚‹", "ใใ‚ใ†", "ใใ‚ใ—ใ„", "ใใ‚™ใ‚“ใ‹ใ‚“", "ใใ‚™ใ‚“ใ—ใ‚‡ใ", "ใใ‚™ใ‚“ใŸใ„", "ใใ‚™ใ‚“ใฆ", "ใ‘ใ‚ใช", "ใ‘ใ„ใ‹ใ", "ใ‘ใ„ใ‘ใ‚“", "ใ‘ใ„ใ“", "ใ‘ใ„ใ•ใค", "ใ‘ใ‚™ใ„ใ—ใ‚™ใ‚…ใค", "ใ‘ใ„ใŸใ„", "ใ‘ใ‚™ใ„ใฎใ†ใ—ใ‚™ใ‚“", "ใ‘ใ„ใ‚Œใ", "ใ‘ใ„ใ‚", "ใ‘ใŠใจใ™", "ใ‘ใŠใ‚Šใ‚‚ใฎ", "ใ‘ใ‚™ใใ‹", "ใ‘ใ‚™ใใ‘ใ‚™ใ‚“", "ใ‘ใ‚™ใใŸใ‚™ใ‚“", "ใ‘ใ‚™ใใกใ‚“", "ใ‘ใ‚™ใใจใค", "ใ‘ใ‚™ใใฏ", "ใ‘ใ‚™ใใ‚„ใ", "ใ‘ใ‚™ใ“ใ†", "ใ‘ใ‚™ใ“ใใ—ใ‚™ใ‚‡ใ†", "ใ‘ใ‚™ใ•ใ‚™ใ„", "ใ‘ใ•ใ", "ใ‘ใ‚™ใ•ใ‚™ใ‚“", "ใ‘ใ—ใ", "ใ‘ใ—ใ“ใ‚™ใ‚€", "ใ‘ใ—ใ‚‡ใ†", "ใ‘ใ‚™ใ™ใจ", "ใ‘ใŸใฏใ‚™", "ใ‘ใกใ‚ƒใฃใตใ‚š", "ใ‘ใกใ‚‰ใ™", "ใ‘ใคใ‚ใค", "ใ‘ใคใ„", "ใ‘ใคใˆใ", "ใ‘ใฃใ“ใ‚“", "ใ‘ใคใ—ใ‚™ใ‚‡", "ใ‘ใฃใ›ใ", "ใ‘ใฃใฆใ„", "ใ‘ใคใพใค", "ใ‘ใ‚™ใคใ‚ˆใ†ใฒใ‚™", "ใ‘ใ‚™ใคใ‚Œใ„", "ใ‘ใคใ‚ใ‚“", "ใ‘ใ‚™ใจใ‚™ใ", "ใ‘ใจใฏใ‚™ใ™", "ใ‘ใจใ‚‹", "ใ‘ใชใ‘ใ‚™", "ใ‘ใชใ™", "ใ‘ใชใฟ", "ใ‘ใฌใ", "ใ‘ใ‚™ใญใค", "ใ‘ใญใ‚“", "ใ‘ใฏใ„", "ใ‘ใ‚™ใฒใ‚“", "ใ‘ใตใ‚™ใ‹ใ„", "ใ‘ใ‚™ใปใ‚™ใ", "ใ‘ใพใ‚Š", "ใ‘ใฟใ‹ใ‚‹", "ใ‘ใ‚€ใ—", "ใ‘ใ‚€ใ‚Š", "ใ‘ใ‚‚ใฎ", "ใ‘ใ‚‰ใ„", "ใ‘ใ‚ใ‘ใ‚", "ใ‘ใ‚ใ—ใ„", "ใ‘ใ‚“ใ„", "ใ‘ใ‚“ใˆใค", "ใ‘ใ‚“ใŠ", "ใ‘ใ‚“ใ‹", "ใ‘ใ‚™ใ‚“ใ", "ใ‘ใ‚“ใ‘ใ‚™ใ‚“", "ใ‘ใ‚“ใ“ใ†", "ใ‘ใ‚“ใ•ใ", "ใ‘ใ‚“ใ—ใ‚…ใ†", "ใ‘ใ‚“ใ™ใ†", "ใ‘ใ‚™ใ‚“ใใ†", "ใ‘ใ‚“ใกใ", "ใ‘ใ‚“ใฆใ„", "ใ‘ใ‚“ใจใ†", "ใ‘ใ‚“ใชใ„", "ใ‘ใ‚“ใซใ‚“", "ใ‘ใ‚™ใ‚“ใตใ‚™ใค", "ใ‘ใ‚“ใพ", "ใ‘ใ‚“ใฟใ‚“", "ใ‘ใ‚“ใ‚ใ„", "ใ‘ใ‚“ใ‚‰ใ‚“", "ใ‘ใ‚“ใ‚Š", "ใ“ใ‚ใใพ", "ใ“ใ„ใฌ", "ใ“ใ„ใฒใ‚™ใจ", "ใ“ใ‚™ใ†ใ„", "ใ“ใ†ใˆใ‚“", "ใ“ใ†ใŠใ‚“", "ใ“ใ†ใ‹ใ‚“", "ใ“ใ‚™ใ†ใใ‚…ใ†", "ใ“ใ‚™ใ†ใ‘ใ„", "ใ“ใ†ใ“ใ†", "ใ“ใ†ใ•ใ„", "ใ“ใ†ใ—ใ‚™", "ใ“ใ†ใ™ใ„", "ใ“ใ‚™ใ†ใ›ใ„", "ใ“ใ†ใใ", "ใ“ใ†ใŸใ„", "ใ“ใ†ใกใ‚ƒ", "ใ“ใ†ใคใ†", "ใ“ใ†ใฆใ„", "ใ“ใ†ใจใ‚™ใ†", "ใ“ใ†ใชใ„", "ใ“ใ†ใฏใ„", "ใ“ใ‚™ใ†ใปใ†", "ใ“ใ‚™ใ†ใพใ‚“", "ใ“ใ†ใ‚‚ใ", "ใ“ใ†ใ‚Šใค", "ใ“ใˆใ‚‹", "ใ“ใŠใ‚Š", "ใ“ใ‚™ใ‹ใ„", "ใ“ใ‚™ใ‹ใ‚™ใค", "ใ“ใ‚™ใ‹ใ‚“", "ใ“ใใ“ใ‚™", "ใ“ใใ•ใ„", "ใ“ใใจใ†", "ใ“ใใชใ„", "ใ“ใใฏใ", "ใ“ใใ‚™ใพ", "ใ“ใ‘ใ„", "ใ“ใ‘ใ‚‹", "ใ“ใ“ใฎใ‹", "ใ“ใ“ใ‚", "ใ“ใ•ใ‚", "ใ“ใ—ใค", "ใ“ใ™ใ†", "ใ“ใ›ใ„", "ใ“ใ›ใ", "ใ“ใ›ใ‚™ใ‚“", "ใ“ใใŸใ‚™ใฆ", "ใ“ใŸใ„", "ใ“ใŸใˆใ‚‹", "ใ“ใŸใค", "ใ“ใกใ‚‡ใ†", "ใ“ใฃใ‹", "ใ“ใคใ“ใค", "ใ“ใคใฏใ‚™ใ‚“", "ใ“ใคใตใ‚™", "ใ“ใฆใ„", "ใ“ใฆใ‚“", "ใ“ใจใ‹ใ‚™ใ‚‰", "ใ“ใจใ—", "ใ“ใจใฏใ‚™", "ใ“ใจใ‚Š", "ใ“ใชใ“ใ‚™ใช", "ใ“ใญใ“ใญ", "ใ“ใฎใพใพ", "ใ“ใฎใฟ", "ใ“ใฎใ‚ˆ", "ใ“ใ‚™ใฏใ‚“", "ใ“ใฒใคใ—ใ‚™", "ใ“ใตใ†", "ใ“ใตใ‚“", "ใ“ใปใ‚™ใ‚Œใ‚‹", "ใ“ใ‚™ใพใ‚ใตใ‚™ใ‚‰", "ใ“ใพใ‹ใ„", "ใ“ใ‚™ใพใ™ใ‚Š", "ใ“ใพใคใช", "ใ“ใพใ‚‹", "ใ“ใ‚€ใใ‚™ใ“", "ใ“ใ‚‚ใ—ใ‚™", "ใ“ใ‚‚ใก", "ใ“ใ‚‚ใฎ", "ใ“ใ‚‚ใ‚“", "ใ“ใ‚„ใ", "ใ“ใ‚„ใพ", "ใ“ใ‚†ใ†", "ใ“ใ‚†ใฒใ‚™", "ใ“ใ‚ˆใ„", "ใ“ใ‚ˆใ†", "ใ“ใ‚Šใ‚‹", "ใ“ใ‚Œใใ—ใ‚‡ใ‚“", "ใ“ใ‚ใฃใ‘", "ใ“ใ‚ใ‚‚ใฆ", "ใ“ใ‚ใ‚Œใ‚‹", "ใ“ใ‚“ใ„ใ‚“", "ใ“ใ‚“ใ‹ใ„", "ใ“ใ‚“ใ", "ใ“ใ‚“ใ—ใ‚…ใ†", "ใ“ใ‚“ใ™ใ„", "ใ“ใ‚“ใŸใ‚™ใฆ", "ใ“ใ‚“ใจใ‚“", "ใ“ใ‚“ใชใ‚“", "ใ“ใ‚“ใฒใ‚™ใซ", "ใ“ใ‚“ใปใ‚šใ‚“", "ใ“ใ‚“ใพใ‘", "ใ“ใ‚“ใ‚„", "ใ“ใ‚“ใ‚Œใ„", "ใ“ใ‚“ใ‚ใ", "ใ•ใ‚™ใ„ใˆใ", "ใ•ใ„ใ‹ใ„", "ใ•ใ„ใใ‚“", "ใ•ใ‚™ใ„ใ‘ใ‚™ใ‚“", "ใ•ใ‚™ใ„ใ“", "ใ•ใ„ใ—ใ‚‡", "ใ•ใ„ใ›ใ„", "ใ•ใ‚™ใ„ใŸใ", "ใ•ใ‚™ใ„ใกใ‚…ใ†", "ใ•ใ„ใฆใ", "ใ•ใ‚™ใ„ใ‚Šใ‚‡ใ†", "ใ•ใ†ใช", "ใ•ใ‹ใ„ใ—", "ใ•ใ‹ใ‚™ใ™", "ใ•ใ‹ใช", "ใ•ใ‹ใฟใก", "ใ•ใ‹ใ‚™ใ‚‹", "ใ•ใใ‚™ใ‚‡ใ†", "ใ•ใใ—", "ใ•ใใฒใ‚“", "ใ•ใใ‚‰", "ใ•ใ“ใ", "ใ•ใ“ใค", "ใ•ใ™ใ‚™ใ‹ใ‚‹", "ใ•ใ‚™ใ›ใ", "ใ•ใŸใ‚“", "ใ•ใคใˆใ„", "ใ•ใ‚™ใคใŠใ‚“", "ใ•ใ‚™ใฃใ‹", "ใ•ใ‚™ใคใ‹ใ‚™ใ", "ใ•ใฃใใ‚‡ใ", "ใ•ใ‚™ใฃใ—", "ใ•ใคใ—ใ‚™ใ‚“", "ใ•ใ‚™ใฃใใ†", "ใ•ใคใŸใฏใ‚™", "ใ•ใคใพใ„ใ‚‚", "ใ•ใฆใ„", "ใ•ใจใ„ใ‚‚", "ใ•ใจใ†", "ใ•ใจใŠใ‚„", "ใ•ใจใ—", "ใ•ใจใ‚‹", "ใ•ใฎใ†", "ใ•ใฏใ‚™ใ", "ใ•ใฒใ‚™ใ—ใ„", "ใ•ใธใ‚™ใค", "ใ•ใปใ†", "ใ•ใปใจใ‚™", "ใ•ใพใ™", "ใ•ใฟใ—ใ„", "ใ•ใฟใŸใ‚™ใ‚Œ", "ใ•ใ‚€ใ‘", "ใ•ใ‚ใ‚‹", "ใ•ใ‚„ใˆใ‚“ใจใ‚™ใ†", "ใ•ใ‚†ใ†", "ใ•ใ‚ˆใ†", "ใ•ใ‚ˆใ", "ใ•ใ‚‰ใŸใ‚™", "ใ•ใ‚™ใ‚‹ใใฏใ‚™", "ใ•ใ‚ใ‚„ใ‹", "ใ•ใ‚ใ‚‹", "ใ•ใ‚“ใ„ใ‚“", "ใ•ใ‚“ใ‹", "ใ•ใ‚“ใใ‚ƒใ", "ใ•ใ‚“ใ“ใ†", "ใ•ใ‚“ใ•ใ„", "ใ•ใ‚™ใ‚“ใ—ใ‚‡", "ใ•ใ‚“ใ™ใ†", "ใ•ใ‚“ใ›ใ„", "ใ•ใ‚“ใ", "ใ•ใ‚“ใก", "ใ•ใ‚“ใพ", "ใ•ใ‚“ใฟ", "ใ•ใ‚“ใ‚‰ใ‚“", "ใ—ใ‚ใ„", "ใ—ใ‚ใ‘ใ‚™", "ใ—ใ‚ใ•ใฃใฆ", "ใ—ใ‚ใ‚ใ›", "ใ—ใ„ใ", "ใ—ใ„ใ‚“", "ใ—ใ†ใก", "ใ—ใˆใ„", "ใ—ใŠใ‘", "ใ—ใ‹ใ„", "ใ—ใ‹ใ", "ใ—ใ‚™ใ‹ใ‚“", "ใ—ใ“ใ‚™ใจ", "ใ—ใ™ใ†", "ใ—ใ‚™ใŸใ‚™ใ„", "ใ—ใŸใ†ใ‘", "ใ—ใŸใใ‚™", "ใ—ใŸใฆ", "ใ—ใŸใฟ", "ใ—ใกใ‚‡ใ†", "ใ—ใกใ‚Šใ‚“", "ใ—ใฃใ‹ใ‚Š", "ใ—ใคใ—ใ‚™", "ใ—ใคใ‚‚ใ‚“", "ใ—ใฆใ„", "ใ—ใฆใ", "ใ—ใฆใค", "ใ—ใ‚™ใฆใ‚“", "ใ—ใ‚™ใจใ‚™ใ†", "ใ—ใชใใ‚™ใ‚Œ", "ใ—ใชใ‚‚ใฎ", "ใ—ใชใ‚“", "ใ—ใญใพ", "ใ—ใญใ‚“", "ใ—ใฎใใ‚™", "ใ—ใฎใตใ‚™", "ใ—ใฏใ„", "ใ—ใฏใ‚™ใ‹ใ‚Š", "ใ—ใฏใค", "ใ—ใฏใ‚‰ใ„", "ใ—ใฏใ‚“", "ใ—ใฒใ‚‡ใ†", "ใ—ใตใ", "ใ—ใ‚™ใตใ‚™ใ‚“", "ใ—ใธใ„", "ใ—ใปใ†", "ใ—ใปใ‚“", "ใ—ใพใ†", "ใ—ใพใ‚‹", "ใ—ใฟใ‚“", "ใ—ใ‚€ใ‘ใ‚‹", "ใ—ใ‚™ใ‚€ใ—ใ‚‡", "ใ—ใ‚ใ„", "ใ—ใ‚ใ‚‹", "ใ—ใ‚‚ใ‚“", "ใ—ใ‚ƒใ„ใ‚“", "ใ—ใ‚ƒใ†ใ‚“", "ใ—ใ‚ƒใŠใ‚“", "ใ—ใ‚™ใ‚ƒใ‹ใ‚™ใ„ใ‚‚", "ใ—ใ‚„ใใ—ใ‚‡", "ใ—ใ‚ƒใใปใ†", "ใ—ใ‚ƒใ‘ใ‚“", "ใ—ใ‚ƒใ“", "ใ—ใ‚ƒใ•ใ‚™ใ„", "ใ—ใ‚ƒใ—ใ‚“", "ใ—ใ‚ƒใ›ใ‚“", "ใ—ใ‚ƒใใ†", "ใ—ใ‚ƒใŸใ„", "ใ—ใ‚ƒใกใ‚‡ใ†", "ใ—ใ‚ƒใฃใใ‚“", "ใ—ใ‚™ใ‚ƒใพ", "ใ—ใ‚ƒใ‚Šใ‚“", "ใ—ใ‚ƒใ‚Œใ„", "ใ—ใ‚™ใ‚†ใ†", "ใ—ใ‚™ใ‚…ใ†ใ—ใ‚‡", "ใ—ใ‚…ใใฏใ", "ใ—ใ‚™ใ‚…ใ—ใ‚“", "ใ—ใ‚…ใฃใ›ใ", "ใ—ใ‚…ใฟ", "ใ—ใ‚…ใ‚‰ใฏใ‚™", "ใ—ใ‚™ใ‚…ใ‚“ใฏใ‚™ใ‚“", "ใ—ใ‚‡ใ†ใ‹ใ„", "ใ—ใ‚‡ใใŸใ", "ใ—ใ‚‡ใฃใ‘ใ‚“", "ใ—ใ‚‡ใจใ‚™ใ†", "ใ—ใ‚‡ใ‚‚ใค", "ใ—ใ‚‰ใ›ใ‚‹", "ใ—ใ‚‰ใธใ‚™ใ‚‹", "ใ—ใ‚“ใ‹", "ใ—ใ‚“ใ“ใ†", "ใ—ใ‚™ใ‚“ใ—ใ‚™ใ‚ƒ", "ใ—ใ‚“ใ›ใ„ใ—ใ‚™", "ใ—ใ‚“ใกใ", "ใ—ใ‚“ใ‚Šใ‚“", "ใ™ใ‚ใ‘ใ‚™", "ใ™ใ‚ใ—", "ใ™ใ‚ใช", "ใ™ใ‚™ใ‚ใ‚“", "ใ™ใ„ใˆใ„", "ใ™ใ„ใ‹", "ใ™ใ„ใจใ†", "ใ™ใ‚™ใ„ใตใ‚™ใ‚“", "ใ™ใ„ใ‚ˆใ†ใฒใ‚™", "ใ™ใ†ใ‹ใ‚™ใ", "ใ™ใ†ใ—ใ‚™ใค", "ใ™ใ†ใ›ใ‚“", "ใ™ใŠใจใ‚™ใ‚Š", "ใ™ใใพ", "ใ™ใใ†", "ใ™ใใชใ„", "ใ™ใ‘ใ‚‹", "ใ™ใ“ใ‚™ใ„", "ใ™ใ“ใ—", "ใ™ใ‚™ใ•ใ‚“", "ใ™ใ™ใ‚™ใ—ใ„", "ใ™ใ™ใ‚€", "ใ™ใ™ใ‚ใ‚‹", "ใ™ใฃใ‹ใ‚Š", "ใ™ใ‚™ใฃใ—ใ‚Š", "ใ™ใ‚™ใฃใจ", "ใ™ใฆใ", "ใ™ใฆใ‚‹", "ใ™ใญใ‚‹", "ใ™ใฎใ“", "ใ™ใฏใŸใ‚™", "ใ™ใฏใ‚™ใ‚‰ใ—ใ„", "ใ™ใ‚™ใฒใ‚‡ใ†", "ใ™ใ‚™ใตใ‚™ใฌใ‚Œ", "ใ™ใตใ‚™ใ‚Š", "ใ™ใตใ‚Œ", "ใ™ใธใ‚™ใฆ", "ใ™ใธใ‚™ใ‚‹", "ใ™ใ‚™ใปใ†", "ใ™ใปใ‚™ใ‚“", "ใ™ใพใ„", "ใ™ใ‚ใ—", "ใ™ใ‚‚ใ†", "ใ™ใ‚„ใ", "ใ™ใ‚‰ใ™ใ‚‰", "ใ™ใ‚‹ใ‚", "ใ™ใ‚Œใกใ‹ใ‚™ใ†", "ใ™ใ‚ใฃใจ", "ใ™ใ‚ใ‚‹", "ใ™ใ‚“ใ›ใ‚™ใ‚“", "ใ™ใ‚“ใปใ‚šใ†", "ใ›ใ‚ใตใ‚™ใ‚‰", "ใ›ใ„ใ‹ใค", "ใ›ใ„ใ‘ใ‚™ใ‚“", "ใ›ใ„ใ—ใ‚™", "ใ›ใ„ใ‚ˆใ†", "ใ›ใŠใ†", "ใ›ใ‹ใ„ใ‹ใ‚“", "ใ›ใใซใ‚“", "ใ›ใใ‚€", "ใ›ใใ‚†", "ใ›ใใ‚‰ใ‚“ใ†ใ‚“", "ใ›ใ‘ใ‚“", "ใ›ใ“ใ†", "ใ›ใ™ใ—ใ‚™", "ใ›ใŸใ„", "ใ›ใŸใ‘", "ใ›ใฃใ‹ใ", "ใ›ใฃใใ‚ƒใ", "ใ›ใ‚™ใฃใ", "ใ›ใฃใ‘ใ‚“", "ใ›ใฃใ“ใค", "ใ›ใฃใ•ใŸใใพ", "ใ›ใคใใ‚™ใ", "ใ›ใคใŸใ‚™ใ‚“", "ใ›ใคใฆใ‚™ใ‚“", "ใ›ใฃใฏใ‚šใ‚“", "ใ›ใคใฒใ‚™", "ใ›ใคใตใ‚™ใ‚“", "ใ›ใคใ‚ใ„", "ใ›ใคใ‚Šใค", "ใ›ใชใ‹", "ใ›ใฎใฒใ‚™", "ใ›ใฏใฏใ‚™", "ใ›ใฒใ‚™ใ‚", "ใ›ใปใ‚™ใญ", "ใ›ใพใ„", "ใ›ใพใ‚‹", "ใ›ใ‚ใ‚‹", "ใ›ใ‚‚ใŸใ‚Œ", "ใ›ใ‚Šใต", "ใ›ใ‚™ใ‚“ใ‚ใ", "ใ›ใ‚“ใ„", "ใ›ใ‚“ใˆใ„", "ใ›ใ‚“ใ‹", "ใ›ใ‚“ใใ‚‡", "ใ›ใ‚“ใ", "ใ›ใ‚“ใ‘ใ‚™ใ‚“", "ใ›ใ‚™ใ‚“ใ“ใ‚™", "ใ›ใ‚“ใ•ใ„", "ใ›ใ‚“ใ—ใ‚…", "ใ›ใ‚“ใ™ใ„", "ใ›ใ‚“ใ›ใ„", "ใ›ใ‚“ใใ‚™", "ใ›ใ‚“ใŸใ", "ใ›ใ‚“ใกใ‚‡ใ†", "ใ›ใ‚“ใฆใ„", "ใ›ใ‚“ใจใ†", "ใ›ใ‚“ใฌใ", "ใ›ใ‚“ใญใ‚“", "ใ›ใ‚“ใฏใ‚šใ„", "ใ›ใ‚™ใ‚“ใตใ‚™", "ใ›ใ‚™ใ‚“ใปใ‚šใ†", "ใ›ใ‚“ใ‚€", "ใ›ใ‚“ใ‚ใ‚“ใ—ใ‚™ใ‚‡", "ใ›ใ‚“ใ‚‚ใ‚“", "ใ›ใ‚“ใ‚„ใ", "ใ›ใ‚“ใ‚†ใ†", "ใ›ใ‚“ใ‚ˆใ†", "ใ›ใ‚™ใ‚“ใ‚‰", "ใ›ใ‚™ใ‚“ใ‚Šใ‚ƒใ", "ใ›ใ‚“ใ‚Œใ„", "ใ›ใ‚“ใ‚", "ใใ‚ใ", "ใใ„ใจใ‘ใ‚™ใ‚‹", "ใใ„ใญ", "ใใ†ใ‹ใ‚™ใ‚“ใใ‚‡ใ†", "ใใ†ใ", "ใใ†ใ“ใ‚™", "ใใ†ใ—ใ‚“", "ใใ†ใŸใ‚™ใ‚“", "ใใ†ใชใ‚“", "ใใ†ใฒใ‚™", "ใใ†ใ‚ใ‚“", "ใใ†ใ‚Š", "ใใˆใ‚‚ใฎ", "ใใˆใ‚“", "ใใ‹ใ‚™ใ„", "ใใ‘ใ‚™ใ", "ใใ“ใ†", "ใใ“ใใ“", "ใใ•ใ‚™ใ„", "ใใ—ใช", "ใใ›ใ„", "ใใ›ใ‚“", "ใใใใ‚™", "ใใŸใ‚™ใฆใ‚‹", "ใใคใ†", "ใใคใˆใ‚“", "ใใฃใ‹ใ‚“", "ใใคใใ‚™ใ‚‡ใ†", "ใใฃใ‘ใค", "ใใฃใ“ใ†", "ใใฃใ›ใ‚“", "ใใฃใจ", "ใใจใ‹ใ‚™ใ‚", "ใใจใคใ‚™ใ‚‰", "ใใชใˆใ‚‹", "ใใชใŸ", "ใใตใปใ‚™", "ใใปใ‚™ใ", "ใใปใ‚™ใ‚", "ใใพใค", "ใใพใ‚‹", "ใใ‚€ใ", "ใใ‚€ใ‚Šใˆ", "ใใ‚ใ‚‹", "ใใ‚‚ใใ‚‚", "ใใ‚ˆใ‹ใ›ใ‚™", "ใใ‚‰ใพใ‚", "ใใ‚ใ†", "ใใ‚“ใ‹ใ„", "ใใ‚“ใ‘ใ„", "ใใ‚“ใ•ใ‚™ใ„", "ใใ‚“ใ—ใค", "ใใ‚“ใใ‚™ใ", "ใใ‚“ใกใ‚‡ใ†", "ใใ‚™ใ‚“ใฒใ‚™", "ใใ‚™ใ‚“ใตใ‚™ใ‚“", "ใใ‚“ใฟใ‚“", "ใŸใ‚ใ„", "ใŸใ„ใ„ใ‚“", "ใŸใ„ใ†ใ‚“", "ใŸใ„ใˆใ", "ใŸใ„ใŠใ†", "ใŸใ‚™ใ„ใ‹ใ‚™ใ", "ใŸใ„ใ", "ใŸใ„ใใ‚™ใ†", "ใŸใ„ใ‘ใ‚“", "ใŸใ„ใ“", "ใŸใ„ใ•ใ‚™ใ„", "ใŸใ‚™ใ„ใ—ใ‚™ใ‚‡ใ†ใตใ‚™", "ใŸใ‚™ใ„ใ™ใ", "ใŸใ„ใ›ใค", "ใŸใ„ใใ†", "ใŸใ‚™ใ„ใŸใ„", "ใŸใ„ใกใ‚‡ใ†", "ใŸใ„ใฆใ„", "ใŸใ‚™ใ„ใจใ‚™ใ“ใ‚", "ใŸใ„ใชใ„", "ใŸใ„ใญใค", "ใŸใ„ใฎใ†", "ใŸใ„ใฏใ‚“", "ใŸใ‚™ใ„ใฒใ‚‡ใ†", "ใŸใ„ใตใ†", "ใŸใ„ใธใ‚“", "ใŸใ„ใป", "ใŸใ„ใพใคใฏใ‚™ใช", "ใŸใ„ใฟใ‚“ใใ‚™", "ใŸใ„ใ‚€", "ใŸใ„ใ‚ใ‚“", "ใŸใ„ใ‚„ใ", "ใŸใ„ใ‚ˆใ†", "ใŸใ„ใ‚‰", "ใŸใ„ใ‚Šใ‚‡ใ", "ใŸใ„ใ‚‹", "ใŸใ„ใ‚ใ‚“", "ใŸใ†ใˆ", "ใŸใˆใ‚‹", "ใŸใŠใ™", "ใŸใŠใ‚‹", "ใŸใŠใ‚Œใ‚‹", "ใŸใ‹ใ„", "ใŸใ‹ใญ", "ใŸใใฒใ‚™", "ใŸใใ•ใ‚“", "ใŸใ“ใ", "ใŸใ“ใ‚„ใ", "ใŸใ•ใ„", "ใŸใ—ใ•ใ‚™ใ‚“", "ใŸใ‚™ใ—ใ‚™ใ‚ƒใ‚Œ", "ใŸใ™ใ‘ใ‚‹", "ใŸใ™ใ‚™ใ•ใ‚ใ‚‹", "ใŸใใ‹ใ‚™ใ‚Œ", "ใŸใŸใ‹ใ†", "ใŸใŸใ", "ใŸใŸใ‚™ใ—ใ„", "ใŸใŸใฟ", "ใŸใกใฏใ‚™ใช", "ใŸใ‚™ใฃใ‹ใ„", "ใŸใ‚™ใฃใใ‚ƒใ", "ใŸใ‚™ใฃใ“", "ใŸใ‚™ใฃใ—ใ‚…ใค", "ใŸใ‚™ใฃใŸใ„", "ใŸใฆใ‚‹", "ใŸใจใˆใ‚‹", "ใŸใชใฏใ‚™ใŸ", "ใŸใซใ‚“", "ใŸใฌใ", "ใŸใฎใ—ใฟ", "ใŸใฏใค", "ใŸใตใ‚™ใ‚“", "ใŸใธใ‚™ใ‚‹", "ใŸใปใ‚™ใ†", "ใŸใพใ“ใ‚™", "ใŸใพใ‚‹", "ใŸใ‚™ใ‚€ใ‚‹", "ใŸใ‚ใ„ใ", "ใŸใ‚ใ™", "ใŸใ‚ใ‚‹", "ใŸใ‚‚ใค", "ใŸใ‚„ใ™ใ„", "ใŸใ‚ˆใ‚‹", "ใŸใ‚‰ใ™", "ใŸใ‚Šใใปใ‚“ใ‹ใ‚™ใ‚“", "ใŸใ‚Šใ‚‡ใ†", "ใŸใ‚Šใ‚‹", "ใŸใ‚‹ใจ", "ใŸใ‚Œใ‚‹", "ใŸใ‚Œใ‚“ใจ", "ใŸใ‚ใฃใจ", "ใŸใ‚ใ‚€ใ‚Œใ‚‹", "ใŸใ‚™ใ‚“ใ‚ใค", "ใŸใ‚“ใ„", "ใŸใ‚“ใŠใ‚“", "ใŸใ‚“ใ‹", "ใŸใ‚“ใ", "ใŸใ‚“ใ‘ใ‚“", "ใŸใ‚“ใ“ใ‚™", "ใŸใ‚“ใ•ใ‚“", "ใŸใ‚“ใ—ใ‚™ใ‚‡ใ†ใฒใ‚™", "ใŸใ‚™ใ‚“ใ›ใ„", "ใŸใ‚“ใใ", "ใŸใ‚“ใŸใ„", "ใŸใ‚™ใ‚“ใก", "ใŸใ‚“ใฆใ„", "ใŸใ‚“ใจใ†", "ใŸใ‚™ใ‚“ใช", "ใŸใ‚“ใซใ‚“", "ใŸใ‚™ใ‚“ใญใค", "ใŸใ‚“ใฎใ†", "ใŸใ‚“ใฒใ‚šใ‚“", "ใŸใ‚™ใ‚“ใปใ‚™ใ†", "ใŸใ‚“ใพใค", "ใŸใ‚“ใ‚ใ„", "ใŸใ‚™ใ‚“ใ‚Œใค", "ใŸใ‚™ใ‚“ใ‚", "ใŸใ‚™ใ‚“ใ‚", "ใกใ‚ใ„", "ใกใ‚ใ‚“", "ใกใ„ใ", "ใกใ„ใ•ใ„", "ใกใˆใ‚“", "ใกใ‹ใ„", "ใกใ‹ใ‚‰", "ใกใใ‚…ใ†", "ใกใใ‚“", "ใกใ‘ใ„ใ™ใ‚™", "ใกใ‘ใ‚“", "ใกใ“ใ", "ใกใ•ใ„", "ใกใ—ใ", "ใกใ—ใ‚Šใ‚‡ใ†", "ใกใ›ใ„", "ใกใใ†", "ใกใŸใ„", "ใกใŸใ‚“", "ใกใกใŠใ‚„", "ใกใคใ—ใ‚™ใ‚‡", "ใกใฆใ", "ใกใฆใ‚“", "ใกใฌใ", "ใกใฌใ‚Š", "ใกใฎใ†", "ใกใฒใ‚‡ใ†", "ใกใธใ„ใ›ใ‚“", "ใกใปใ†", "ใกใพใŸ", "ใกใฟใค", "ใกใฟใจใ‚™ใ‚", "ใกใ‚ใ„ใจใ‚™", "ใกใ‚ƒใ‚“ใ“ใชใธใ‚™", "ใกใ‚…ใ†ใ„", "ใกใ‚†ใ‚Šใ‚‡ใ", "ใกใ‚‡ใ†ใ—", "ใกใ‚‡ใ•ใใ‘ใ‚“", "ใกใ‚‰ใ—", "ใกใ‚‰ใฟ", "ใกใ‚Šใ‹ใ‚™ใฟ", "ใกใ‚Šใ‚‡ใ†", "ใกใ‚‹ใจใ‚™", "ใกใ‚ใ‚", "ใกใ‚“ใŸใ„", "ใกใ‚“ใ‚‚ใ", "ใคใ„ใ‹", "ใคใ„ใŸใก", "ใคใ†ใ‹", "ใคใ†ใ—ใ‚™ใ‚‡ใ†", "ใคใ†ใฏใ‚“", "ใคใ†ใ‚", "ใคใ‹ใ†", "ใคใ‹ใ‚Œใ‚‹", "ใคใใญ", "ใคใใ‚‹", "ใคใ‘ใญ", "ใคใ‘ใ‚‹", "ใคใ“ใ‚™ใ†", "ใคใŸใˆใ‚‹", "ใคใคใ‚™ใ", "ใคใคใ—ใ‚™", "ใคใคใ‚€", "ใคใจใ‚ใ‚‹", "ใคใชใ‹ใ‚™ใ‚‹", "ใคใชใฟ", "ใคใญใคใ‚™ใญ", "ใคใฎใ‚‹", "ใคใตใ‚™ใ™", "ใคใพใ‚‰ใชใ„", "ใคใพใ‚‹", "ใคใฟใ", "ใคใ‚ใŸใ„", "ใคใ‚‚ใ‚Š", "ใคใ‚‚ใ‚‹", "ใคใ‚ˆใ„", "ใคใ‚‹ใปใ‚™", "ใคใ‚‹ใฟใ", "ใคใ‚ใ‚‚ใฎ", "ใคใ‚ใ‚Š", "ใฆใ‚ใ—", "ใฆใ‚ใฆ", "ใฆใ‚ใฟ", "ใฆใ„ใŠใ‚“", "ใฆใ„ใ‹", "ใฆใ„ใ", "ใฆใ„ใ‘ใ„", "ใฆใ„ใ“ใ", "ใฆใ„ใ•ใค", "ใฆใ„ใ—", "ใฆใ„ใ›ใ„", "ใฆใ„ใŸใ„", "ใฆใ„ใจใ‚™", "ใฆใ„ใญใ„", "ใฆใ„ใฒใ‚‡ใ†", "ใฆใ„ใธใ‚“", "ใฆใ„ใปใ‚™ใ†", "ใฆใ†ใก", "ใฆใŠใใ‚Œ", "ใฆใใจใ†", "ใฆใใฒใ‚™", "ใฆใ‚™ใ“ใปใ‚™ใ“", "ใฆใ•ใใ‚™ใ‚‡ใ†", "ใฆใ•ใ‘ใ‚™", "ใฆใ™ใ‚Š", "ใฆใใ†", "ใฆใกใ‹ใ‚™ใ„", "ใฆใกใ‚‡ใ†", "ใฆใคใ‹ใ‚™ใ", "ใฆใคใคใ‚™ใ", "ใฆใ‚™ใฃใฏใ‚š", "ใฆใคใปใ‚™ใ†", "ใฆใคใ‚„", "ใฆใ‚™ใฌใ‹ใˆ", "ใฆใฌใ", "ใฆใฌใใ‚™ใ„", "ใฆใฎใฒใ‚‰", "ใฆใฏใ„", "ใฆใตใ‚™ใใ‚", "ใฆใตใŸใ‚™", "ใฆใปใจใ‚™ใ", "ใฆใปใ‚“", "ใฆใพใˆ", "ใฆใพใใ™ใ‚™ใ—", "ใฆใฟใ—ใ‚™ใ‹", "ใฆใฟใ‚„ใ‘ใ‚™", "ใฆใ‚‰ใ™", "ใฆใ‚Œใฒใ‚™", "ใฆใ‚ใ‘", "ใฆใ‚ใŸใ—", "ใฆใ‚™ใ‚“ใ‚ใค", "ใฆใ‚“ใ„ใ‚“", "ใฆใ‚“ใ‹ใ„", "ใฆใ‚“ใ", "ใฆใ‚“ใใ‚™", "ใฆใ‚“ใ‘ใ‚“", "ใฆใ‚“ใ“ใ‚™ใ", "ใฆใ‚“ใ•ใ„", "ใฆใ‚“ใ—", "ใฆใ‚“ใ™ใ†", "ใฆใ‚™ใ‚“ใก", "ใฆใ‚“ใฆใ", "ใฆใ‚“ใจใ†", "ใฆใ‚“ใชใ„", "ใฆใ‚“ใตใ‚šใ‚‰", "ใฆใ‚“ใปใ‚™ใ†ใŸใ‚™ใ„", "ใฆใ‚“ใ‚ใค", "ใฆใ‚“ใ‚‰ใ‚“ใ‹ใ„", "ใฆใ‚™ใ‚“ใ‚Šใ‚‡ใ", "ใฆใ‚™ใ‚“ใ‚", "ใจใ‚™ใ‚ใ„", "ใจใ„ใ‚Œ", "ใจใ‚™ใ†ใ‹ใ‚“", "ใจใ†ใใ‚…ใ†", "ใจใ‚™ใ†ใใ‚™", "ใจใ†ใ—", "ใจใ†ใ‚€ใใ‚™", "ใจใŠใ„", "ใจใŠใ‹", "ใจใŠใ", "ใจใŠใ™", "ใจใŠใ‚‹", "ใจใ‹ใ„", "ใจใ‹ใ™", "ใจใใŠใ‚Š", "ใจใใจใ‚™ใ", "ใจใใ„", "ใจใใ—ใ‚…ใ†", "ใจใใฆใ‚“", "ใจใใซ", "ใจใใธใ‚™ใค", "ใจใ‘ใ„", "ใจใ‘ใ‚‹", "ใจใ“ใ‚„", "ใจใ•ใ‹", "ใจใ—ใ‚‡ใ‹ใ‚“", "ใจใใ†", "ใจใŸใ‚“", "ใจใกใ‚…ใ†", "ใจใฃใใ‚…ใ†", "ใจใฃใใ‚“", "ใจใคใ›ใ‚™ใ‚“", "ใจใคใซใ‚…ใ†", "ใจใจใ‚™ใ‘ใ‚‹", "ใจใจใฎใˆใ‚‹", "ใจใชใ„", "ใจใชใˆใ‚‹", "ใจใชใ‚Š", "ใจใฎใ•ใพ", "ใจใฏใ‚™ใ™", "ใจใ‚™ใตใ‚™ใ‹ใ‚™ใ‚", "ใจใปใ†", "ใจใพใ‚‹", "ใจใ‚ใ‚‹", "ใจใ‚‚ใŸใ‚™ใก", "ใจใ‚‚ใ‚‹", "ใจใ‚™ใ‚ˆใ†ใฒใ‚™", "ใจใ‚‰ใˆใ‚‹", "ใจใ‚“ใ‹ใค", "ใจใ‚™ใ‚“ใตใ‚™ใ‚Š", "ใชใ„ใ‹ใ", "ใชใ„ใ“ใ†", "ใชใ„ใ—ใ‚‡", "ใชใ„ใ™", "ใชใ„ใ›ใ‚“", "ใชใ„ใใ†", "ใชใŠใ™", "ใชใ‹ใ‚™ใ„", "ใชใใ™", "ใชใ‘ใ‚™ใ‚‹", "ใชใ“ใ†ใจใ‚™", "ใชใ•ใ‘", "ใชใŸใฆใ‚™ใ“ใ“", "ใชใฃใจใ†", "ใชใคใ‚„ใ™ใฟ", "ใชใชใŠใ—", "ใชใซใ“ใ‚™ใจ", "ใชใซใ‚‚ใฎ", "ใชใซใ‚", "ใชใฎใ‹", "ใชใตใŸใ‚™", "ใชใพใ„ใ", "ใชใพใˆ", "ใชใพใฟ", "ใชใฟใŸใ‚™", "ใชใ‚ใ‚‰ใ‹", "ใชใ‚ใ‚‹", "ใชใ‚„ใ‚€", "ใชใ‚‰ใ†", "ใชใ‚‰ใฒใ‚™", "ใชใ‚‰ใตใ‚™", "ใชใ‚Œใ‚‹", "ใชใ‚ใจใฒใ‚™", "ใชใ‚ใฏใ‚™ใ‚Š", "ใซใ‚ใ†", "ใซใ„ใ‹ใ‚™ใŸ", "ใซใ†ใ‘", "ใซใŠใ„", "ใซใ‹ใ„", "ใซใ‹ใ‚™ใฆ", "ใซใใฒใ‚™", "ใซใใ—ใฟ", "ใซใใพใ‚“", "ใซใ‘ใ‚™ใ‚‹", "ใซใ•ใ‚“ใ‹ใŸใ‚“ใ", "ใซใ—ใ", "ใซใ›ใ‚‚ใฎ", "ใซใกใ—ใ‚™ใ‚‡ใ†", "ใซใกใ‚ˆใ†ใฒใ‚™", "ใซใฃใ‹", "ใซใฃใ", "ใซใฃใ‘ใ„", "ใซใฃใ“ใ†", "ใซใฃใ•ใ‚“", "ใซใฃใ—ใ‚‡ใ", "ใซใฃใ™ใ†", "ใซใฃใ›ใ", "ใซใฃใฆใ„", "ใซใชใ†", "ใซใปใ‚“", "ใซใพใ‚", "ใซใ‚‚ใค", "ใซใ‚„ใ‚Š", "ใซใ‚…ใ†ใ„ใ‚“", "ใซใ‚Šใ‚“ใ—ใ‚ƒ", "ใซใ‚ใจใ‚Š", "ใซใ‚“ใ„", "ใซใ‚“ใ‹", "ใซใ‚“ใ", "ใซใ‚“ใ‘ใ‚™ใ‚“", "ใซใ‚“ใ—ใ", "ใซใ‚“ใ™ใ‚™ใ†", "ใซใ‚“ใใ†", "ใซใ‚“ใŸใ„", "ใซใ‚“ใก", "ใซใ‚“ใฆใ„", "ใซใ‚“ใซใ", "ใซใ‚“ใตใ‚š", "ใซใ‚“ใพใ‚Š", "ใซใ‚“ใ‚€", "ใซใ‚“ใ‚ใ„", "ใซใ‚“ใ‚ˆใ†", "ใฌใ„ใใใ‚™", "ใฌใ‹ใ™", "ใฌใใ‚™ใ„ใจใ‚‹", "ใฌใใ‚™ใ†", "ใฌใใ‚‚ใ‚Š", "ใฌใ™ใ‚€", "ใฌใพใˆใฒใ‚™", "ใฌใ‚ใ‚Š", "ใฌใ‚‰ใ™", "ใฌใ‚“ใกใ‚ƒใ", "ใญใ‚ใ‘ใ‚™", "ใญใ„ใ", "ใญใ„ใ‚‹", "ใญใ„ใ‚", "ใญใใ‚™ใ›", "ใญใใŸใ„", "ใญใใ‚‰", "ใญใ“ใ›ใ‚™", "ใญใ“ใ‚€", "ใญใ•ใ‘ใ‚™", "ใญใ™ใ“ใ‚™ใ™", "ใญใใธใ‚™ใ‚‹", "ใญใŸใ‚™ใ‚“", "ใญใคใ„", "ใญใฃใ—ใ‚“", "ใญใคใใ‚™ใ†", "ใญใฃใŸใ„ใใ‚™ใ‚‡", "ใญใตใ‚™ใใ", "ใญใตใŸใ‚™", "ใญใปใ‚™ใ†", "ใญใปใ‚Šใฏใปใ‚Š", "ใญใพใ", "ใญใพใ‚ใ—", "ใญใฟใฟ", "ใญใ‚€ใ„", "ใญใ‚€ใŸใ„", "ใญใ‚‚ใจ", "ใญใ‚‰ใ†", "ใญใ‚ใ•ใ‚™", "ใญใ‚“ใ„ใ‚Š", "ใญใ‚“ใŠใ—", "ใญใ‚“ใ‹ใ‚“", "ใญใ‚“ใใ‚“", "ใญใ‚“ใใ‚™", "ใญใ‚“ใ•ใ‚™", "ใญใ‚“ใ—", "ใญใ‚“ใกใ‚ƒใ", "ใญใ‚“ใจใ‚™", "ใญใ‚“ใฒใ‚š", "ใญใ‚“ใตใ‚™ใค", "ใญใ‚“ใพใค", "ใญใ‚“ใ‚Šใ‚‡ใ†", "ใญใ‚“ใ‚Œใ„", "ใฎใ„ใ™ใ‚™", "ใฎใŠใคใ‚™ใพ", "ใฎใ‹ใ‚™ใ™", "ใฎใใชใฟ", "ใฎใ“ใใ‚™ใ‚Š", "ใฎใ“ใ™", "ใฎใ“ใ‚‹", "ใฎใ›ใ‚‹", "ใฎใใ‚™ใ", "ใฎใใ‚™ใ‚€", "ใฎใŸใพใ†", "ใฎใกใปใจใ‚™", "ใฎใฃใ", "ใฎใฏใ‚™ใ™", "ใฎใฏใ‚‰", "ใฎใธใ‚™ใ‚‹", "ใฎใปใ‚™ใ‚‹", "ใฎใฟใ‚‚ใฎ", "ใฎใ‚„ใพ", "ใฎใ‚‰ใ„ใฌ", "ใฎใ‚‰ใญใ“", "ใฎใ‚Šใ‚‚ใฎ", "ใฎใ‚Šใ‚†ใ", "ใฎใ‚Œใ‚“", "ใฎใ‚“ใ", "ใฏใ‚™ใ‚ใ„", "ใฏใ‚ใ", "ใฏใ‚™ใ‚ใ•ใ‚“", "ใฏใ‚™ใ„ใ‹", "ใฏใ‚™ใ„ใ", "ใฏใ„ใ‘ใ‚“", "ใฏใ„ใ“ใ‚™", "ใฏใ„ใ—ใ‚“", "ใฏใ„ใ™ใ„", "ใฏใ„ใ›ใ‚“", "ใฏใ„ใใ†", "ใฏใ„ใก", "ใฏใ‚™ใ„ใฏใ‚™ใ„", "ใฏใ„ใ‚Œใค", "ใฏใˆใ‚‹", "ใฏใŠใ‚‹", "ใฏใ‹ใ„", "ใฏใ‚™ใ‹ใ‚Š", "ใฏใ‹ใ‚‹", "ใฏใใ—ใ‚…", "ใฏใ‘ใ‚“", "ใฏใ“ใตใ‚™", "ใฏใ•ใฟ", "ใฏใ•ใ‚“", "ใฏใ—ใ“ใ‚™", "ใฏใ‚™ใ—ใ‚‡", "ใฏใ—ใ‚‹", "ใฏใ›ใ‚‹", "ใฏใ‚šใใ“ใ‚“", "ใฏใใ‚“", "ใฏใŸใ‚“", "ใฏใกใฟใค", "ใฏใคใŠใ‚“", "ใฏใฃใ‹ใ", "ใฏใคใ‚™ใ", "ใฏใฃใใ‚Š", "ใฏใฃใใค", "ใฏใฃใ‘ใ‚“", "ใฏใฃใ“ใ†", "ใฏใฃใ•ใ‚“", "ใฏใฃใ—ใ‚“", "ใฏใฃใŸใค", "ใฏใฃใกใ‚…ใ†", "ใฏใฃใฆใ‚“", "ใฏใฃใฒใ‚šใ‚‡ใ†", "ใฏใฃใปใ‚šใ†", "ใฏใชใ™", "ใฏใชใฒใ‚™", "ใฏใซใ‹ใ‚€", "ใฏใตใ‚™ใ‚‰ใ—", "ใฏใฟใ‹ใ‚™ใ", "ใฏใ‚€ใ‹ใ†", "ใฏใ‚ใค", "ใฏใ‚„ใ„", "ใฏใ‚„ใ—", "ใฏใ‚‰ใ†", "ใฏใ‚ใ†ใƒใ‚“", "ใฏใ‚ใ„", "ใฏใ‚“ใ„", "ใฏใ‚“ใˆใ„", "ใฏใ‚“ใŠใ‚“", "ใฏใ‚“ใ‹ใ", "ใฏใ‚“ใใ‚‡ใ†", "ใฏใ‚™ใ‚“ใใ‚™ใฟ", "ใฏใ‚“ใ“", "ใฏใ‚“ใ—ใ‚ƒ", "ใฏใ‚“ใ™ใ†", "ใฏใ‚“ใŸใ‚™ใ‚“", "ใฏใ‚šใ‚“ใก", "ใฏใ‚šใ‚“ใค", "ใฏใ‚“ใฆใ„", "ใฏใ‚“ใจใ—", "ใฏใ‚“ใฎใ†", "ใฏใ‚“ใฏใ‚š", "ใฏใ‚“ใตใ‚™ใ‚“", "ใฏใ‚“ใธใ‚šใ‚“", "ใฏใ‚“ใปใ‚™ใ†ใ", "ใฏใ‚“ใ‚ใ„", "ใฏใ‚“ใ‚‰ใ‚“", "ใฏใ‚“ใ‚ใ‚“", "ใฒใ„ใ", "ใฒใ†ใ‚“", "ใฒใˆใ‚‹", "ใฒใ‹ใ", "ใฒใ‹ใ‚Š", "ใฒใ‹ใ‚‹", "ใฒใ‹ใ‚“", "ใฒใใ„", "ใฒใ‘ใค", "ใฒใ“ใ†ใ", "ใฒใ“ใ", "ใฒใ•ใ„", "ใฒใ•ใ—ใตใ‚™ใ‚Š", "ใฒใ•ใ‚“", "ใฒใ‚™ใ—ใ‚™ใ‚…ใคใ‹ใ‚“", "ใฒใ—ใ‚‡", "ใฒใใ‹", "ใฒใใ‚€", "ใฒใŸใ‚€ใ", "ใฒใŸใ‚™ใ‚Š", "ใฒใŸใ‚‹", "ใฒใคใใ‚™", "ใฒใฃใ“ใ—", "ใฒใฃใ—", "ใฒใคใ—ใ‚™ใ‚…ใฒใ‚“", "ใฒใฃใ™", "ใฒใคใ›ใ‚™ใ‚“", "ใฒใ‚šใฃใŸใ‚Š", "ใฒใ‚šใฃใกใ‚Š", "ใฒใคใ‚ˆใ†", "ใฒใฆใ„", "ใฒใจใ“ใ‚™ใฟ", "ใฒใชใพใคใ‚Š", "ใฒใชใ‚“", "ใฒใญใ‚‹", "ใฒใฏใ‚“", "ใฒใฒใ‚™ใ", "ใฒใฒใ‚‡ใ†", "ใฒใปใ†", "ใฒใพใ‚ใ‚Š", "ใฒใพใ‚“", "ใฒใฟใค", "ใฒใ‚ใ„", "ใฒใ‚ใ—ใ‚™ใ—", "ใฒใ‚„ใ‘", "ใฒใ‚„ใ™", "ใฒใ‚ˆใ†", "ใฒใ‚™ใ‚‡ใ†ใ", "ใฒใ‚‰ใ‹ใ‚™ใช", "ใฒใ‚‰ใ", "ใฒใ‚Šใค", "ใฒใ‚Šใ‚‡ใ†", "ใฒใ‚‹ใพ", "ใฒใ‚‹ใ‚„ใ™ใฟ", "ใฒใ‚Œใ„", "ใฒใ‚ใ„", "ใฒใ‚ใ†", "ใฒใ‚ใ", "ใฒใ‚ใ‚†ใ", "ใฒใ‚“ใ‹ใ", "ใฒใ‚“ใ‘ใค", "ใฒใ‚“ใ“ใ‚“", "ใฒใ‚“ใ—ใ‚…", "ใฒใ‚“ใใ†", "ใฒใ‚šใ‚“ใก", "ใฒใ‚“ใฏใ‚šใ‚“", "ใฒใ‚™ใ‚“ใปใ‚™ใ†", "ใตใ‚ใ‚“", "ใตใ„ใ†ใก", "ใตใ†ใ‘ใ„", "ใตใ†ใ›ใ‚“", "ใตใ‚šใ†ใŸใ‚ใ†", "ใตใ†ใจใ†", "ใตใ†ใต", "ใตใˆใ‚‹", "ใตใŠใ‚“", "ใตใ‹ใ„", "ใตใใ‚“", "ใตใใ•ใ‚™ใค", "ใตใใตใ‚™ใใ‚", "ใตใ“ใ†", "ใตใ•ใ„", "ใตใ—ใใ‚™", "ใตใ—ใ‚™ใฟ", "ใตใ™ใพ", "ใตใ›ใ„", "ใตใ›ใใ‚™", "ใตใใ", "ใตใ‚™ใŸใซใ", "ใตใŸใ‚“", "ใตใกใ‚‡ใ†", "ใตใคใ†", "ใตใคใ‹", "ใตใฃใ‹ใค", "ใตใฃใ", "ใตใฃใ“ใ", "ใตใ‚™ใจใ‚™ใ†", "ใตใจใ‚‹", "ใตใจใ‚“", "ใตใฎใ†", "ใตใฏใ„", "ใตใฒใ‚‡ใ†", "ใตใธใ‚“", "ใตใพใ‚“", "ใตใฟใ‚“", "ใตใ‚ใค", "ใตใ‚ใ‚“", "ใตใ‚ˆใ†", "ใตใ‚Šใ“", "ใตใ‚Šใ‚‹", "ใตใ‚‹ใ„", "ใตใ‚“ใ„ใ", "ใตใ‚™ใ‚“ใ‹ใ‚™ใ", "ใตใ‚™ใ‚“ใใ‚™", "ใตใ‚“ใ—ใค", "ใตใ‚™ใ‚“ใ›ใ", "ใตใ‚“ใใ†", "ใตใ‚™ใ‚“ใปใ‚šใ†", "ใธใ„ใ‚ใ‚“", "ใธใ„ใŠใ‚“", "ใธใ„ใ‹ใ‚™ใ„", "ใธใ„ใ", "ใธใ„ใ‘ใ‚™ใ‚“", "ใธใ„ใ“ใ†", "ใธใ„ใ•", "ใธใ„ใ—ใ‚ƒ", "ใธใ„ใ›ใค", "ใธใ„ใ", "ใธใ„ใŸใ", "ใธใ„ใฆใ‚“", "ใธใ„ใญใค", "ใธใ„ใ‚", "ใธใใ‹ใ‚™", "ใธใ“ใ‚€", "ใธใ‚™ใซใ„ใ‚", "ใธใ‚™ใซใ—ใ‚‡ใ†ใ‹ใ‚™", "ใธใ‚‰ใ™", "ใธใ‚“ใ‹ใ‚“", "ใธใ‚™ใ‚“ใใ‚‡ใ†", "ใธใ‚™ใ‚“ใ“ใ‚™ใ—", "ใธใ‚“ใ•ใ„", "ใธใ‚“ใŸใ„", "ใธใ‚™ใ‚“ใ‚Š", "ใปใ‚ใ‚“", "ใปใ„ใ", "ใปใ‚™ใ†ใใ‚™ใ‚‡", "ใปใ†ใ“ใ", "ใปใ†ใใ†", "ใปใ†ใปใ†", "ใปใ†ใ‚‚ใ‚“", "ใปใ†ใ‚Šใค", "ใปใˆใ‚‹", "ใปใŠใ‚“", "ใปใ‹ใ‚“", "ใปใใ‚‡ใ†", "ใปใ‚™ใใ‚“", "ใปใใ‚", "ใปใ‘ใค", "ใปใ‘ใ‚“", "ใปใ“ใ†", "ใปใ“ใ‚‹", "ใปใ—ใ„", "ใปใ—ใค", "ใปใ—ใ‚…", "ใปใ—ใ‚‡ใ†", "ใปใ›ใ„", "ใปใใ„", "ใปใใ", "ใปใŸใฆ", "ใปใŸใ‚‹", "ใปใ‚šใกใตใ‚™ใใ‚", "ใปใฃใใ‚‡ใ", "ใปใฃใ•", "ใปใฃใŸใ‚“", "ใปใจใ‚“ใจใ‚™", "ใปใ‚ใ‚‹", "ใปใ‚“ใ„", "ใปใ‚“ใ", "ใปใ‚“ใ‘", "ใปใ‚“ใ—ใค", "ใปใ‚“ใ‚„ใ", "ใพใ„ใซใก", "ใพใ‹ใ„", "ใพใ‹ใ›ใ‚‹", "ใพใ‹ใ‚™ใ‚‹", "ใพใ‘ใ‚‹", "ใพใ“ใจ", "ใพใ•ใค", "ใพใ—ใ‚™ใ‚", "ใพใ™ใ", "ใพใ›ใ‚™ใ‚‹", "ใพใคใ‚Š", "ใพใจใ‚", "ใพใชใตใ‚™", "ใพใฌใ‘", "ใพใญใ", "ใพใปใ†", "ใพใ‚‚ใ‚‹", "ใพใ‚†ใ‘ใ‚™", "ใพใ‚ˆใ†", "ใพใ‚ใ‚„ใ‹", "ใพใ‚ใ™", "ใพใ‚ใ‚Š", "ใพใ‚ใ‚‹", "ใพใ‚“ใ‹ใ‚™", "ใพใ‚“ใใค", "ใพใ‚“ใใ‚™ใ", "ใพใ‚“ใชใ‹", "ใฟใ„ใ‚‰", "ใฟใ†ใก", "ใฟใˆใ‚‹", "ใฟใ‹ใ‚™ใ", "ใฟใ‹ใŸ", "ใฟใ‹ใ‚“", "ใฟใ‘ใ‚“", "ใฟใ“ใ‚“", "ใฟใ—ใ‚™ใ‹ใ„", "ใฟใ™ใ„", "ใฟใ™ใˆใ‚‹", "ใฟใ›ใ‚‹", "ใฟใฃใ‹", "ใฟใคใ‹ใ‚‹", "ใฟใคใ‘ใ‚‹", "ใฟใฆใ„", "ใฟใจใ‚ใ‚‹", "ใฟใชใจ", "ใฟใชใฟใ‹ใ•ใ„", "ใฟใญใ‚‰ใ‚‹", "ใฟใฎใ†", "ใฟใฎใ‹ใ‚™ใ™", "ใฟใปใ‚“", "ใฟใ‚‚ใจ", "ใฟใ‚„ใ‘ใ‚™", "ใฟใ‚‰ใ„", "ใฟใ‚Šใ‚‡ใ", "ใฟใ‚ใ", "ใฟใ‚“ใ‹", "ใฟใ‚“ใใ‚™ใ", "ใ‚€ใ„ใ‹", "ใ‚€ใˆใ", "ใ‚€ใˆใ‚“", "ใ‚€ใ‹ใ„", "ใ‚€ใ‹ใ†", "ใ‚€ใ‹ใˆ", "ใ‚€ใ‹ใ—", "ใ‚€ใใ‚™ใกใ‚ƒ", "ใ‚€ใ‘ใ‚‹", "ใ‚€ใ‘ใ‚™ใ‚“", "ใ‚€ใ•ใปใ‚™ใ‚‹", "ใ‚€ใ—ใ‚ใคใ„", "ใ‚€ใ—ใฏใ‚™", "ใ‚€ใ—ใ‚™ใ‚…ใ‚“", "ใ‚€ใ—ใ‚", "ใ‚€ใ™ใ†", "ใ‚€ใ™ใ“", "ใ‚€ใ™ใตใ‚™", "ใ‚€ใ™ใ‚", "ใ‚€ใ›ใ‚‹", "ใ‚€ใ›ใ‚“", "ใ‚€ใกใ‚…ใ†", "ใ‚€ใชใ—ใ„", "ใ‚€ใฎใ†", "ใ‚€ใ‚„ใฟ", "ใ‚€ใ‚ˆใ†", "ใ‚€ใ‚‰ใ•ใ", "ใ‚€ใ‚Šใ‚‡ใ†", "ใ‚€ใ‚ใ‚“", "ใ‚ใ„ใ‚ใ‚“", "ใ‚ใ„ใ†ใ‚“", "ใ‚ใ„ใˆใ‚“", "ใ‚ใ„ใ‹ใ", "ใ‚ใ„ใใ‚‡ใ", "ใ‚ใ„ใ•ใ„", "ใ‚ใ„ใ—", "ใ‚ใ„ใใ†", "ใ‚ใ„ใตใ‚™ใค", "ใ‚ใ„ใ‚Œใ„", "ใ‚ใ„ใ‚ใ", "ใ‚ใใ‚™ใพใ‚Œใ‚‹", "ใ‚ใ•ใ‚™ใ™", "ใ‚ใ—ใŸ", "ใ‚ใ™ใ‚™ใ‚‰ใ—ใ„", "ใ‚ใŸใ‚™ใค", "ใ‚ใพใ„", "ใ‚ใ‚„ใ™", "ใ‚ใ‚“ใใ‚‡", "ใ‚ใ‚“ใ›ใ", "ใ‚ใ‚“ใจใ‚™ใ†", "ใ‚‚ใ†ใ—ใ‚ใ‘ใ‚™ใ‚‹", "ใ‚‚ใ†ใจใ‚™ใ†ใ‘ใ‚“", "ใ‚‚ใˆใ‚‹", "ใ‚‚ใใ—", "ใ‚‚ใใฆใ", "ใ‚‚ใใ‚ˆใ†ใฒใ‚™", "ใ‚‚ใกใ‚ใ‚“", "ใ‚‚ใจใ‚™ใ‚‹", "ใ‚‚ใ‚‰ใ†", "ใ‚‚ใ‚“ใ", "ใ‚‚ใ‚“ใŸใ‚™ใ„", "ใ‚„ใŠใ‚„", "ใ‚„ใ‘ใ‚‹", "ใ‚„ใ•ใ„", "ใ‚„ใ•ใ—ใ„", "ใ‚„ใ™ใ„", "ใ‚„ใ™ใŸใ‚ใ†", "ใ‚„ใ™ใฟ", "ใ‚„ใ›ใ‚‹", "ใ‚„ใใ†", "ใ‚„ใŸใ„", "ใ‚„ใกใ‚“", "ใ‚„ใฃใจ", "ใ‚„ใฃใฏใ‚šใ‚Š", "ใ‚„ใตใ‚™ใ‚‹", "ใ‚„ใ‚ใ‚‹", "ใ‚„ใ‚„ใ“ใ—ใ„", "ใ‚„ใ‚ˆใ„", "ใ‚„ใ‚ใ‚‰ใ‹ใ„", "ใ‚†ใ†ใ", "ใ‚†ใ†ใฒใ‚™ใ‚“ใใ‚‡ใ", "ใ‚†ใ†ใธใ‚™", "ใ‚†ใ†ใ‚ใ„", "ใ‚†ใ‘ใค", "ใ‚†ใ—ใ‚…ใค", "ใ‚†ใ›ใ‚“", "ใ‚†ใใ†", "ใ‚†ใŸใ‹", "ใ‚†ใกใ‚ƒใ", "ใ‚†ใฆใ‚™ใ‚‹", "ใ‚†ใซใ‚…ใ†", "ใ‚†ใฒใ‚™ใ‚", "ใ‚†ใ‚‰ใ„", "ใ‚†ใ‚Œใ‚‹", "ใ‚ˆใ†ใ„", "ใ‚ˆใ†ใ‹", "ใ‚ˆใ†ใใ‚…ใ†", "ใ‚ˆใ†ใ—ใ‚™", "ใ‚ˆใ†ใ™", "ใ‚ˆใ†ใกใˆใ‚“", "ใ‚ˆใ‹ใ›ใ‚™", "ใ‚ˆใ‹ใ‚“", "ใ‚ˆใใ‚“", "ใ‚ˆใใ›ใ„", "ใ‚ˆใใปใ‚™ใ†", "ใ‚ˆใ‘ใ„", "ใ‚ˆใ“ใ‚™ใ‚Œใ‚‹", "ใ‚ˆใ•ใ‚“", "ใ‚ˆใ—ใ‚…ใ†", "ใ‚ˆใใ†", "ใ‚ˆใใ", "ใ‚ˆใฃใ‹", "ใ‚ˆใฆใ„", "ใ‚ˆใจใ‚™ใ‹ใ‚™ใ‚ใ", "ใ‚ˆใญใค", "ใ‚ˆใ‚„ใ", "ใ‚ˆใ‚†ใ†", "ใ‚ˆใ‚ใ“ใตใ‚™", "ใ‚ˆใ‚ใ—ใ„", "ใ‚‰ใ„ใ†", "ใ‚‰ใใ‹ใ‚™ใ", "ใ‚‰ใใ“ใ‚™", "ใ‚‰ใใ•ใค", "ใ‚‰ใใŸใ‚™", "ใ‚‰ใ—ใ‚“ใฏใ‚™ใ‚“", "ใ‚‰ใ›ใ‚“", "ใ‚‰ใใ‚™ใ", "ใ‚‰ใŸใ„", "ใ‚‰ใฃใ‹", "ใ‚‰ใ‚Œใค", "ใ‚Šใˆใ", "ใ‚Šใ‹ใ„", "ใ‚Šใใ•ใ", "ใ‚Šใใ›ใค", "ใ‚Šใใใ‚™ใ‚“", "ใ‚Šใใค", "ใ‚Šใ‘ใ‚“", "ใ‚Šใ“ใ†", "ใ‚Šใ›ใ„", "ใ‚Šใใ†", "ใ‚Šใใ", "ใ‚Šใฆใ‚“", "ใ‚Šใญใ‚“", "ใ‚Šใ‚†ใ†", "ใ‚Šใ‚…ใ†ใ‹ใ‚™ใ", "ใ‚Šใ‚ˆใ†", "ใ‚Šใ‚‡ใ†ใ‚Š", "ใ‚Šใ‚‡ใ‹ใ‚“", "ใ‚Šใ‚‡ใใกใ‚ƒ", "ใ‚Šใ‚‡ใ“ใ†", "ใ‚Šใ‚Šใ", "ใ‚Šใ‚Œใ", "ใ‚Šใ‚ใ‚“", "ใ‚Šใ‚“ใ“ใ‚™", "ใ‚‹ใ„ใ‘ใ„", "ใ‚‹ใ„ใ•ใ„", "ใ‚‹ใ„ใ—ใ‚™", "ใ‚‹ใ„ใ›ใ", "ใ‚‹ใ™ใฏใ‚™ใ‚“", "ใ‚‹ใ‚Šใ‹ใ‚™ใ‚ใ‚‰", "ใ‚Œใ„ใ‹ใ‚“", "ใ‚Œใ„ใใ‚™", "ใ‚Œใ„ใ›ใ„", "ใ‚Œใ„ใใ‚™ใ†ใ“", "ใ‚Œใ„ใจใ†", "ใ‚Œใ„ใปใ‚™ใ†", "ใ‚Œใใ—", "ใ‚ŒใใŸใ‚™ใ„", "ใ‚Œใ‚“ใ‚ใ„", "ใ‚Œใ‚“ใ‘ใ„", "ใ‚Œใ‚“ใ“ใ‚“", "ใ‚Œใ‚“ใ•ใ„", "ใ‚Œใ‚“ใ—ใ‚…ใ†", "ใ‚Œใ‚“ใใ‚™ใ", "ใ‚Œใ‚“ใ‚‰ใ", "ใ‚ใ†ใ‹", "ใ‚ใ†ใ“ใ‚™", "ใ‚ใ†ใ—ใ‚™ใ‚“", "ใ‚ใ†ใใ", "ใ‚ใใ‹ใ‚™", "ใ‚ใ“ใค", "ใ‚ใ—ใ‚™ใ†ใ‚‰", "ใ‚ใ—ใ‚…ใค", "ใ‚ใ›ใ‚“", "ใ‚ใฆใ‚“", "ใ‚ใ‚ใ‚“", "ใ‚ใ‚Œใค", "ใ‚ใ‚“ใใ‚™", "ใ‚ใ‚“ใฏใ‚š", "ใ‚ใ‚“ใตใ‚™ใ‚“", "ใ‚ใ‚“ใ‚Š", "ใ‚ใ‹ใ™", "ใ‚ใ‹ใ‚", "ใ‚ใ‹ใ‚„ใพ", "ใ‚ใ‹ใ‚Œใ‚‹", "ใ‚ใ—ใค", "ใ‚ใ—ใ‚™ใพใ—", "ใ‚ใ™ใ‚Œใ‚‚ใฎ", "ใ‚ใ‚‰ใ†", "ใ‚ใ‚Œใ‚‹" }; } } #endif
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/Plugin/Transaction/Payload/DIDInfo.h
<reponame>fakecoinbase/elastosslashElastos.ELA.SPV.Cpp // Copyright (c) 2012-2019 The Elastos Open Source Project // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef __ELASTOS_SDK_DIDINFO_H__ #define __ELASTOS_SDK_DIDINFO_H__ #include "IPayload.h" #include <Common/JsonGenerator.h> namespace Elastos { namespace ElaWallet { #define DID_DEFAULT_TYPE "ECDSAsecp256r1" #define PREFIX_DID "did:elastos:" #define UPDATE_DID "update" #define PRIMARY_KEY "#primary" class DIDHeaderInfo { public: DIDHeaderInfo(); ~DIDHeaderInfo(); DIDHeaderInfo(const std::string &specification, const std::string &operation, const std::string &preTxID = ""); const std::string &Specification() const; void SetSpecification(const std::string &specification); const std::string &Operation() const; void SetOperation(const std::string &operation); void SetPreviousTxid(const std::string &txid); const std::string &PreviousTxid() const; public: virtual size_t EstimateSize(uint8_t version) const; virtual void Serialize(ByteStream &stream, uint8_t version) const; virtual bool Deserialize(const ByteStream &stream, uint8_t version); virtual nlohmann::json ToJson(uint8_t version) const; virtual void FromJson(const nlohmann::json &j, uint8_t version); private: std::string _specification; std::string _operation; std::string _previousTxid; }; class DIDPubKeyInfo { public: DIDPubKeyInfo(); ~DIDPubKeyInfo(); DIDPubKeyInfo(const std::string &id, const std::string &pubkeyBase58, const std::string &controller = "", const std::string &type = DID_DEFAULT_TYPE); const std::string &ID() const; void SetID(const std::string &id); const std::string &Type() const; void SetType(const std::string &type); const std::string &Controller() const; void SetController(const std::string &controller); const std::string &PublicKeyBase58() const; void SetPublicKeyBase58(const std::string &pubkey); virtual nlohmann::json ToJson(uint8_t version) const; virtual void FromJson(const nlohmann::json &j, uint8_t version); void ToOrderedJson(JsonGenerator *generator) const; void AutoFill(const std::string &did); private: std::string _id; std::string _type; std::string _controller; std::string _publicKeyBase58; }; typedef std::vector<DIDPubKeyInfo> DIDPubKeyInfoArray; class CredentialSubject { public: CredentialSubject(); ~CredentialSubject(); void SetID(const std::string &id); const std::string &ID() const; void AutoFill(const std::string &did); const nlohmann::json &GetProperties() const; const nlohmann::json &GetValue(const std::string &key) const; bool HasProperties(const std::string &key) const; void AddProperties(const std::string &key, const std::string &value); public: virtual nlohmann::json ToJson(uint8_t version) const; virtual void FromJson(const nlohmann::json &j, uint8_t version); void ToOrderedJson(JsonGenerator *generator) const; private: void Properties2OrderedJson(JsonGenerator *generator, const nlohmann::json &properties) const; private: std::string _id; nlohmann::json _properties; }; typedef std::vector<CredentialSubject> CredentialSubjectArray; class DIDProofInfo { public: DIDProofInfo(); ~DIDProofInfo(); DIDProofInfo(const std::string &method, const std::string &signature, const std::string &type = DID_DEFAULT_TYPE); const std::string &Type() const; void SetType(const std::string &type); const std::string &VerificationMethod() const; void SetVerificationMethod(const std::string &method); const std::string &Signature() const; void SetSignature(const std::string &sign); public: virtual size_t EstimateSize(uint8_t version) const; virtual void Serialize(ByteStream &stream, uint8_t version) const; virtual bool Deserialize(const ByteStream &stream, uint8_t version); virtual nlohmann::json ToJson(uint8_t version) const; virtual void FromJson(const nlohmann::json &j, uint8_t version); void AutoFill(const std::string &did); void ToOrderJson(JsonGenerator *generator) const; private: std::string _type; std::string _verificationMethod; std::string _signature; }; class ServiceEndpoint { public: ServiceEndpoint(); ServiceEndpoint(const std::string &id, const std::string &type, const std::string &serviceEndpoint); ~ServiceEndpoint(); void SetID(const std::string &id); const std::string &ID() const; void SetType(const std::string &type); const std::string &Type() const; void SetService(const std::string &service); const std::string &GetService() const; void AutoFill(const std::string &did); public: virtual nlohmann::json ToJson(uint8_t version) const; virtual void FromJson(const nlohmann::json &j, uint8_t version); void ToOrderedJson(JsonGenerator *generator) const; private: std::string _id; std::string _type; std::string _serviceEndpoint; }; typedef std::vector<ServiceEndpoint> ServiceEndpoints; class VerifiableCredential { public: VerifiableCredential(); ~VerifiableCredential(); void SetID(const std::string &id); const std::string &ID(); void SetTypes(const std::vector<std::string> &types); const std::vector<std::string> &Types() const; void SetIssuer(const std::string &issuer); const std::string &GetIssuer() const; void SetIssuerDate(const std::string &issuerDate); const std::string &GetIssuerDate() const; void SetCredentialSubject(const CredentialSubject &credentialSubject); const CredentialSubject &GetCredentialSubject() const; void SetProof(const DIDProofInfo &proof); const DIDProofInfo &Proof() const; void AutoFill(const std::string &did); public: virtual nlohmann::json ToJson(uint8_t version) const; virtual void FromJson(const nlohmann::json &j, uint8_t version); void ToOrderedJson(JsonGenerator *generator) const; private: std::string _id; std::vector<std::string> _types; std::string _issuer; std::string _issuanceDate; std::string _expirationDate; CredentialSubject _credentialSubject; DIDProofInfo _proof; }; typedef std::vector<VerifiableCredential> VerifiableCredentialArray; class DIDPayloadProof { public: DIDPayloadProof(); ~DIDPayloadProof(); void SetType(const std::string &type); const std::string &GetType() const; void SetCreateDate(const std::string &date); const std::string &GetCreatedDate() const; void SetCreator(const std::string &creator); const std::string &GetCreator() const; void SetSignature(const std::string &signature); const std::string &GetSignature() const; virtual nlohmann::json ToJson(uint8_t version) const; virtual void FromJson(const nlohmann::json &j, uint8_t version); private: std::string _type; std::string _created; std::string _creator; std::string _signatureValue; }; class DIDPayloadInfo { public: DIDPayloadInfo(); ~DIDPayloadInfo(); const std::string &ID() const; void SetID(const std::string &id); const DIDPubKeyInfoArray &PublicKeyInfo() const; void SetPublickKey(const DIDPubKeyInfoArray &pubkey); const DIDPubKeyInfoArray &Authentication() const; void SetAuthentication(const DIDPubKeyInfoArray &authentication); const DIDPubKeyInfoArray &Authorization() const; void SetAuthorization(const DIDPubKeyInfoArray &authorization); const VerifiableCredentialArray &GetVerifiableCredential() const; void SetVerifiableCredential(const VerifiableCredentialArray &verifiableCredential); const ServiceEndpoints &GetServiceEndpoint() const; void SetServiceEndpoints(const ServiceEndpoints &serviceEndpoint); const std::string &Expires() const; void SetExpires(const std::string &expires); void SetProof(const DIDPayloadProof &proof); const DIDPayloadProof &GetProof() const; public: virtual bool IsValid() const; virtual nlohmann::json ToJson(uint8_t version) const; virtual void FromJson(const nlohmann::json &j, uint8_t version); std::string ToOrderedJson() const; private: std::string _id; DIDPubKeyInfoArray _publickey; DIDPubKeyInfoArray _authentication; // contain 0 or 1 DIDPubKeyInfoArray _authorization; // contain 0 or 1 VerifiableCredentialArray _verifiableCredential; // contain 0 or 1 ServiceEndpoints _services; // contain 0 or 1 std::string _expires; DIDPayloadProof _proof; }; class DIDInfo : public IPayload { public: DIDInfo(); ~DIDInfo(); void SetDIDHeader(const DIDHeaderInfo &headerInfo); const DIDHeaderInfo &DIDHeader() const; const std::string &DIDPayloadString() const; void SetDIDPlayloadInfo(const DIDPayloadInfo &didPayloadInfo); const DIDPayloadInfo &DIDPayload() const; void SetDIDProof(const DIDProofInfo &proofInfo); const DIDProofInfo &DIDProof() const; public: virtual size_t EstimateSize(uint8_t version) const; virtual void Serialize(ByteStream &stream, uint8_t version) const; virtual bool Deserialize(const ByteStream &stream, uint8_t version); virtual nlohmann::json ToJson(uint8_t version) const; virtual void FromJson(const nlohmann::json &j, uint8_t version); virtual bool IsValid(uint8_t version) const; virtual IPayload &operator=(const IPayload &payload); DIDInfo &operator=(const DIDInfo &payload); private: DIDHeaderInfo _header; std::string _payload; DIDProofInfo _proof; DIDPayloadInfo _payloadInfo; }; } } #endif //SPVSDK_DIDINFO_H
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/les/msg/BREthereumMessageDIS.h
// // BREthereumMessageDIS.h // BRCore // // Created by <NAME> on 9/1/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // // See the LICENSE file at the project root for license information. // See the CONTRIBUTORS file at the project root for a list of contributors. #ifndef BR_Ethereum_Message_DIS_H #define BR_Ethereum_Message_DIS_H #include "support/BRKey.h" #include "../BREthereumLESBase.h" #ifdef __cplusplus extern "C" { #endif /** * Node DIScovery (apparently V4) defines four message types: PING, PONG, FIND_NEIGHBORS and * NEIGHBORS. Note that the message identifier of '0x00' is reserved. This DIS identifier of * 0x00, ..., 0x04 overlap with the P2P identifier; however, the DIS identifier are used on the * UDP route (and PIP identifiers are use don the TCP route). */ typedef enum { /* No 0x00 value; caution on indexing */ DIS_MESSAGE_PING = 0x01, DIS_MESSAGE_PONG = 0x02, DIS_MESSAGE_FIND_NEIGHBORS = 0x03, DIS_MESSAGE_NEIGHBORS = 0x04 } BREthereumDISMessageIdentifier; #define MESSAGE_DIS_IDENTIFIER_ANY ((BREthereumDISMessageIdentifier) 0x00) extern const char * messageDISGetIdentifierName (BREthereumDISMessageIdentifier identifier); /** * A DIS Endpoint is commonly used to identify an INET address. Sometimes a DIS Endpoint is * provided to identify from/to (like in the Ping/Pong mesages) and, most importantly, to identify * peers (like in the Neighbor message). */ typedef struct { /** The AF (Address Family) domain - one of AF_INET or AF_INET6 */ int domain; /** The IP address - 4 bytes for ivp4; 16 bytes for ivp6 */ union { uint8_t ipv4[4]; // struct in_addr uint8_t ipv6[16]; } addr; /** The UDP port */ uint16_t portUDP; /** The TCP port */ uint16_t portTCP; } BREthereumDISEndpoint; extern BRRlpItem endpointDISEncode (const BREthereumDISEndpoint *endpoint, BRRlpCoder coder); extern BREthereumDISEndpoint endpointDISDecode (BRRlpItem item, BRRlpCoder coder); /** * The DIS Ping Message. The first four fields are RLP encoded. We */ typedef struct { int version; // = 4 BREthereumDISEndpoint from; BREthereumDISEndpoint to; uint64_t expiration; /** The Ping hash (from the DIS header) is used in the Pong reply. We record it here */ BREthereumHash hash; } BREthereumDISMessagePing; extern BREthereumDISMessagePing messageDISPingCreate (BREthereumDISEndpoint to, BREthereumDISEndpoint from, uint64_t expiration); /** * The DIS Pong Message */ typedef struct { BREthereumDISEndpoint to; BREthereumHash pingHash; uint64_t expiration; } BREthereumDISMessagePong; extern BREthereumDISMessagePong messageDISPongCreate (BREthereumDISEndpoint to, BREthereumHash pingHash, uint64_t expiration); /** * The DIS Find Neighbors Message */ typedef struct { BRKey target; // 65-byte secp256k1 public key uint64_t expiration; } BREthereumDISMessageFindNeighbors; extern BREthereumDISMessageFindNeighbors messageDISFindNeighborsCreate (BRKey target, uint64_t expiration); /** * A DIS Neighbor. The result of Find Neighbors will be an array of these */ typedef struct { BREthereumDISEndpoint node; BRKey key; // a 64 byte public key } BREthereumDISNeighbor; extern BREthereumHash neighborDISHash (BREthereumDISNeighbor neighbor); /** * The DIS Neighbor Distance * * https://github.com/ethereum/devp2p/blob/master/discv4.md * distance(nโ‚, nโ‚‚) = keccak256(nโ‚) XOR keccak256(nโ‚‚) * "The 'distance' between two node IDs is the bitwise exclusive or on the hashes of the public * keys, taken as the number." * * @param n1 The DISNeighbor, n1, w/ nodeID * @param n2 The DISNeighbor, n2, w/ nodeID * * @return The distance as a UInt256 */ extern UInt256 neighborDISDistance (BREthereumDISNeighbor n1, BREthereumDISNeighbor n2); // enode://<nodeid>@<ip>:<port> #define NEIGHBOR_DIS_ENODE_STRLEN (8 + 2 * 64 + 1 + 39 + 1 + 5 + 1) typedef struct { char chars[NEIGHBOR_DIS_ENODE_STRLEN]; } BREthereumDISNeighborEnode; extern BREthereumDISNeighborEnode neighborDISAsEnode (BREthereumDISNeighbor neighbor, int useTCP); /** * The DIS Neighbors Message. */ typedef struct { BRArrayOf(BREthereumDISNeighbor) neighbors; uint64_t expiration; } BREthereumDISMessageNeighbors; /** * A DIS Message is one of four messages. We include the `privateKeyForSigning` - although * it might be better to provide the key at the point when the message is serialized so that * the key doesn't sit here-and-there in memory. * * Confirm but... the `privateKeyForSigning` has NOTHING to do with the User's paperKey. */ typedef struct { BREthereumDISMessageIdentifier identifier; union { BREthereumDISMessagePing ping; BREthereumDISMessagePong pong; BREthereumDISMessageFindNeighbors findNeighbors; BREthereumDISMessageNeighbors neighbors; } u; BRKey privateKeyForSigning; } BREthereumDISMessage; extern BRRlpItem messageDISEncode (BREthereumDISMessage message, BREthereumMessageCoder coder); extern BREthereumDISMessage messageDISDecode (BRRlpItem item, BREthereumMessageCoder coder); extern void messageDISRelease (BREthereumDISMessage *message); #ifdef __cplusplus } #endif #endif /* BR_Ethereum_Message_DIS_H */
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/contract/BREthereumToken.c
// // BREthereumToken // breadwallet-core Ethereum // // Created by <NAME> on 2/25/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // // See the LICENSE file at the project root for license information. // See the CONTRIBUTORS file at the project root for a list of contributors. #include <string.h> #include "support/BRArray.h" #include "support/BRSet.h" #include "BREthereumToken.h" #define TOKEN_DEFAULT_INITIALIZATION_COUNT (100) // // Token // struct BREthereumTokenRecord { /** * An Ethereum raw address - for BRSet *must* be first. */ BREthereumAddress raw; /** * An Ethereum '0x' address for the token's contract. */ char *address; /** * The (exchange) symbol - "BRD" */ char *symbol; /** * The name - "Bread Token" */ char *name; /** * The description - "The Bread Token ..." */ char *description; /** * The maximum decimals (typically 0 to 18). */ unsigned int decimals; /** * The (default) Gas Limit for exchanges of this token. */ BREthereumGas gasLimit; // TODO: Feels modifiable /** * The (default) Gas Price for exchanges of this token. */ BREthereumGasPrice gasPrice; // TODO: Feels modifiable /** * True(1) if allocated statically */ int staticallyAllocated; }; extern BREthereumAddress tokenGetAddressRaw (BREthereumToken token) { return token->raw; } extern const char * tokenGetAddress(BREthereumToken token) { return token->address; } extern const char * tokenGetSymbol(BREthereumToken token) { return token->symbol; } extern const char * tokenGetName(BREthereumToken token) { return token->name; } extern const char * tokenGetDescription(BREthereumToken token) { return token->description; } extern int tokenGetDecimals(BREthereumToken token) { return token->decimals; } extern BREthereumGas tokenGetGasLimit(BREthereumToken token) { return token->gasLimit; } extern BREthereumGasPrice tokenGetGasPrice(BREthereumToken token) { return token->gasPrice; } extern BREthereumContract tokenGetContract(BREthereumToken token) { return contractERC20; } static inline size_t tokenHashValue (const void *t) { return addressHashValue(((BREthereumToken) t)->raw); } static inline int tokenHashEqual (const void *t1, const void *t2) { return t1 == t2 || addressHashEqual (((BREthereumToken) t1)->raw, ((BREthereumToken) t2)->raw); } // // Token Quantity // extern BREthereumTokenQuantity createTokenQuantity(BREthereumToken token, UInt256 valueAsInteger) { assert (NULL != token); BREthereumTokenQuantity quantity; quantity.token = token; quantity.valueAsInteger = valueAsInteger; return quantity; } extern BREthereumTokenQuantity createTokenQuantityString(BREthereumToken token, const char *number, BREthereumTokenQuantityUnit unit, BRCoreParseStatus *status) { UInt256 valueAsInteger; if ((TOKEN_QUANTITY_TYPE_DECIMAL == unit && CORE_PARSE_OK != parseIsDecimal(number)) || (TOKEN_QUANTITY_TYPE_INTEGER == unit && CORE_PARSE_OK != parseIsInteger(number))) { *status = CORE_PARSE_STRANGE_DIGITS; valueAsInteger = UINT256_ZERO; } else { valueAsInteger = (TOKEN_QUANTITY_TYPE_DECIMAL == unit ? createUInt256ParseDecimal(number, token->decimals, status) : createUInt256Parse(number, 10, status)); } return createTokenQuantity(token, (CORE_PARSE_OK != *status ? UINT256_ZERO : valueAsInteger)); } extern const BREthereumToken tokenQuantityGetToken(BREthereumTokenQuantity quantity) { return quantity.token; } extern char * tokenQuantityGetValueString(const BREthereumTokenQuantity quantity, BREthereumTokenQuantityUnit unit) { return TOKEN_QUANTITY_TYPE_INTEGER == unit ? coerceString(quantity.valueAsInteger, 10) : coerceStringDecimal(quantity.valueAsInteger, quantity.token->decimals); } extern BREthereumComparison tokenQuantityCompare(BREthereumTokenQuantity q1, BREthereumTokenQuantity q2, int *typeMismatch) { *typeMismatch = (q1.token != q2.token); if (*typeMismatch) return ETHEREUM_COMPARISON_GT; switch (compareUInt256(q1.valueAsInteger, q2.valueAsInteger)) { case -1: return ETHEREUM_COMPARISON_LT; case 0: return ETHEREUM_COMPARISON_EQ; case +1: return ETHEREUM_COMPARISON_GT; default: return ETHEREUM_COMPARISON_GT; } } /* {"code":"SNGLS","colors":["FAFAFA","FAFAFA"],"name":"Singular DTV","decimal":"0","address":"0xaeC2E87E0A235266D9C5ADc9DEb4b2E29b54D009"} var tokensInJSONToC = function (tokens) { return "static struct BREthereumTokenRecord tokens[] = \n{" + tokens.map (function (token) { return ` { "${token.address}", "${token.code}", "${token.name}", "", ${token.decimal}, "${token.colors[0]}", "${token.colors[1]}", { TOKEN_BRD_DEFAULT_GAS_LIMIT }, { { { .u64 = {TOKEN_BRD_DEFAULT_GAS_PRICE_IN_WEI_UINT64, 0, 0, 0}}}}, 1 }`}) .join (",\n") + "\n};" } var result = tokensInJSONToC (tokens); console.log (result) */ static BRSet *tokenSet = NULL; static void tokenInitializeIfAppropriate (void) { if (NULL == tokenSet) { tokenSet = BRSetNew(tokenHashValue, tokenHashEqual, TOKEN_DEFAULT_INITIALIZATION_COUNT); } } extern BREthereumToken tokenLookupByAddress (BREthereumAddress address) { tokenInitializeIfAppropriate(); return (BREthereumToken) BRSetGet(tokenSet, &address); } extern BREthereumToken tokenLookup(const char *address) { return ((NULL == address || '\0' == address[0]) ? NULL : tokenLookupByAddress (addressCreate(address))); } extern int tokenCount() { tokenInitializeIfAppropriate(); return (int) BRSetCount (tokenSet); } extern BREthereumToken * tokenGetAll (void) { int tokensCount = tokenCount(); BREthereumToken *tokens = calloc (tokensCount, sizeof (BREthereumToken)); BRSetAll (tokenSet, (void**) tokens, tokensCount); return tokens; } extern void tokenInstall (const char *address, const char *symbol, const char *name, const char *description, int decimals, BREthereumGas defaultGasLimit, BREthereumGasPrice defaultGasPrice) { BREthereumAddress raw = addressCreate (address); BREthereumToken token = tokenLookupByAddress (raw); if (NULL == token) { token = malloc (sizeof(struct BREthereumTokenRecord)); token->address = strdup (address); token->symbol = strdup (symbol); token->name = strdup (name); token->description = strdup (description); token->decimals = decimals; token->gasLimit = defaultGasLimit; token->gasPrice = defaultGasPrice; token->raw = raw; BRSetAdd (tokenSet, token); } else { if (0 != strcasecmp (address , token->address )) { free (token->address ); token->address = strdup (address ); } if (0 != strcasecmp (symbol , token->symbol )) { free (token->symbol ); token->symbol = strdup (symbol ); } if (0 != strcasecmp (name , token->name )) { free (token->name ); token->name = strdup (name ); } if (0 != strcasecmp (description, token->description)) { free (token->description); token->description = strdup (description); } token->decimals = decimals; token->gasLimit = defaultGasLimit; token->gasPrice = defaultGasPrice; } }
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/blockchain/BREthereumBloomFilter.c
// // BREthereumBloomFilter.c // BRCore // // Created by <NAME> on 5/10/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // // See the LICENSE file at the project root for license information. // See the CONTRIBUTORS file at the project root for a list of contributors. #include <assert.h> #include <string.h> #include "BREthereumBloomFilter.h" /* Forward Declarations */ static void bloomFilterExtractLocation (unsigned int index, unsigned int *byteIndex, unsigned int *bitIndex); static void bloomFilterSetBit (BREthereumBloomFilter *filter, unsigned int index); static void bloomFilterClrBit (BREthereumBloomFilter *filter, unsigned int index); static unsigned int bloomFilterCreateIndex (uint8_t highByte, uint8_t lowByte); // // An Empty BloomFilter // static BREthereumBloomFilter empty; extern BREthereumBloomFilter bloomFilterCreateEmpty (void) { return empty; } /** * 'Designated Contructor' for BloomFilter */ extern BREthereumBloomFilter bloomFilterCreateHash (const BREthereumHash hash) { BREthereumBloomFilter filter = empty; bloomFilterSetBit(&filter, bloomFilterCreateIndex(hash.bytes[0], hash.bytes[1])); bloomFilterSetBit(&filter, bloomFilterCreateIndex(hash.bytes[2], hash.bytes[3])); bloomFilterSetBit(&filter, bloomFilterCreateIndex(hash.bytes[4], hash.bytes[5])); return filter; } extern BREthereumBloomFilter bloomFilterCreateData (const BRRlpData data) { return bloomFilterCreateHash(hashCreateFromData(data)); } extern BREthereumBloomFilter bloomFilterCreateAddress (const BREthereumAddress address) { BRRlpData data; data.bytes = (uint8_t *) address.bytes; data.bytesCount = sizeof (address.bytes); return bloomFilterCreateHash(hashCreateFromData(data)); } extern BREthereumBloomFilter bloomFilterCreateString (const char *string) { BREthereumBloomFilter filter; if (0 == strncmp ("0x", string, 2)) string = &string[2]; decodeHex (filter.bytes, sizeof (filter.bytes), string, strlen(string)); return filter; } extern BREthereumBloomFilter bloomFilterOr (const BREthereumBloomFilter filter1, const BREthereumBloomFilter filter2) { BREthereumBloomFilter result = empty; for (int i = 0; i < ETHEREUM_BLOOM_FILTER_BYTES; i++) result.bytes[i] = filter1.bytes[i] | filter2.bytes[i]; return result; } extern void bloomFilterOrInPlace (BREthereumBloomFilter filter1, const BREthereumBloomFilter filter2) { for (int i = 0; i < ETHEREUM_BLOOM_FILTER_BYTES; i++) filter1.bytes[i] |= filter2.bytes[i]; } extern BREthereumBoolean bloomFilterEqual (const BREthereumBloomFilter filter1, const BREthereumBloomFilter filter2) { return (0 == memcmp (filter1.bytes, filter2.bytes, ETHEREUM_BLOOM_FILTER_BYTES) ? ETHEREUM_BOOLEAN_TRUE : ETHEREUM_BOOLEAN_FALSE); } extern BREthereumBoolean bloomFilterMatch (const BREthereumBloomFilter filter, const BREthereumBloomFilter other) { return bloomFilterEqual(filter, bloomFilterOr(filter, other)); } // // RLP Encode / Decoe // extern BRRlpItem bloomFilterRlpEncode(BREthereumBloomFilter filter, BRRlpCoder coder) { return rlpEncodeBytes(coder, filter.bytes, 256); } extern BREthereumBloomFilter bloomFilterRlpDecode (BRRlpItem item, BRRlpCoder coder) { BREthereumBloomFilter filter; BRRlpData data = rlpDecodeBytes(coder, item); assert (256 == data.bytesCount); memcpy (filter.bytes, data.bytes, 256); rlpDataRelease(data); return filter; } // // As String // extern char * bloomFilterAsString (BREthereumBloomFilter filter) { return encodeHexCreate(NULL, filter.bytes, sizeof (filter.bytes)); } // // Support // /** * Extract the byte and bit position of `index` within ETHEREUM_BLOOM_FILTER_BITS. `index` * is [0, ETHEREUM_BLOOM_FILTER_BITS). * */ static void bloomFilterExtractLocation (unsigned int index, unsigned int *byteIndex, unsigned int *bitIndex) { assert (index < ETHEREUM_BLOOM_FILTER_BITS); assert (NULL != byteIndex && NULL != bitIndex); *byteIndex = (ETHEREUM_BLOOM_FILTER_BITS - 1 - index ) / 8; *bitIndex = index % 8; } static void bloomFilterSetBit (BREthereumBloomFilter *filter, unsigned int index) { unsigned int byteIndex; unsigned int bitIndex; bloomFilterExtractLocation(index, &byteIndex, &bitIndex); filter->bytes[byteIndex] |= (1 << bitIndex); } #pragma clang diagnostic push #pragma GCC diagnostic push #pragma clang diagnostic ignored "-Wunused-function" #pragma GCC diagnostic ignored "-Wunused-function" static void bloomFilterClrBit (BREthereumBloomFilter *filter, unsigned int index) { unsigned int byteIndex; unsigned int bitIndex; bloomFilterExtractLocation(index, &byteIndex, &bitIndex); filter->bytes[byteIndex] &= ~(1 << bitIndex); } #pragma clang diagnostic pop #pragma GCC diagnostic pop #define ETHERUM_BLOOM_FILTER_BITS_MASK (ETHEREUM_BLOOM_FILTER_BITS - 1) static unsigned int bloomFilterCreateIndex (uint8_t highByte, uint8_t lowByte) { return ((highByte << 8) | lowByte) & ETHERUM_BLOOM_FILTER_BITS_MASK; }
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
SDK/P2P/PeerInfo.h
// Copyright (c) 2012-2018 The Elastos Open Source Project // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef __ELASTOS_SDK_PEERINFO_H__ #define __ELASTOS_SDK_PEERINFO_H__ #include <Common/uint256.h> #include <sys/types.h> #include <string> #define SERVICES_NODE_NETWORK 0x01 // services value indicating a node carries full blocks, not just headers #define SERVICES_NODE_BLOOM 0x04 // BIP111: https://github.com/bitcoin/bips/blob/master/bip-0111.mediawiki #define SERVICES_NODE_BCASH 0x20 // https://github.com/Bitcoin-UAHF/spec/blob/master/uahf-technical-spec.md namespace Elastos { namespace ElaWallet { struct PeerInfo { uint128 Address; // IPv6 address of peer uint16_t Port; // port number for peer connection uint64_t Services; // bitcoin network services supported by peer uint64_t Timestamp; // timestamp reported by peer uint8_t Flags; // scratch variable PeerInfo(); PeerInfo(const uint128 &addr, uint16_t port, uint64_t timestamp); PeerInfo(const uint128 &addr, uint16_t port, uint64_t timestamp, uint64_t services); PeerInfo(const PeerInfo &peerInfo); PeerInfo &operator=(const PeerInfo &peerInfo); bool operator==(const PeerInfo &info) const; bool operator<(const PeerInfo &info) const; bool operator!=(const PeerInfo &info) const; size_t GetHash() const; bool IsIPv4() const; std::string GetHost() const; }; } } #endif //__ELASTOS_SDK_PEERINFO_H__
fakecoinbase/elastosslashElastos.ELA.SPV.Cpp
ThirdParty/breadwallet-core/ethereum/event/BREvent.c
// // BREvent.c // BRCore // // Created by <NAME> on 5/7/18. // Copyright ยฉ 2018 Breadwinner AG. All rights reserved. // // See the LICENSE file at the project root for license information. // See the CONTRIBUTORS file at the project root for a list of contributors. #include <string.h> #include <errno.h> #include <pthread.h> #include <sys/time.h> #include <assert.h> #include "BREvent.h" #include "BREventQueue.h" #include "BREventAlarm.h" #define PTHREAD_NULL ((pthread_t) NULL) #define PTHREAD_STACK_SIZE (512 * 1024) #define PTHREAD_NAME_SIZE (33) /* Forward Declarations */ static void * eventHandlerThread (BREventHandler handler); // // Event Handler // struct BREventHandlerRecord { char name[PTHREAD_NAME_SIZE]; // Types size_t typesCount; const BREventType **types; // Queue size_t eventSize; BREventQueue queue; BREvent *scratch; // (Optional) Timeout /// /// The Handler specific timeout event - `filled` with the dispatcher //// BREventType timeoutEventType; /// /// The Handler specific timeout context. /// BREventTimeoutContext timeoutContext; /// /// The timeout period /// struct timespec timeout; /// /// The timeout alarm id, if one exists /// BREventAlarmId timeoutAlarmId; // Pthread pthread_t thread; pthread_cond_t cond; pthread_mutex_t lock; pthread_mutex_t lockOnStartStop; pthread_mutex_t *lockToUse; // Boolean to identify if the thread should quit. int threadQuit; }; extern BREventHandler eventHandlerCreate (const char *name, const BREventType *types[], unsigned int typesCount, pthread_mutex_t *lock) { BREventHandler handler = calloc (1, sizeof (struct BREventHandlerRecord)); // Fill in the timeout event. Leave the dispatcher NULL until the dispatcher is provided. handler->timeoutEventType.eventName = "Timeout Event"; handler->timeoutEventType.eventSize = sizeof(BREventTimeout); handler->timeoutEventType.eventDispatcher = NULL; // Handle the event types. Ensure we account for the (implicit) timeout event. handler->typesCount = typesCount; handler->types = types; handler->eventSize = handler->timeoutEventType.eventSize; strncpy (handler->name, name, PTHREAD_NAME_SIZE); handler->name[PTHREAD_NAME_SIZE - 1] = '\0'; // Update `eventSize` with the largest sized event for (int i = 0; i < handler->typesCount; i++) { const BREventType *type = handler->types[i]; if (handler->eventSize < type->eventSize) handler->eventSize = type->eventSize; } handler->timeoutAlarmId = ALARM_ID_NONE; // Create the PTHREAD CONDition variable { pthread_condattr_t attr; pthread_condattr_init(&attr); pthread_cond_init(&handler->cond, &attr); pthread_condattr_destroy(&attr); } // Create the PTHREAD LOCK variable if (NULL != lock) handler->lockToUse = lock; else { // The cacheLock is a normal, non-recursive lock pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); pthread_mutex_init(&handler->lock, &attr); pthread_mutexattr_destroy(&attr); handler->lockToUse = &handler->lock; } // Create the PTHREAD LOCK-ON-START-STOP variable { // The cacheLock is a normal, non-recursive lock pthread_mutexattr_t attr; pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL); pthread_mutex_init(&handler->lockOnStartStop, &attr); pthread_mutexattr_destroy(&attr); } handler->thread = PTHREAD_NULL; handler->scratch = (BREvent*) calloc (1, handler->eventSize); handler->queue = eventQueueCreate (handler->eventSize); return handler; } extern void eventHandlerSetTimeoutDispatcher (BREventHandler handler, unsigned int timeInMilliseconds, BREventDispatcher dispatcher, BREventTimeoutContext context) { pthread_mutex_lock (handler->lockToUse); handler->timeout.tv_sec = timeInMilliseconds / 1000; handler->timeout.tv_nsec = 1000000 * (timeInMilliseconds % 1000); handler->timeoutContext = context; handler->timeoutEventType.eventDispatcher = dispatcher; pthread_mutex_unlock (handler->lockToUse); // Signal an event - so that the 'timedwait' starts. pthread_cond_signal(&handler->cond); } static void eventHandlerAlarmCallback (BREventHandler handler, struct timespec expiration, BREventAlarmClock clock) { BREventTimeout event = { { NULL, &handler->timeoutEventType }, handler->timeoutContext, expiration}; eventHandlerSignalEventOOB (handler, (BREvent*) &event); } typedef void* (*ThreadRoutine) (void*); static void * eventHandlerThread (BREventHandler handler) { #if defined (__DARWIN__) pthread_setname_np(handler->name); #else pthread_setname_np(handler->thread, handler->name); #endif pthread_mutex_lock (handler->lockToUse); handler->threadQuit = 0; while (!handler->threadQuit) { // Check for a queued event switch (eventQueueDequeue(handler->queue, handler->scratch)) { case EVENT_STATUS_SUCCESS: { // If we have one, dispatch BREventType *type = handler->scratch->type; type->eventDispatcher (handler, handler->scratch); break; } case EVENT_STATUS_NOT_STARTED: case EVENT_STATUS_UNKNOWN_TYPE: case EVENT_STATUS_NULL_EVENT: // impossible? // fall through case EVENT_STATUS_NONE_PENDING: // ... otherwise wait for an event ... pthread_cond_wait(&handler->cond, handler->lockToUse); break; } } // Requires as `cond_wait` takes its mutex when signalled. pthread_mutex_unlock (handler->lockToUse); return NULL; } extern void eventHandlerDestroy (BREventHandler handler) { // First stop... eventHandlerStop(handler); // ... then kill assert (PTHREAD_NULL == handler->thread); pthread_cond_destroy(&handler->cond); if (handler->lockToUse == &handler->lock) pthread_mutex_destroy(&handler->lock); pthread_mutex_destroy(&handler->lockOnStartStop); // release memory eventQueueDestroy(handler->queue); free (handler->scratch); free (handler); } // // Start / Stop // /** * Start the handler. It is possible that events will already be queued; they will all be * dispatched, in FIFO order. If there is a periodic alarm; it will be added to the alarmClock. * * @param handler */ extern void eventHandlerStart (BREventHandler handler) { alarmClockCreateIfNecessary(1); pthread_mutex_lock(&handler->lockOnStartStop); if (PTHREAD_NULL == handler->thread) { // If we have an timeout event dispatcher, then add an alarm. if (NULL != handler->timeoutEventType.eventDispatcher) { handler->timeoutAlarmId = alarmClockAddAlarmPeriodic (alarmClock, (BREventAlarmContext) handler, (BREventAlarmCallback) eventHandlerAlarmCallback, handler->timeout); } // Spawn the eventHandlerThread { pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); pthread_attr_setstacksize(&attr, PTHREAD_STACK_SIZE); pthread_create(&handler->thread, &attr, (ThreadRoutine) eventHandlerThread, handler); pthread_attr_destroy(&attr); } } pthread_mutex_unlock(&handler->lockOnStartStop); } /** * Stop the handler. This will clear all pending events. If there is a periodic alarm, it will * be removed from the alarmClock. * * @note There is a tiny race here, I think. Before this function returns and after the queue * has been cleared, another event can be added. This is prevented by stopping the threads that * submit to this queue before stopping this queue's thread. Or prior to a subsequent start, * clear this handler (But, `eventHandlerStart()` does not clear the thread on start.) * * @param handler */ extern void eventHandlerStop (BREventHandler handler) { pthread_mutex_lock(&handler->lockOnStartStop); if (PTHREAD_NULL != handler->thread) { pthread_mutex_lock (handler->lockToUse); // Remove a timeout alarm, if it exists. if (ALARM_ID_NONE != handler->timeoutAlarmId) { alarmClockRemAlarm (alarmClock, handler->timeoutAlarmId); handler->timeoutAlarmId = ALARM_ID_NONE; } // Quit the thread. handler->threadQuit = 1; pthread_cond_signal(&handler->cond); pthread_mutex_unlock (handler->lockToUse); pthread_join(handler->thread, NULL); // A mini-race here? handler->thread = PTHREAD_NULL; // Empty the queue completely. eventHandlerClear (handler); } pthread_mutex_unlock(&handler->lockOnStartStop); } extern int eventHandlerIsRunning (BREventHandler handler) { return PTHREAD_NULL != handler->thread; } extern BREventStatus eventHandlerSignalEvent (BREventHandler handler, BREvent *event) { eventQueueEnqueueTail(handler->queue, event); pthread_cond_signal(&handler->cond); return EVENT_STATUS_SUCCESS; } extern BREventStatus eventHandlerSignalEventOOB (BREventHandler handler, BREvent *event) { eventQueueEnqueueHead(handler->queue, event); pthread_cond_signal(&handler->cond); return EVENT_STATUS_SUCCESS; } extern void eventHandlerClear (BREventHandler handler) { eventQueueClear(handler->queue); }