mirror of
https://github.com/JayDDee/cpuminer-opt.git
synced 2025-09-17 23:44:27 +00:00
v3.13.2-segwit-test
This commit is contained in:
@@ -65,6 +65,14 @@ If not what makes it happen or not happen?
|
||||
Change Log
|
||||
----------
|
||||
|
||||
v3.13.2-segwit-test
|
||||
|
||||
Added support for SegWit.
|
||||
|
||||
This is a test release, it may contain bugs and additional debug logging.
|
||||
Solo miners are invited to test it and report their results. Other users
|
||||
may want to wait for the next general release before upgrading.
|
||||
|
||||
v3.13.1.1
|
||||
|
||||
Fixed Windows crash mining minotaur algo.
|
||||
|
||||
20
configure
vendored
20
configure
vendored
@@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.69 for cpuminer-opt 3.13.1.1.
|
||||
# Generated by GNU Autoconf 2.69 for cpuminer-opt 3.13.2-segwit-test.
|
||||
#
|
||||
#
|
||||
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
|
||||
@@ -577,8 +577,8 @@ MAKEFLAGS=
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME='cpuminer-opt'
|
||||
PACKAGE_TARNAME='cpuminer-opt'
|
||||
PACKAGE_VERSION='3.13.1.1'
|
||||
PACKAGE_STRING='cpuminer-opt 3.13.1.1'
|
||||
PACKAGE_VERSION='3.13.2-segwit-test'
|
||||
PACKAGE_STRING='cpuminer-opt 3.13.2-segwit-test'
|
||||
PACKAGE_BUGREPORT=''
|
||||
PACKAGE_URL=''
|
||||
|
||||
@@ -1332,7 +1332,7 @@ if test "$ac_init_help" = "long"; then
|
||||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
\`configure' configures cpuminer-opt 3.13.1.1 to adapt to many kinds of systems.
|
||||
\`configure' configures cpuminer-opt 3.13.2-segwit-test to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
@@ -1404,7 +1404,7 @@ fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of cpuminer-opt 3.13.1.1:";;
|
||||
short | recursive ) echo "Configuration of cpuminer-opt 3.13.2-segwit-test:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
@@ -1509,7 +1509,7 @@ fi
|
||||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
cpuminer-opt configure 3.13.1.1
|
||||
cpuminer-opt configure 3.13.2-segwit-test
|
||||
generated by GNU Autoconf 2.69
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
@@ -2012,7 +2012,7 @@ cat >config.log <<_ACEOF
|
||||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by cpuminer-opt $as_me 3.13.1.1, which was
|
||||
It was created by cpuminer-opt $as_me 3.13.2-segwit-test, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
$ $0 $@
|
||||
@@ -2993,7 +2993,7 @@ fi
|
||||
|
||||
# Define the identity of the package.
|
||||
PACKAGE='cpuminer-opt'
|
||||
VERSION='3.13.1.1'
|
||||
VERSION='3.13.2-segwit-test'
|
||||
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
@@ -6690,7 +6690,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by cpuminer-opt $as_me 3.13.1.1, which was
|
||||
This file was extended by cpuminer-opt $as_me 3.13.2-segwit-test, which was
|
||||
generated by GNU Autoconf 2.69. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@@ -6756,7 +6756,7 @@ _ACEOF
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
|
||||
ac_cs_version="\\
|
||||
cpuminer-opt config.status 3.13.1.1
|
||||
cpuminer-opt config.status 3.13.2-segwit-test
|
||||
configured by $0, generated by GNU Autoconf 2.69,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
AC_INIT([cpuminer-opt], [3.13.1.1])
|
||||
AC_INIT([cpuminer-opt], [3.13.2-segwit-test])
|
||||
|
||||
AC_PREREQ([2.59c])
|
||||
AC_CANONICAL_SYSTEM
|
||||
|
||||
108
cpu-miner.c
108
cpu-miner.c
@@ -563,6 +563,23 @@ static bool gbt_work_decode( const json_t *val, struct work *work )
|
||||
json_t *tmp, *txa;
|
||||
bool rc = false;
|
||||
|
||||
// Segwit BEGIN
|
||||
bool segwit = false;
|
||||
tmp = json_object_get(val, "rules");
|
||||
if (tmp && json_is_array(tmp)) {
|
||||
n = json_array_size(tmp);
|
||||
for (i = 0; i < n; i++) {
|
||||
const char *s = json_string_value(json_array_get(tmp, i));
|
||||
if (!s)
|
||||
continue;
|
||||
if (!strcmp(s, "segwit") || !strcmp(s, "!segwit"))
|
||||
segwit = true;
|
||||
}
|
||||
}
|
||||
// Segwit END
|
||||
|
||||
if ( segwit ) applog( LOG_INFO, "SEGWIT test, segwit is enabled");
|
||||
|
||||
tmp = json_object_get( val, "mutable" );
|
||||
if ( tmp && json_is_array( tmp ) )
|
||||
{
|
||||
@@ -596,6 +613,8 @@ static bool gbt_work_decode( const json_t *val, struct work *work )
|
||||
}
|
||||
version = (uint32_t) json_integer_value( tmp );
|
||||
|
||||
applog( LOG_INFO, "SEGWIT test, block version= %d", version );
|
||||
|
||||
// yescryptr8g uses block version 5 and sapling.
|
||||
if ( opt_sapling )
|
||||
work->sapling = true;
|
||||
@@ -721,13 +740,59 @@ static bool gbt_work_decode( const json_t *val, struct work *work )
|
||||
cbtx[41] = cbtx_size - 42; /* scriptsig length */
|
||||
le32enc( (uint32_t *)( cbtx+cbtx_size ), 0xffffffff ); /* sequence */
|
||||
cbtx_size += 4;
|
||||
cbtx[ cbtx_size++ ] = 1; /* out-counter */
|
||||
|
||||
// Segwit BEGIN
|
||||
//cbtx[cbtx_size++] = 1; /* out-counter */
|
||||
cbtx[cbtx_size++] = segwit ? 2 : 1; /* out-counter */
|
||||
// Segwit END
|
||||
|
||||
le32enc( (uint32_t *)( cbtx+cbtx_size) , (uint32_t)cbvalue ); /* value */
|
||||
le32enc( (uint32_t *)( cbtx+cbtx_size+4 ), cbvalue >> 32 );
|
||||
cbtx_size += 8;
|
||||
cbtx[ cbtx_size++ ] = (uint8_t) pk_script_size; /* txout-script length */
|
||||
memcpy( cbtx+cbtx_size, pk_script, pk_script_size );
|
||||
cbtx_size += (int) pk_script_size;
|
||||
|
||||
// Segwit BEGIN
|
||||
if (segwit) {
|
||||
|
||||
applog( LOG_INFO, "SEGWIT test: add segwit to tx");
|
||||
|
||||
unsigned char (*wtree)[32] = calloc(tx_count + 2, 32);
|
||||
memset(cbtx+cbtx_size, 0, 8); /* value */
|
||||
cbtx_size += 8;
|
||||
cbtx[cbtx_size++] = 38; /* txout-script length */
|
||||
cbtx[cbtx_size++] = 0x6a; /* txout-script */
|
||||
cbtx[cbtx_size++] = 0x24;
|
||||
cbtx[cbtx_size++] = 0xaa;
|
||||
cbtx[cbtx_size++] = 0x21;
|
||||
cbtx[cbtx_size++] = 0xa9;
|
||||
cbtx[cbtx_size++] = 0xed;
|
||||
for (i = 0; i < tx_count; i++) {
|
||||
const json_t *tx = json_array_get(txa, i);
|
||||
const json_t *hash = json_object_get(tx, "hash");
|
||||
if (!hash || !hex2bin(wtree[1+i], json_string_value(hash), 32)) {
|
||||
applog(LOG_ERR, "JSON invalid transaction hash");
|
||||
free(wtree);
|
||||
goto out;
|
||||
}
|
||||
memrev(wtree[1+i], 32);
|
||||
}
|
||||
n = tx_count + 1;
|
||||
while (n > 1) {
|
||||
if (n % 2)
|
||||
memcpy(wtree[n], wtree[n-1], 32);
|
||||
n = (n + 1) / 2;
|
||||
for (i = 0; i < n; i++)
|
||||
sha256d(wtree[i], wtree[2*i], 64);
|
||||
}
|
||||
memset(wtree[1], 0, 32); /* witness reserved value = 0 */
|
||||
sha256d(cbtx+cbtx_size, wtree[0], 64);
|
||||
cbtx_size += 32;
|
||||
free(wtree);
|
||||
}
|
||||
// Segwit END
|
||||
|
||||
le32enc( (uint32_t *)( cbtx+cbtx_size ), 0 ); /* lock time */
|
||||
cbtx_size += 4;
|
||||
coinbase_append = true;
|
||||
@@ -802,6 +867,22 @@ static bool gbt_work_decode( const json_t *val, struct work *work )
|
||||
tmp = json_array_get( txa, i );
|
||||
const char *tx_hex = json_string_value( json_object_get( tmp, "data" ) );
|
||||
const int tx_size = tx_hex ? (int) ( strlen( tx_hex ) / 2 ) : 0;
|
||||
|
||||
// Segwit BEGIN
|
||||
if ( segwit )
|
||||
{
|
||||
const char *txid = json_string_value(json_object_get(tmp, "txid"));
|
||||
if (!txid || !hex2bin(merkle_tree[1 + i], txid, 32))
|
||||
{
|
||||
applog(LOG_ERR, "JSON invalid transaction txid");
|
||||
goto out;
|
||||
}
|
||||
memrev(merkle_tree[1 + i], 32);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Segwit END
|
||||
|
||||
unsigned char *tx = (uchar*) malloc( tx_size );
|
||||
if ( !tx_hex || !hex2bin( tx, tx_hex, tx_size ) )
|
||||
{
|
||||
@@ -810,6 +891,12 @@ static bool gbt_work_decode( const json_t *val, struct work *work )
|
||||
goto out;
|
||||
}
|
||||
sha256d( merkle_tree[1 + i], tx, tx_size );
|
||||
free( tx );
|
||||
|
||||
// Segwit BEGIN
|
||||
}
|
||||
// Segwit END
|
||||
|
||||
if ( !submit_coinbase )
|
||||
strcat( work->txs, tx_hex );
|
||||
}
|
||||
@@ -1405,12 +1492,24 @@ const char *getwork_req =
|
||||
|
||||
#define GBT_CAPABILITIES "[\"coinbasetxn\", \"coinbasevalue\", \"longpoll\", \"workid\"]"
|
||||
|
||||
// Segwit BEGIN
|
||||
#define GBT_RULES "[\"segwit\"]"
|
||||
static const char *gbt_req =
|
||||
"{\"method\": \"getblocktemplate\", \"params\": [{\"capabilities\": "
|
||||
GBT_CAPABILITIES ", \"rules\": " GBT_RULES "}], \"id\":0}\r\n";
|
||||
const char *gbt_lp_req =
|
||||
"{\"method\": \"getblocktemplate\", \"params\": [{\"capabilities\": "
|
||||
GBT_CAPABILITIES ", \"rules\": " GBT_RULES ", \"longpollid\": \"%s\"}], \"id\":0}\r\n";
|
||||
|
||||
/*
|
||||
static const char *gbt_req =
|
||||
"{\"method\": \"getblocktemplate\", \"params\": [{\"capabilities\": "
|
||||
GBT_CAPABILITIES "}], \"id\":0}\r\n";
|
||||
const char *gbt_lp_req =
|
||||
"{\"method\": \"getblocktemplate\", \"params\": [{\"capabilities\": "
|
||||
GBT_CAPABILITIES ", \"longpollid\": \"%s\"}], \"id\":0}\r\n";
|
||||
*/
|
||||
// Segwit END
|
||||
|
||||
static bool get_upstream_work( CURL *curl, struct work *work )
|
||||
{
|
||||
@@ -3219,6 +3318,13 @@ static void show_credits()
|
||||
printf(" A CPU miner with multi algo support and optimized for CPUs\n");
|
||||
printf(" with AVX512, SHA and VAES extensions.\n");
|
||||
printf(" BTC donation address: 12tdvfF7KmAsihBXQXynT6E6th2c2pByTT\n\n");
|
||||
|
||||
printf("/nWarning: this is a test release, it may contain bugs and aditional\n");
|
||||
printf("debug log output. Users who solo mine using getwork or GBT are invited\n\n");
|
||||
printf("to use it for testing purposes. Please report any regressions. Other\n");
|
||||
printf("users may prefer to continue using the latest general release.\n\n");
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool check_cpu_capability ()
|
||||
|
||||
4
miner.h
4
miner.h
@@ -313,6 +313,10 @@ size_t address_to_script( unsigned char *out, size_t outsz, const char *addr );
|
||||
int timeval_subtract( struct timeval *result, struct timeval *x,
|
||||
struct timeval *y);
|
||||
|
||||
// Segwit BEGIN
|
||||
extern void memrev(unsigned char *p, size_t len);
|
||||
// Segwit END
|
||||
|
||||
// Bitcoin formula for converting difficulty to an equivalent
|
||||
// number of hashes.
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user