Skip to content

Commit

Permalink
peercoin changes part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
backpacker69 committed Aug 13, 2019
1 parent f1e84b3 commit 2d0935a
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Expand Up @@ -9,5 +9,5 @@
url = https://github.com/ianlancetaylor/libbacktrace.git
[submodule "external/libwally-core"]
path = external/libwally-core
url = https://github.com/ElementsProject/libwally-core.git
url = https://github.com/backpacker69/libwally-core.git
ignore = dirty
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -189,7 +189,7 @@ BOLT_DEPS := $(BOLT_GEN)
ALL_PROGRAMS =

CPPFLAGS = -DBINTOPKGLIBEXECDIR="\"$(shell sh tools/rel.sh $(bindir) $(pkglibexecdir))\""
CFLAGS = $(CPPFLAGS) $(CWARNFLAGS) $(CDEBUGFLAGS) $(COPTFLAGS) -I $(CCANDIR) $(EXTERNAL_INCLUDE_FLAGS) -I . -I/usr/local/include $(FEATURES) $(COVFLAGS) $(DEV_CFLAGS) -DSHACHAIN_BITS=48 -DJSMN_PARENT_LINKS $(PIE_CFLAGS) $(COMPAT_CFLAGS)
CFLAGS = $(CPPFLAGS) $(CWARNFLAGS) $(CDEBUGFLAGS) $(COPTFLAGS) -I $(CCANDIR) $(EXTERNAL_INCLUDE_FLAGS) -I . -I/usr/local/include $(FEATURES) $(COVFLAGS) $(DEV_CFLAGS) -DSHACHAIN_BITS=48 -DJSMN_PARENT_LINKS $(PIE_CFLAGS) $(COMPAT_CFLAGS) -DENABLE_TIMESTAMP

# We can get configurator to run a different compile cmd to cross-configure.
CONFIGURATOR_CC := $(CC)
Expand Down
4 changes: 3 additions & 1 deletion bitcoin/block.c
Expand Up @@ -33,9 +33,11 @@ bitcoin_block_from_hex(const tal_t *ctx, const struct chainparams *chainparams,
b->tx[i] = pull_bitcoin_tx(b->tx, &p, &len);
b->tx[i]->chainparams = chainparams;
}
/* pull size of signature */
num = pull_varint(&p, &len);

/* We should end up not overrunning, nor have extra */
if (!p || len)
if (!p || len>num)
return tal_free(b);

tal_free(linear_tx);
Expand Down
32 changes: 32 additions & 0 deletions bitcoin/chainparams.c
Expand Up @@ -114,6 +114,38 @@ const struct chainparams networks[] = {
.p2pkh_version = 111,
.p2sh_version = 58,
.testnet = true,
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_TEST_PUBLIC, .bip32_privkey_version = BIP32_VER_TEST_PRIVATE}},
{.network_name = "peercoin",
.bip173_name = "pc",
.bip70_name = "main",
.genesis_blockhash = {{{.u.u8 = { 0xe3, 0x27, 0xcd, 0x80, 0xc8, 0xb1, 0x7e, 0xfd, 0xa4, 0xea, 0x08, 0xc5, 0x87, 0x7e, 0x95, 0xd8, 0x77, 0x46, 0x2a, 0xb6, 0x63, 0x49, 0xd5, 0x66, 0x71, 0x67, 0xfe, 0x32, 0x00, 0x00, 0x00, 0x00 }}}},
.rpc_port = 9902,
.cli = "peercoin-cli",
.cli_args = NULL,
.cli_min_supported_version = 150000,
.dust_limit = { 100000 },
.max_funding = AMOUNT_SAT_INIT(60 * ((1 << 24) - 1)),
.max_payment = AMOUNT_MSAT_INIT(60 * 0xFFFFFFFFULL),
.when_lightning_became_cool = 666666,
.p2pkh_version = 55,
.p2sh_version = 117,
.testnet = false,
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_MAIN_PUBLIC, .bip32_privkey_version = BIP32_VER_MAIN_PRIVATE}},
{.network_name = "peercoin-testnet",
.bip173_name = "tpc",
.bip70_name = "test",
.genesis_blockhash = {{{.u.u8 = { 0x06, 0x9f, 0x7c, 0xc4, 0xae, 0x81, 0xca, 0x0c, 0x7c, 0x72, 0xcc, 0x30, 0xe6, 0x8c, 0x65, 0xb0, 0x17, 0xcd, 0x17, 0x3e, 0x50, 0x96, 0x65, 0x7f, 0x73, 0xbb, 0x57, 0xf7, 0x01, 0x00, 0x00, 0x00 }}}},
.rpc_port = 9904,
.cli = "peercoin-cli",
.cli_args = "-testnet",
.cli_min_supported_version = 150000,
.dust_limit = { 100000 },
.max_funding = AMOUNT_SAT_INIT(60 * ((1 << 24) - 1)),
.max_payment = AMOUNT_MSAT_INIT(60 * 0xFFFFFFFFULL),
.when_lightning_became_cool = 1,
.p2pkh_version = 111,
.p2sh_version = 196,
.testnet = true,
.bip32_key_version = {.bip32_pubkey_version = BIP32_VER_TEST_PUBLIC, .bip32_privkey_version = BIP32_VER_TEST_PRIVATE}}
};

Expand Down
4 changes: 2 additions & 2 deletions bitcoin/tx.c
Expand Up @@ -2,6 +2,7 @@
#include <bitcoin/block.h>
#include <bitcoin/pullpush.h>
#include <bitcoin/tx.h>
#include <ccan/time/time.h>
#include <ccan/cast/cast.h>
#include <ccan/crypto/sha256/sha256.h>
#include <ccan/endian/endian.h>
Expand Down Expand Up @@ -282,8 +283,7 @@ struct bitcoin_tx *bitcoin_tx(const tal_t *ctx,
{
struct bitcoin_tx *tx = tal(ctx, struct bitcoin_tx);
assert(chainparams);

wally_tx_init_alloc(WALLY_TX_VERSION_2, 0, input_count, output_count,
wally_tx_init_alloc(WALLY_TX_VERSION_2, time_now().ts.tv_sec, 0, input_count, output_count,
&tx->wtx);
tal_add_destructor(tx, bitcoin_tx_destroy);

Expand Down
2 changes: 1 addition & 1 deletion common/json_helpers.c
Expand Up @@ -16,7 +16,7 @@ bool json_to_bitcoin_amount(const char *buffer, const jsmntok_t *tok,
return false;
if (end != buffer + tok->end) {
/* Expect always 8 decimal places. */
if (*end != '.' || buffer + tok->end - end != 9)
if (*end != '.') // || buffer + tok->end - end != 9)
return false;
sat = strtoul(end+1, &end, 10);
if (sat == ULONG_MAX && errno == ERANGE)
Expand Down
2 changes: 1 addition & 1 deletion external/Makefile
Expand Up @@ -51,7 +51,7 @@ external/libsecp256k1.% external/libwallycore.%: external/libwally-core/src/secp
$(MAKE) -C external/libwally-core DESTDIR=$$(pwd)/external install-exec

external/libwally-core/src/libwallycore.% external/libwally-core/src/secp256k1/libsecp256k1.%: $(LIBWALLY_HEADERS) $(LIBSECP_HEADERS)
cd external/libwally-core && ./tools/autogen.sh && ./configure CC="$(CC)" --enable-static=yes --host="$(MAKE_HOST)" --build="$(BUILD)" --enable-module-recovery --enable-shared=no --prefix=/ --libdir=/ && $(MAKE)
cd external/libwally-core && ./tools/autogen.sh && ./configure CC="$(CC)" --enable-timestamp=yes --enable-static=yes --host="$(MAKE_HOST)" --build="$(BUILD)" --enable-module-recovery --enable-shared=no --prefix=/ --libdir=/ && $(MAKE)

external/jsmn/jsmn.h: submodcheck

Expand Down
2 changes: 1 addition & 1 deletion external/libsodium
Submodule libsodium updated 274 files
2 changes: 1 addition & 1 deletion external/libwally-core
Submodule libwally-core updated 105 files

0 comments on commit 2d0935a

Please sign in to comment.