Skip to content
Snippets Groups Projects
Commit 6a99ae22 authored by Dmitriy A. Gerasimov's avatar Dmitriy A. Gerasimov
Browse files

[+] interchain communications infrastructure

[*] Converted \r\n from DOS to UNIX encoding
parent b2f12f32
No related branches found
No related tags found
No related merge requests found
Pipeline #6170 passed with stage
in 19 seconds
Showing
with 278 additions and 4 deletions
......@@ -123,6 +123,12 @@ if (CELLFRAME_MODULES MATCHES "srv-stake")
set(CELLFRAME_LIBS ${CELLFRAME_LIBS} dap_chain_net_srv_stake )
endif()
# Enable interchain exchange with BTC-like networks
if (CELLFRAME_MODULES MATCHES "inter-btc")
message("[+] Module 'inter-btc'")
set(CELLFRAME_LIBS ${CELLFRAME_LIBS} dap_chain_inter_btc )
endif()
# Enable service for dynamic modules
if (CELLFRAME_MODULES MATCHES "modules-dynamic")
message("[+] Module 'dap_modules_dynamic_cdb'")
......
......@@ -87,6 +87,11 @@ if (CELLFRAME_MODULES MATCHES "srv-stake")
add_subdirectory(service/stake)
endif()
# Interchaine communications with BTC-like networks
if (CELLFRAME_MODULES MATCHES "inter-btc")
add_subdirectory(inter/btc)
endif()
# Support for dynamic modules
if (CELLFRAME_MODULES MATCHES "modules-dynamic")
add_subdirectory(modules_dynamic)
......
......@@ -2,6 +2,9 @@ HEADERS += $$PWD/include/dap_chain_common.h \
$$PWD/include/dap_chain_datum.h \
$$PWD/include/dap_chain_datum_hashtree_roots.h \
$$PWD/include/dap_chain_datum_token.h \
$$PWD/include/dap_chain_datum_decree.h \
$$PWD/include/dap_chain_datum_vote.h \
$$PWD/include/dap_chain_datum_poll.h \
$$PWD/include/dap_chain_datum_tx.h \
$$PWD/include/dap_chain_datum_tx_in_cond.h \
$$PWD/include/dap_chain_datum_tx_in.h \
......@@ -11,10 +14,13 @@ HEADERS += $$PWD/include/dap_chain_common.h \
$$PWD/include/dap_chain_datum_tx_pkey.h \
$$PWD/include/dap_chain_datum_tx_receipt.h \
$$PWD/include/dap_chain_datum_tx_sig.h \
$$PWD/include/dap_chain_datum_tx_token.h
$$PWD/include/dap_chain_datum_tx_token.h
SOURCES += $$PWD/dap_chain_common.c \
$$PWD/dap_chain_datum.c \
$$PWD/dap_chain_datum_vote.c \
$$PWD/dap_chain_datum_poll.c \
$$PWD/dap_chain_datum_decree.c \
$$PWD/dap_chain_datum_hashtree_roots.c \
$$PWD/dap_chain_datum_token.c \
$$PWD/dap_chain_datum_tx.c \
......
......@@ -42,6 +42,7 @@ const char * c_datum_type_str[]={
[DAP_CHAIN_DATUM_CUSTOM]="DATUM_CUSTOM",
[DAP_CHAIN_DATUM_TOKEN_DECL]="DATUM_TOKEN_DECL",
[DAP_CHAIN_DATUM_TOKEN_EMISSION]="DATUM_TOKEN_EMISSION",
[DAP_CHAIN_DATUM_TOKEN_DISMISSAL]="DATUM_TOKEN_DISMISSAL",
[DAP_CHAIN_DATUM_CUSTOM] = "DAP_CHAIN_DATUM_CUSTOM"
};
......
/*
* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* Copyright (c) 2020, All rights reserved.
This file is part of CellFrame SDK the open source project
CellFrame SDK is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CellFrame SDK is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with any CellFrame SDK based project. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* Copyright (c) 2020, All rights reserved.
This file is part of CellFrame SDK the open source project
CellFrame SDK is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CellFrame SDK is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with any CellFrame SDK based project. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* Copyright (c) 2020, All rights reserved.
This file is part of CellFrame SDK the open source project
CellFrame SDK is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CellFrame SDK is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with any CellFrame SDK based project. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* CellFrame https://cellframe.net
* Sources https://gitlab.demlabs.net/cellframe
* Copyright (c) 2020
* All rights reserved.
This file is part of CellFrame SDK the open source project
CellFrame SDK is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CellFrame SDK is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with any CellFrame SDK based project. If not, see <http://www.gnu.org/licenses/>.
*/
#include "dap_chain_inter.h"
#define LOG_TAG "dap_chain_inter"
......@@ -56,9 +56,9 @@
#define DAP_CHAIN_DATUM_CA 0x0c00
/// Token
/// Simple token decl
#define DAP_CHAIN_DATUM_TOKEN_DECL 0xf000
#define DAP_CHAIN_DATUM_TOKEN_EMISSION 0xf100
#define DAP_CHAIN_DATUM_TOKEN_DISMISSAL 0xf200
#define DAP_CHAIN_DATUM_CUSTOM 0xffff
......@@ -124,6 +124,7 @@ static inline const char * dap_chain_datum_type_id_to_str(uint16_t a_type_id){
case DAP_CHAIN_DATUM_CA:
case DAP_CHAIN_DATUM_TOKEN_DECL:
case DAP_CHAIN_DATUM_TOKEN_EMISSION:
case DAP_CHAIN_DATUM_TOKEN_DISMISSAL:
case DAP_CHAIN_DATUM_CUSTOM:
return c_datum_type_str[a_type_id];
default:
......
/*
* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* Copyright (c) 2020, All rights reserved.
This file is part of CellFrame SDK the open source project
CellFrame SDK is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CellFrame SDK is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with any CellFrame SDK based project. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
/*
* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* Copyright (c) 2020, All rights reserved.
This file is part of CellFrame SDK the open source project
CellFrame SDK is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CellFrame SDK is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with any CellFrame SDK based project. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
......@@ -58,6 +58,14 @@ typedef struct dap_chain_datum_token{
dap_chain_addr_t premine_address;
uint32_t flags;
} DAP_ALIGN_PACKED header_public;
// Private token declarations, with flags, manipulations and updates
struct {
uint128_t padding0;
uint128_t padding1;
byte_t padding2[sizeof (dap_chain_addr_t)];
uint32_t padding3;
} DAP_ALIGN_PACKED header_wrapped;
};
byte_t data_n_tsd[]; // Signs and/or types-size-data sections
} DAP_ALIGN_PACKED dap_chain_datum_token_t;
......@@ -72,6 +80,10 @@ typedef struct dap_chain_datum_token{
// Open token with now ownership
#define DAP_CHAIN_DATUM_TOKEN_TYPE_PUBLIC 0x0004
// Wrapped token declaration for interchain communications
#define DAP_CHAIN_DATUM_TOKEN_WRAPPED 0x0010
#define DAP_CHAIN_DATUM_TOKEN_WRAPPED_UPDATE 0x0011
// Macros for token flags
/// ------- Global section flags --------
......@@ -193,6 +205,9 @@ typedef struct dap_chain_datum_token_tsd{
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_TX_SENDER_BLOCKED_REMOVE 0x0024
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_TX_SENDER_BLOCKED_CLEAR 0x0025
// External chain address
#define DAP_CHAIN_DATUM_TOKEN_TSD_TYPE_EXT_CHAIN_ADDR 0x0100
// Token emission
typedef struct dap_chain_datum_token_emission{
......@@ -229,10 +244,30 @@ typedef struct dap_chain_datum_token_emission{
#define DAP_CHAIN_DATUM_TOKEN_EMISSION_TYPE_ALGO 0x02
#define DAP_CHAIN_DATUM_TOKEN_EMISSION_TYPE_ATOM_OWNER 0x03
#define DAP_CHAIN_DATUM_TOKEN_EMISSION_TYPE_SMART_CONTRACT 0x04
#define DAP_CHAIN_DATUM_TOKEN_EMISSION_TYPE_WRAPPED 0x05
extern const char *c_dap_chain_datum_token_emission_type_str[];
/// TDS op funcs
///
// Token dismissal
typedef struct dap_chain_datum_token_dismissal{
struct {
uint8_t version;
uint8_t type; // Dismissan Type
char ticker[DAP_CHAIN_TICKER_SIZE_MAX];
dap_chain_hash_fast_t tx_out; // Tx hash with outgoing coin
uint16_t tx_out_idx; // Tx out index
uint128_t tx_out_value; // Tx value
} DAP_ALIGN_PACKED hdr;
byte_t tsd[]; // TSD sections
} DAP_ALIGN_PACKED dap_chain_datum_token_dismissal_t;
// Different dismissal type
#define DAP_CHAIN_DATUM_TOKEN_DISMISSAL_TYPE_GENERAL 0x01
// TSD op funcs
//
dap_chain_datum_token_tsd_t * dap_chain_datum_token_tsd_create(uint16_t a_type, const void * a_data, size_t a_data_size);
dap_chain_datum_token_tsd_t* dap_chain_datum_token_tsd_get(dap_chain_datum_token_t * a_token, size_t a_token_size);
......
/*
* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* Copyright (c) 2020, All rights reserved.
This file is part of CellFrame SDK the open source project
CellFrame SDK is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CellFrame SDK is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with any CellFrame SDK based project. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
/*
* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* Copyright (c) 2020, All rights reserved.
This file is part of CellFrame SDK the open source project
CellFrame SDK is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CellFrame SDK is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with any CellFrame SDK based project. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
project (dap_chain_inter_btc)
file(GLOB DAP_CHAIN_INTER_BTC_SRCS *.c)
file(GLOB DAP_CHAIN_INTER_BTC_HEADERS include/*.h)
add_library(${PROJECT_NAME} STATIC ${DAP_CHAIN_INTER_BTC_SRCS} ${DAP_CHAIN_INTER_BTC_HEADERS})
target_include_directories(dap_chain_crypto INTERFACE .)
target_include_directories(${PROJECT_NAME} PUBLIC include)
target_link_libraries(${PROJECT_NAME} dap_core dap_crypto dap_chain dap_chain_crypto dap_chain_net )
#include "dap_common.h"
#include "dap_chain_inter.h"
#include "dap_chain_inter_btc.h"
#define LOG_TAG "dap_chain_inter_btc"
/*
* Authors:
* Dmitriy A. Gearasimov <gerasimov.dmitriy@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* CellFrame https://cellframe.net
* Sources https://gitlab.demlabs.net/cellframe
* Copyright (c) 2020
* All rights reserved.
This file is part of CellFrame SDK the open source project
CellFrame SDK is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
CellFrame SDK is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with any CellFrame SDK based project. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment