Skip to content

Commit 0606cbc

Browse files
author
limxdev
committed
Merge branch 'master' of https://github.com/LIMXTEC/BitCore into 0.9.8.x
2 parents b253389 + 1c6e04f commit 0606cbc

File tree

19 files changed

+1286
-36
lines changed

19 files changed

+1286
-36
lines changed

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ AC_PREREQ([2.60])
33
define(_CLIENT_VERSION_MAJOR, 0)
44
define(_CLIENT_VERSION_MINOR, 90)
55
define(_CLIENT_VERSION_REVISION, 9)
6-
define(_CLIENT_VERSION_BUILD, 0)
6+
define(_CLIENT_VERSION_BUILD, 1)
77
define(_CLIENT_VERSION_IS_RELEASE, true)
88
define(_COPYRIGHT_YEAR, 2020)
99
define(_COPYRIGHT_HOLDERS,[The %s developers])

src/Makefile.am

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,11 @@ crypto_libbitcoin_crypto_base_a_SOURCES += \
433433
crypto/sph_whirlpool.h \
434434
crypto/sponge.c \
435435
crypto/sponge.h \
436+
crypto/tiger.cpp \
437+
crypto/sph_tiger.h \
436438
crypto/x11.h \
437-
crypto/x16r.h
439+
crypto/x16r.h \
440+
crypto/x16rv2.h
438441

439442

440443
if USE_ASM

src/consensus/consensus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ static const int64_t MAX_BLOCK_SIGOPS_COST = 500000; // BTX: 80000
1818
/** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */
1919
static const int COINBASE_MATURITY = 100;
2020
static const int COINBASE_MATURITY_2 = 576;
21+
static const int COINBASE_MATURITY_3 = 4032;
2122

2223
static const int WITNESS_SCALE_FACTOR = 4;
2324

src/consensus/tx_verify.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, bool fChe
210210

211211
bool Consensus::CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight, CAmount& txfee)
212212
{
213+
int AHeight = chainActive.Height();
213214
// are the actual inputs available?
214215
if (!inputs.HaveInputs(tx)) {
215216
return state.DoS(100, false, REJECT_INVALID, "bad-txns-inputs-missingorspent", false,
@@ -225,12 +226,33 @@ bool Consensus::CheckTxInputs(const CTransaction& tx, CValidationState& state, c
225226
// If prev is coinbase, check that it's matured
226227
// if (coin.IsCoinBase() && nSpendHeight - coin.nHeight < COINBASE_MATURITY) {
227228
// BTX BEGIN
228-
if (coin.IsCoinBase() && nSpendHeight - coin.nHeight < (!sporkManager.IsSporkActive(SPORK_BTX_15_COINBASE_MATURITY_STAGE_2)? COINBASE_MATURITY : COINBASE_MATURITY_2 )) {
229+
if (AHeight < 590000)
230+
{
231+
if (coin.IsCoinBase() && nSpendHeight - coin.nHeight < COINBASE_MATURITY)
232+
{
233+
return state.Invalid(false,
234+
REJECT_INVALID, "bad-txns-premature-spend-of-coinbase",
235+
strprintf("tried to spend coinbase at depth %d", nSpendHeight - coin.nHeight));
236+
}
237+
}
238+
else
239+
{
240+
if (coin.IsCoinBase() && nSpendHeight - coin.nHeight < (!sporkManager.IsSporkActive(SPORK_BTX_16_COINBASE_MATURITY_STAGE_3)? COINBASE_MATURITY_2 : COINBASE_MATURITY_3 ))
241+
{
242+
return state.Invalid(false,
243+
REJECT_INVALID, "bad-txns-premature-spend-of-coinbase",
244+
strprintf("tried to spend coinbase at depth %d", nSpendHeight - coin.nHeight));
245+
}
246+
}
247+
/*
248+
if (coin.IsCoinBase() && nSpendHeight - coin.nHeight < (!sporkManager.IsSporkActive(SPORK_BTX_16_COINBASE_MATURITY_STAGE_3)? COINBASE_MATURITY_2 : COINBASE_MATURITY_3 )) {
229249
return state.Invalid(false,
230250
REJECT_INVALID, "bad-txns-premature-spend-of-coinbase",
231251
strprintf("tried to spend coinbase at depth %d", nSpendHeight - coin.nHeight));
232252
}
253+
*/
233254
// BTX END
255+
234256
// Check for negative or overflow input values
235257
nValueIn += coin.out.nValue;
236258
if (!MoneyRange(coin.out.nValue) || !MoneyRange(nValueIn)) {

src/consensus/tx_verify.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#define BITCORE_CONSENSUS_TX_VERIFY_H
77

88
#include <amount.h>
9-
9+
#include <validation.h>
1010
#include <stdint.h>
1111
#include <vector>
1212

src/crypto/md_helper.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,18 @@
5151
* ==========================(LICENSE BEGIN)============================
5252
*
5353
* Copyright (c) 2007-2010 Projet RNRT SAPHIR
54-
*
54+
*
5555
* Permission is hereby granted, free of charge, to any person obtaining
5656
* a copy of this software and associated documentation files (the
5757
* "Software"), to deal in the Software without restriction, including
5858
* without limitation the rights to use, copy, modify, merge, publish,
5959
* distribute, sublicense, and/or sell copies of the Software, and to
6060
* permit persons to whom the Software is furnished to do so, subject to
6161
* the following conditions:
62-
*
62+
*
6363
* The above copyright notice and this permission notice shall be
6464
* included in all copies or substantial portions of the Software.
65-
*
65+
*
6666
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
6767
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
6868
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -121,24 +121,24 @@
121121
#ifndef CLOSE_ONLY
122122

123123
#ifdef SPH_UPTR
124-
static void
124+
void
125125
SPH_XCAT(HASH, _short)(void *cc, const void *data, size_t len)
126126
#else
127127
void
128128
SPH_XCAT(sph_, HASH)(void *cc, const void *data, size_t len)
129129
#endif
130130
{
131131
SPH_XCAT(sph_, SPH_XCAT(HASH, _context)) *sc;
132-
size_t current;
132+
unsigned current;
133133

134-
sc = cc;
134+
sc = (SPH_XCAT(sph_, SPH_XCAT(HASH, _context))*) cc;
135135
#if SPH_64
136136
current = (unsigned)sc->count & (SPH_BLEN - 1U);
137137
#else
138138
current = (unsigned)sc->count_low & (SPH_BLEN - 1U);
139139
#endif
140140
while (len > 0) {
141-
size_t clen;
141+
unsigned clen;
142142
#if !SPH_64
143143
sph_u32 clow, clow2;
144144
#endif
@@ -181,7 +181,7 @@ SPH_XCAT(sph_, HASH)(void *cc, const void *data, size_t len)
181181
SPH_XCAT(HASH, _short)(cc, data, len);
182182
return;
183183
}
184-
sc = cc;
184+
sc = (SPH_XCAT(sph_, SPH_XCAT(HASH, _context))*) cc;
185185
#if SPH_64
186186
current = (unsigned)sc->count & (SPH_BLEN - 1U);
187187
#else
@@ -203,7 +203,7 @@ SPH_XCAT(sph_, HASH)(void *cc, const void *data, size_t len)
203203
#endif
204204
orig_len = len;
205205
while (len >= SPH_BLEN) {
206-
RFUN(data, SPH_VAL);
206+
RFUN((const unsigned char*)data, SPH_VAL);
207207
len -= SPH_BLEN;
208208
data = (const unsigned char *)data + SPH_BLEN;
209209
}
@@ -235,7 +235,7 @@ SPH_XCAT(sph_, HASH)(void *cc, const void *data, size_t len)
235235
* Perform padding and produce result. The context is NOT reinitialized
236236
* by this function.
237237
*/
238-
static void
238+
void
239239
SPH_XCAT(HASH, _addbits_and_close)(void *cc,
240240
unsigned ub, unsigned n, void *dst, unsigned rnum)
241241
{
@@ -245,7 +245,8 @@ SPH_XCAT(HASH, _addbits_and_close)(void *cc,
245245
sph_u32 low, high;
246246
#endif
247247

248-
sc = cc;
248+
sc = (SPH_XCAT(sph_, SPH_XCAT(HASH, _context))*) cc;
249+
249250
#if SPH_64
250251
current = (unsigned)sc->count & (SPH_BLEN - 1U);
251252
#else
@@ -339,7 +340,7 @@ SPH_XCAT(HASH, _addbits_and_close)(void *cc,
339340
#endif
340341
}
341342

342-
static void
343+
void
343344
SPH_XCAT(HASH, _close)(void *cc, void *dst, unsigned rnum)
344345
{
345346
SPH_XCAT(HASH, _addbits_and_close)(cc, 0, 0, dst, rnum);

src/crypto/sph_tiger.h

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
/* $Id: sph_tiger.h 216 2010-06-08 09:46:57Z tp $ */
2+
/**
3+
* Tiger / Tiger-2 interface.
4+
*
5+
* Tiger has been published in: R. Anderson, E. Biham, "Tiger: A Fast
6+
* New Hash Function", Fast Software Encryption - FSE'96, LNCS 1039,
7+
* Springer (1996), pp. 89--97.
8+
*
9+
* Tiger2 has never been formally published, but it was described as
10+
* identical to Tiger, except for the padding which is the same in
11+
* Tiger2 as it is in MD4. Fortunately, an implementation of Tiger2
12+
* was submitted to NESSIE, which produced test vectors; the sphlib
13+
* implementation of Tiger2 is compatible with the NESSIE test vectors.
14+
*
15+
* ==========================(LICENSE BEGIN)============================
16+
*
17+
* Copyright (c) 2007-2010 Projet RNRT SAPHIR
18+
*
19+
* Permission is hereby granted, free of charge, to any person obtaining
20+
* a copy of this software and associated documentation files (the
21+
* "Software"), to deal in the Software without restriction, including
22+
* without limitation the rights to use, copy, modify, merge, publish,
23+
* distribute, sublicense, and/or sell copies of the Software, and to
24+
* permit persons to whom the Software is furnished to do so, subject to
25+
* the following conditions:
26+
*
27+
* The above copyright notice and this permission notice shall be
28+
* included in all copies or substantial portions of the Software.
29+
*
30+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
33+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
34+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
35+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
36+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37+
*
38+
* ===========================(LICENSE END)=============================
39+
*
40+
* @file sph_tiger.h
41+
* @author Thomas Pornin <[email protected]>
42+
*/
43+
44+
#ifndef BITCORE_CRYPTO_SPH_TIGER_H
45+
#define BITCORE_CRYPTO_SPH_TIGER_H
46+
47+
#include <stddef.h>
48+
#include <crypto/sph_types.h>
49+
50+
#if SPH_64
51+
52+
/**
53+
* Output size (in bits) for Tiger.
54+
*/
55+
#define SPH_SIZE_tiger 192
56+
57+
/**
58+
* Output size (in bits) for Tiger2.
59+
*/
60+
#define SPH_SIZE_tiger2 192
61+
62+
/**
63+
* This structure is a context for Tiger computations: it contains the
64+
* intermediate values and some data from the last entered block. Once
65+
* a Tiger computation has been performed, the context can be reused for
66+
* another computation.
67+
*
68+
* The contents of this structure are private. A running Tiger computation
69+
* can be cloned by copying the context (e.g. with a simple
70+
* <code>memcpy()</code>).
71+
*/
72+
typedef struct {
73+
#ifndef DOXYGEN_IGNORE
74+
unsigned char buf[64]; /* first field, for alignment */
75+
sph_u64 val[3];
76+
sph_u64 count;
77+
#endif
78+
} sph_tiger_context;
79+
80+
/**
81+
* Initialize a Tiger context. This process performs no memory allocation.
82+
*
83+
* @param cc the Tiger context (pointer to
84+
* a <code>sph_tiger_context</code>)
85+
*/
86+
void sph_tiger_init(void *cc);
87+
88+
/**
89+
* Process some data bytes. It is acceptable that <code>len</code> is zero
90+
* (in which case this function does nothing).
91+
*
92+
* @param cc the Tiger context
93+
* @param data the input data
94+
* @param len the input data length (in bytes)
95+
*/
96+
void sph_tiger(void *cc, const void *data, size_t len);
97+
98+
/**
99+
* Terminate the current Tiger computation and output the result into the
100+
* provided buffer. The destination buffer must be wide enough to
101+
* accomodate the result (24 bytes). The context is automatically
102+
* reinitialized.
103+
*
104+
* @param cc the Tiger context
105+
* @param dst the destination buffer
106+
*/
107+
void sph_tiger_close(void *cc, void *dst);
108+
109+
/**
110+
* Apply the Tiger compression function on the provided data. The
111+
* <code>msg</code> parameter contains the 8 64-bit input blocks,
112+
* as numerical values (hence after the little-endian decoding). The
113+
* <code>val</code> parameter contains the 3 64-bit input blocks for
114+
* the compression function; the output is written in place in this
115+
* array.
116+
*
117+
* @param msg the message block (8 values)
118+
* @param val the function 192-bit input and output
119+
*/
120+
void sph_tiger_comp(const sph_u64 msg[8], sph_u64 val[3]);
121+
122+
/**
123+
* This structure is a context for Tiger2 computations. It is identical
124+
* to the Tiger context, and they may be freely exchanged, since the
125+
* difference between Tiger and Tiger2 resides solely in the padding, which
126+
* is computed only in the last computation step.
127+
*/
128+
typedef sph_tiger_context sph_tiger2_context;
129+
130+
#ifdef DOXYGEN_IGNORE
131+
/**
132+
* Initialize a Tiger2 context. This function is identical to
133+
* <code>sph_tiger_init()</code>.
134+
*
135+
* @param cc the Tiger2 context (pointer to
136+
* a <code>sph_tiger2_context</code>)
137+
*/
138+
void sph_tiger2_init(void *cc);
139+
#endif
140+
141+
#ifndef DOXYGEN_IGNORE
142+
#define sph_tiger2_init sph_tiger_init
143+
#endif
144+
145+
#ifdef DOXYGEN_IGNORE
146+
/**
147+
* Process some data bytes. This function is identical to
148+
* <code>sph_tiger()</code>.
149+
*
150+
* @param cc the Tiger2 context
151+
* @param data the input data
152+
* @param len the input data length (in bytes)
153+
*/
154+
void sph_tiger2(void *cc, const void *data, size_t len);
155+
#endif
156+
157+
#ifndef DOXYGEN_IGNORE
158+
#define sph_tiger2 sph_tiger
159+
#endif
160+
161+
/**
162+
* Terminate the current Tiger2 computation and output the result into the
163+
* provided buffer. The destination buffer must be wide enough to
164+
* accomodate the result (24 bytes). The context is automatically
165+
* reinitialized. Note that this function is NOT identical to
166+
* <code>sph_tiger2_close()</code>: this is the exact and unique point
167+
* where Tiger and Tiger2 differ.
168+
*
169+
* @param cc the Tiger context
170+
* @param dst the destination buffer
171+
*/
172+
void sph_tiger2_close(void *cc, void *dst);
173+
174+
#ifdef DOXYGEN_IGNORE
175+
/**
176+
* Apply the Tiger2 compression function, which is identical to the Tiger
177+
* compression function.
178+
*
179+
* @param msg the message block (8 values)
180+
* @param val the function 192-bit input and output
181+
*/
182+
void sph_tiger2_comp(const sph_u64 msg[8], sph_u64 val[3]);
183+
#endif
184+
185+
#ifndef DOXYGEN_IGNORE
186+
#define sph_tiger2_comp sph_tiger_comp
187+
#endif
188+
189+
#endif
190+
191+
#endif // BITCORE_CRYPTO_SPH_TIGER_H

0 commit comments

Comments
 (0)