Skip to content

Commit

Permalink
fix build fail on ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
heropan committed May 9, 2020
1 parent 242cca3 commit ae7be48
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 40 deletions.
5 changes: 4 additions & 1 deletion CMake/ProjectDefaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE "Release")
endif()

string(TOUPPER ${CMAKE_SYSTEM_NAME} PLATFORM_MARCO)
add_definitions(-D__${PLATFORM_MARCO}__)

if(NOT CMAKE_CROSSCOMPILING)
string(TOUPPER ${CMAKE_SYSTEM_NAME} CANONICAL_SYSTEM_NAME)
set(${CANONICAL_SYSTEM_NAME} TRUE)
Expand Down Expand Up @@ -134,4 +137,4 @@ function(export_shared_library MODULE_NAME)

install(PROGRAMS "${SHARED_LIBRARY_NAME}"
DESTINATION ${_INSTALL_DESTINATION})
endfunction()
endfunction()
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ execute_process(
project(Elastos-spvsdk VERSION ${SPVSDK_VERSION})

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_STANDARD 11)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
include(ProjectDefaults)
include(DistPackage)
Expand Down
4 changes: 1 addition & 3 deletions SDK/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ foreach(src ${BRETH_SOURCE_FILES})
endif()
endforeach()

set(SPVSDK_SOURCE_FILES
${SPVSDK_SOURCE_FILES}
${BRETH_SOURCE_FILES_REMOVE_TEST})
set(SPVSDK_SOURCE_FILES ${BRETH_SOURCE_FILES_REMOVE_TEST} ${SPVSDK_SOURCE_FILES})

set(SPVSDK_DEPENDS boost libressl libfruit libsqlite json libspdlog secp256k1)
set(LIBS boost_filesystem boost_system boost_thread crypto ssl fruit sqlite3 spdlog)
Expand Down
20 changes: 10 additions & 10 deletions ThirdParty/breadwallet-core/ethereum/blockchain/BREthereumBlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -1625,27 +1625,27 @@ initializeGenesisBlocks (void) {

/// MARK: - Block Checkpoint

static BREthereumBlockCheckpoint
BREthereumBlockCheckpoint
ethereumMainnetCheckpoints [] = {
{ 0, HASH_INIT("d4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"), { .std = "17179869184" }, 0 },
{ 4000000, HASH_INIT("b8a3f7f5cfc1748f91a684f20fe89031202cbadcd15078c49b85ec2a57f43853"), { .std = "469024977881526938386" }, 1499633567 },
{ 4500000, HASH_INIT("43340a6d232532c328211d8a8c0fa84af658dbff1f4906ab7a7d4e41f82fe3a3"), { .std = "1386905480746946772236" }, 1509953783 },
{ 5000000, HASH_INIT("7d5a4369273c723454ac137f48a4f142b097aa2779464e6505f1b1c5e37b5382"), { .std = "2285199027754071740498" }, 1517319693 },
{ 5500000, HASH_INIT("2d3a154eee9f90666c6e824f11e15f2d60b05323a81254f60075c34a61ef124d"), { .std = "3825806101695195923560" }, 1524611221 },
{ 6000000, HASH_INIT("be847be2bceb74e660daf96b3f0669d58f59dc9101715689a00ef864a5408f43"), { .std = "5484495551037046114587" }, 1532118564 },
{ 6500000, HASH_INIT("70c81c3cb256b5b930f05b244d095cb4845e9808c48d881e3cc31d18ae4c3ae5"), { .std = "7174074700595750315193" }, 1539330275 },
{ 0, "\xd4\xe5\x67\x40\xf8\x76\xae\xf8\xc0\x10\xb8\x6a\x40\xd5\xf5\x67\x45\xa1\x18\xd0\x90\x6a\x34\xe6\x9a\xec\x8c\x0d\xb1\xcb\x8f\xa3", { .std = "17179869184" }, 0 },
{ 4000000, "\xb8\xa3\xf7\xf5\xcf\xc1\x74\x8f\x91\xa6\x84\xf2\x0f\xe8\x90\x31\x20\x2c\xba\xdc\xd1\x50\x78\xc4\x9b\x85\xec\x2a\x57\xf4\x38\x53", { .std = "469024977881526938386" }, 1499633567 },
{ 4500000, "\x43\x34\x0a\x6d\x23\x25\x32\xc3\x28\x21\x1d\x8a\x8c\x0f\xa8\x4a\xf6\x58\xdb\xff\x1f\x49\x06\xab\x7a\x7d\x4e\x41\xf8\x2f\xe3\xa3", { .std = "1386905480746946772236" }, 1509953783 },
{ 5000000, "\x7d\x5a\x43\x69\x27\x3c\x72\x34\x54\xac\x13\x7f\x48\xa4\xf1\x42\xb0\x97\xaa\x27\x79\x46\x4e\x65\x05\xf1\xb1\xc5\xe3\x7b\x53\x82", { .std = "2285199027754071740498" }, 1517319693 },
{ 5500000, "\x2d\x3a\x15\x4e\xee\x9f\x90\x66\x6c\x6e\x82\x4f\x11\xe1\x5f\x2d\x60\xb0\x53\x23\xa8\x12\x54\xf6\x00\x75\xc3\x4a\x61\xef\x12\x4d", { .std = "3825806101695195923560" }, 1524611221 },
{ 6000000, "\xbe\x84\x7b\xe2\xbc\xeb\x74\xe6\x60\xda\xf9\x6b\x3f\x06\x69\xd5\x8f\x59\xdc\x91\x01\x71\x56\x89\xa0\x0e\xf8\x64\xa5\x40\x8f\x43", { .std = "5484495551037046114587" }, 1532118564 },
{ 6500000, "\x70\xc8\x1c\x3c\xb2\x56\xb5\xb9\x30\xf0\x5b\x24\x4d\x09\x5c\xb4\x84\x5e\x98\x08\xc4\x8d\x88\x1e\x3c\xc3\x1d\x18\xae\x4c\x3a\xe5", { .std = "7174074700595750315193" }, 1539330275 },
};
#define CHECKPOINT_MAINNET_COUNT (sizeof (ethereumMainnetCheckpoints) / sizeof (BREthereumBlockCheckpoint))

static BREthereumBlockCheckpoint
ethereumTestnetCheckpoints [] = {
{ 0, HASH_INIT("41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d"), { .std = "0x100000" }, 0 }, // 1061 days 6 hrs ago (Jul-30-2015 03:26:13 PM +UTC)
{ 0, "\x41\x94\x10\x23\x68\x09\x23\xe0\xfe\x4d\x74\xa3\x4b\xda\xc8\x14\x1f\x25\x40\xe3\xae\x90\x62\x37\x18\xe4\x7d\x66\xd1\xca\x4a\x2d", { .std = "0x100000" }, 0 }, // 1061 days 6 hrs ago (Jul-30-2015 03:26:13 PM +UTC)
};
#define CHECKPOINT_TESTNET_COUNT (sizeof (ethereumTestnetCheckpoints) / sizeof (BREthereumBlockCheckpoint))

static BREthereumBlockCheckpoint
ethereumRinkebyCheckpoints [] = {
{ 0, HASH_INIT("6341fd3daf94b748c72ced5a5b26028f2474f5f00d824504e4fa37a75767e177"), { .std = "0x01" }, 0x58ee40ba }, // 439 days 6 hrs ago (Apr-12-2017 03:20:50 PM +UTC)
{ 0, "\x63\x41\xfd\x3d\xaf\x94\xb7\x48\xc7\x2c\xed\x5a\x5b\x26\x02\x8f\x24\x74\xf5\xf0\x0d\x82\x45\x04\xe4\xfa\x37\xa7\x57\x67\xe1\x77", { .std = "0x01" }, 0x58ee40ba }, // 439 days 6 hrs ago (Apr-12-2017 03:20:50 PM +UTC)
};
#define CHECKPOINT_RINKEBY_COUNT (sizeof (ethereumRinkebyCheckpoints) / sizeof (BREthereumBlockCheckpoint))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// See the CONTRIBUTORS file at the project root for a list of contributors.

#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "BREthereumTransactionStatus.h"

Expand Down Expand Up @@ -59,7 +60,8 @@ transactionStatusCreateErrored (BREthereumTransactionErrorType type,
BREthereumTransactionStatus status;
status.type = TRANSACTION_STATUS_ERRORED;
status.u.errored.type = type;
strlcpy (status.u.errored.detail, detail, TRANSACTION_STATUS_DETAIL_BYTES);
strncpy (status.u.errored.detail, detail, sizeof(status.u.errored.detail));
status.u.errored.detail[TRANSACTION_STATUS_DETAIL_BYTES] = '\0';
return status;
}

Expand Down
9 changes: 5 additions & 4 deletions ThirdParty/breadwallet-core/ethereum/event/BREvent.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ eventHandlerCreate (const char *name,
handler->types = types;
handler->eventSize = handler->timeoutEventType.eventSize;

strlcpy (handler->name, name, PTHREAD_NAME_SIZE);
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++) {
Expand Down Expand Up @@ -174,10 +175,10 @@ typedef void* (*ThreadRoutine) (void*);
static void *
eventHandlerThread (BREventHandler handler) {

#if defined (__ANDROID__)
pthread_setname_np(handler->thread, handler->name);
#else
#if defined (__DARWIN__)
pthread_setname_np(handler->name);
#else
pthread_setname_np(handler->thread, handler->name);
#endif

pthread_mutex_lock (handler->lockToUse);
Expand Down
6 changes: 3 additions & 3 deletions ThirdParty/breadwallet-core/ethereum/event/BREventAlarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ typedef void* (*ThreadRoutine) (void*);
static void *
alarmClockThread (BREventAlarmClock clock) {

#if defined (__ANDROID__)
pthread_setname_np(clock->thread, "Core Ethereum Alarm Clock");
#else
#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);
Expand Down
6 changes: 3 additions & 3 deletions ThirdParty/breadwallet-core/ethereum/les/BREthereumLES.c
Original file line number Diff line number Diff line change
Expand Up @@ -1113,10 +1113,10 @@ lesThreadBootstrapSeeds (BREthereumLES les) {

static void *
lesThread (BREthereumLES les) {
#if defined (__ANDROID__)
pthread_setname_np (les->thread, LES_THREAD_NAME);
#else
#if defined (__DARWIN__)
pthread_setname_np (LES_THREAD_NAME);
#else
pthread_setname_np (les->thread, LES_THREAD_NAME);
#endif
// TODO: Don't timeout pselect(); get some 'wakeup descriptor'
struct timespec timeout = { 0, 250000000 }; // .250 seconds
Expand Down
8 changes: 4 additions & 4 deletions ThirdParty/breadwallet-core/ethereum/les/BREthereumNode.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ nodeSend (BREthereumNode node,
#define HEPUBLIC_BYTES 32
#define NONCE_BYTES 32

static const ssize_t authBufLen = SIG_SIZE_BYTES + HEPUBLIC_BYTES + PUBLIC_SIZE_BYTES + NONCE_BYTES + 1;
static const ssize_t authCipherBufLen = authBufLen + 65 + 16 + 32;
#define authBufLen (SIG_SIZE_BYTES + HEPUBLIC_BYTES + PUBLIC_SIZE_BYTES + NONCE_BYTES + 1)
#define authCipherBufLen (authBufLen + 65 + 16 + 32)

static const ssize_t ackBufLen = PUBLIC_SIZE_BYTES + NONCE_BYTES + 1;
static const ssize_t ackCipherBufLen = ackBufLen + 65 + 16 + 32;
#define ackBufLen (PUBLIC_SIZE_BYTES + NONCE_BYTES + 1)
#define ackCipherBufLen (ackBufLen + 65 + 16 + 32)

//
static int _sendAuthInitiator(BREthereumNode node);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ neighborDISAsEnode (BREthereumDISNeighbor neighbor,
char nodeID [129];
encodeHex(nodeID, 129, &neighbor.key.pubKey[1], 64);

char IP [39];
char IP [139];
if (neighbor.node.domain == AF_INET)
sprintf (IP, "%d.%d.%d.%d",
neighbor.node.addr.ipv4[0],
Expand Down
1 change: 1 addition & 0 deletions ThirdParty/breadwallet-core/ethereum/util/BRUtilHex.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define BR_Util_Hex_H

#include <stdlib.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
Expand Down
6 changes: 3 additions & 3 deletions ThirdParty/breadwallet-core/support/BRAssert.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ typedef void* (*ThreadRoutine) (void*); // pthread_create

static void *
BRAssertThread (BRAssertContext *context) {
#if defined (__ANDROID__)
pthread_setname_np (context->thread, ASSERT_THREAD_NAME);
#else
#if defined (__DARWIN__)
pthread_setname_np (ASSERT_THREAD_NAME);
#else
pthread_setname_np (context->thread, ASSERT_THREAD_NAME);
#endif

pthread_mutex_lock(&context->lock);
Expand Down
12 changes: 6 additions & 6 deletions ThirdParty/breadwallet-core/support/BRKeyECIES.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ size_t BRKeyECIESAES128SHA256Encrypt(BRKey *pubKey, void *out, size_t outLen, BR
// encrypt
BRSHA256(buf, data, dataLen);
BRHMACDRBG(iv, sizeof(iv), K, V, BRSHA256, 32, encKey, 16, buf, 32, NULL, 0); // generate iv
memcpy(&out[pkLen], iv, sizeof(iv));
BRAESCTR(&out[pkLen + sizeof(iv)], encKey, 16, iv, data, dataLen);
memcpy(&((uint8_t*)out)[pkLen], iv, sizeof(iv));
BRAESCTR(&((uint8_t*)out)[pkLen + sizeof(iv)], encKey, 16, iv, data, dataLen);
mem_clean(shared, sizeof(shared));

// tag with mac
BRHMAC(&out[pkLen + sizeof(iv) + dataLen], BRSHA256, 32, macKey, 32, &out[pkLen], sizeof(iv) + dataLen);
BRHMAC(&((uint8_t*)out)[pkLen + sizeof(iv) + dataLen], BRSHA256, 32, macKey, 32, &((uint8_t*)out)[pkLen], sizeof(iv) + dataLen);
mem_clean(macKey, sizeof(macKey));
return pkLen + sizeof(iv) + dataLen + 32;
}
Expand All @@ -88,15 +88,15 @@ size_t BRKeyECIESAES128SHA256Decrypt(BRKey *privKey, void *out, size_t outLen, c
BRSHA256(macKey, &shared[16], 16);

// verify mac tag
BRHMAC(mac, BRSHA256, 32, macKey, 32, &data[pkLen], dataLen - (pkLen + 32));
BRHMAC(mac, BRSHA256, 32, macKey, 32, &((uint8_t*)data)[pkLen], dataLen - (pkLen + 32));
mem_clean(macKey, sizeof(macKey));
for (i = 0; i < 32; i++) r |= mac[i] ^ ((uint8_t *)data)[dataLen + i - 32]; // constant time compare
mem_clean(mac, sizeof(mac));
if (r != 0) return 0;

// decrypt
memcpy(iv, &data[pkLen], sizeof(iv));
BRAESCTR(out, encKey, 16, iv, &data[pkLen + sizeof(iv)], dataLen - (pkLen + sizeof(iv) + 32));
memcpy(iv, &((uint8_t*)data)[pkLen], sizeof(iv));
BRAESCTR(out, encKey, 16, iv, &((uint8_t*)data)[pkLen + sizeof(iv)], dataLen - (pkLen + sizeof(iv) + 32));
mem_clean(shared, sizeof(shared));
return dataLen - (pkLen + sizeof(iv) + 32);
}
Expand Down
3 changes: 2 additions & 1 deletion Wallet/Wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2303,7 +2303,8 @@ int main(int argc, char *argv[]) {

while (1) {
fprintf(stdout, "-> wallet $ ");
fgets(cmdLine, sizeof(cmdLine), stdin);
if (NULL == fgets(cmdLine, sizeof(cmdLine), stdin))
continue;

numArgs = parseCmdLine(cmdLine, cmdArgs);
if (numArgs == 0)
Expand Down

0 comments on commit ae7be48

Please sign in to comment.