From 810488650328c2715d2245446be07f8453573695 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 11 Apr 2016 16:32:43 +0930 Subject: [PATCH] Remove Alpha support. I had already disabled it, and this clears the decks for Segregated Witness which gives us everything we want. Signed-off-by: Rusty Russell --- Makefile | 18 +-- bitcoin/script.c | 9 +- bitcoin/signature.c | 21 --- bitcoin/signature.h | 6 - bitcoin/tx.c | 230 +++-------------------------- bitcoin/tx.h | 11 +- close_tx.c | 6 +- commit_tx.c | 8 +- daemon/peer.c | 12 +- protobuf_convert.c | 22 --- test-cli/scripts/generate-block.sh | 24 +-- test-cli/scripts/vars.sh | 23 +-- 12 files changed, 48 insertions(+), 342 deletions(-) diff --git a/Makefile b/Makefile index b0dd77c11..2952da297 100644 --- a/Makefile +++ b/Makefile @@ -7,25 +7,13 @@ PROTOCC:=protoc-c # We use our own internal ccan copy. CCANDIR := ccan -# Alpha has checksequenceverify, segregated witness+input-amount-in-sig+confidentual-transactions, schnorr, checklocktimeverify -ALPHA_FEATURES := \ - -DALPHA_TXSTYLE=1 \ - -DHAS_BIP68=0 \ - -DHAS_CLTV=1 \ - -DHAS_CSV=1 \ - -DSCRIPTS_USE_DER=0 \ - -DUSE_SCHNORR=1 - # Bitcoin uses DER for signatures (Add BIP68 & HAS_CSV if it's supported) BITCOIN_FEATURES := \ - -DALPHA_TXSTYLE=0 \ -DHAS_BIP68=0 \ -DHAS_CLTV=1 \ -DHAS_CSV=0 \ - -DSCRIPTS_USE_DER=1 \ - -DUSE_SCHNORR=0 + -DSCRIPTS_USE_DER=1 -#FEATURES := $(ALPHA_FEATURES) FEATURES := $(BITCOIN_FEATURES) TEST_PROGRAMS := \ @@ -236,12 +224,12 @@ ccan/ccan/cdump/tools/cdump-enumstr: ccan/ccan/cdump/tools/cdump-enumstr.o $(CDU gen_state_names.h: state_types.h ccan/ccan/cdump/tools/cdump-enumstr ccan/ccan/cdump/tools/cdump-enumstr state_types.h > $@ -# We build a static libsecpk1, since we need schnorr for alpha +# We build a static libsecpk1, since we need ecdh # (and it's not API stable yet!). libsecp256k1.a: secp256k1/libsecp256k1.la secp256k1/libsecp256k1.la: - cd secp256k1 && ./autogen.sh && ./configure --enable-static=yes --enable-shared=no --enable-tests=no --enable-module-schnorr=yes --enable-module-ecdh=yes --libdir=`pwd`/.. + cd secp256k1 && ./autogen.sh && ./configure --enable-static=yes --enable-shared=no --enable-tests=no --enable-module-ecdh=yes --libdir=`pwd`/.. $(MAKE) -C secp256k1 install-exec lightning.pb-c.c lightning.pb-c.h: lightning.proto diff --git a/bitcoin/script.c b/bitcoin/script.c index e043c3865..4b8b90903 100644 --- a/bitcoin/script.c +++ b/bitcoin/script.c @@ -107,8 +107,7 @@ static void add_push_key(u8 **scriptp, const struct pubkey *key) static void add_push_sig(u8 **scriptp, const struct bitcoin_signature *sig) { -/* Bitcoin wants DER encoding. */ -#if SCRIPTS_USE_DER + /* Bitcoin wants DER encoding. */ u8 der[73]; secp256k1_context *secpctx = secp256k1_context_create(0); size_t len = signature_to_der(secpctx, der, &sig->sig); @@ -117,12 +116,6 @@ static void add_push_sig(u8 **scriptp, const struct bitcoin_signature *sig) der[len++] = sig->stype; add_push_bytes(scriptp, der, len); secp256k1_context_destroy(secpctx); -#else /* Alpha uses raw encoding */ - u8 with_sighash[sizeof(sig->sig) + 1]; - memcpy(with_sighash, &sig->sig, sizeof(sig->sig)); - with_sighash[sizeof(sig->sig)] = sig->stype; - add_push_bytes(scriptp, with_sighash, sizeof(with_sighash)); -#endif } /* FIXME: permute? */ diff --git a/bitcoin/signature.c b/bitcoin/signature.c index 17b1229d4..8067566d4 100644 --- a/bitcoin/signature.c +++ b/bitcoin/signature.c @@ -2,9 +2,6 @@ #include "pubkey.h" #include "script.h" #include "secp256k1.h" -#if USE_SCHNORR -#include "secp256k1_schnorr.h" -#endif #include "shadouble.h" #include "signature.h" #include "tx.h" @@ -83,17 +80,10 @@ void sign_hash(secp256k1_context *secpctx, { bool ok; -#if USE_SCHNORR - ok = secp256k1_schnorr_sign(secpctx, - s->schnorr, - h->sha.u.u8, - privkey->secret, NULL, NULL); -#else ok = secp256k1_ecdsa_sign(secpctx, &s->sig, h->sha.u.u8, privkey->secret, NULL, NULL); -#endif assert(ok); } @@ -148,14 +138,9 @@ bool check_signed_hash(secp256k1_context *secpctx, { int ret; -#if USE_SCHNORR - ret = secp256k1_schnorr_verify(secpctx, signature->schnorr, - hash->sha.u.u8, &key->pubkey); -#else ret = secp256k1_ecdsa_verify(secpctx, &signature->sig, hash->sha.u.u8, &key->pubkey); -#endif return ret == 1; } @@ -205,7 +190,6 @@ bool check_2of2_sig(secp256k1_context *secpctx, && check_signed_hash(secpctx, &hash, &sig2->sig, key2); } -#if USE_SCHNORR == 0 /* Stolen direct from bitcoin/src/script/sign.cpp: // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers @@ -289,15 +273,10 @@ size_t signature_to_der(secp256k1_context *secpctx, assert(IsValidSignatureEncoding(der, len + 1)); return len; } -#endif /* USE_SCHNORR */ /* Signature must have low S value. */ bool sig_valid(const struct signature *sig) { -#if USE_SCHNORR - return true; -#else /* FIXME! Need libsecp support. */ return true; -#endif } diff --git a/bitcoin/signature.h b/bitcoin/signature.h index a06029c65..112b78120 100644 --- a/bitcoin/signature.h +++ b/bitcoin/signature.h @@ -14,11 +14,7 @@ enum sighash_type { /* ECDSA of double SHA256. */ struct signature { -#if USE_SCHNORR - u8 schnorr[64]; -#else secp256k1_ecdsa_signature sig; -#endif }; struct sha256_double; @@ -63,10 +59,8 @@ bool check_2of2_sig(secp256k1_context *secpctx, /* Signature must have low S value. */ bool sig_valid(const struct signature *s); -#if USE_SCHNORR == 0 /* Give DER encoding of signature: returns length used (<= 72). */ size_t signature_to_der(secp256k1_context *secpctx, u8 der[72], const struct signature *s); -#endif #endif /* LIGHTNING_BITCOIN_SIGNATURE_H */ diff --git a/bitcoin/tx.c b/bitcoin/tx.c index a12630034..38835d807 100644 --- a/bitcoin/tx.c +++ b/bitcoin/tx.c @@ -9,48 +9,14 @@ #include enum styles { - /* Add the CT padding stuff to amount. */ - TX_AMOUNT_CT_STYLE = 1, - /* Whether to process CT rangeproof and noncecommitment. */ - TX_AMOUNT_INCLUDE_CT = 2, - /* Process the txfee field. */ - TX_FEE = 4, - /* Process the input script sig. */ - TX_INPUT_SCRIPTSIG = 8, - /* Process the amounts for each input. */ - TX_INPUT_AMOUNT = 16, - /* Process the same amounts for each input. */ - TX_INPUT_AMOUNT_BUGGY = 32, - /* Process hash of rangeproof and noncecommitment in *output* amount, - * instead of rangeproof and noncecommitment themselves. */ - TX_OUTPUT_AMOUNT_HASHPROOF = 64 + /* For making a signature */ + SIG_STYLE, + /* linearizing for sendrawtransaction/getrawtransaction. */ + LINEARIZE_STYLE, + /* For making transaction IDs. */ + TXID_STYLE }; -#if ALPHA_TXSTYLE -/* Linearizing has everything, except input amount (which is implied) */ -#define LINEARIZE_STYLE (TX_AMOUNT_CT_STYLE | TX_AMOUNT_INCLUDE_CT | TX_FEE | TX_INPUT_SCRIPTSIG) - -/* Alpha txids don't include input scripts, or rangeproof/txcommit in output */ -#define TXID_STYLE (TX_AMOUNT_CT_STYLE | TX_FEE) - -/* Alpha signatures sign the input script (assuming others are set to - * 0-len), as well as the input fee. - - * They sign a hash of the rangeproof and noncecommitment for inputs, - * rather than the non rangeproof and noncecommitment themselves. - * - * For some reason they skip the txfee. */ -#define SIG_STYLE (TX_AMOUNT_CT_STYLE | TX_AMOUNT_INCLUDE_CT | TX_INPUT_SCRIPTSIG | TX_INPUT_AMOUNT | TX_INPUT_AMOUNT_BUGGY | TX_OUTPUT_AMOUNT_HASHPROOF) - -#else /* BITCOIN */ - -/* Process all the bitcoin fields. Works for txid, serialization and signing */ -#define LINEARIZE_STYLE (TX_INPUT_SCRIPTSIG) -#define TXID_STYLE (TX_INPUT_SCRIPTSIG) -#define SIG_STYLE (TX_INPUT_SCRIPTSIG) - -#endif - static void add_varint(varint_t v, void (*add)(const void *, size_t, void *), void *addp, enum styles style) @@ -99,68 +65,14 @@ static void add_le64(u64 v, add(&l, sizeof(l), addp); } -static void add_value(u64 amount, - void (*add)(const void *, size_t, void *), - void *addp, - bool output, - enum styles style) -{ - if (style & TX_AMOUNT_CT_STYLE) { - /* The input is hashed as a 33 byte value (for CT); 25 0, then - * the big-endian value. */ - static u8 zeroes[25]; - be64 b = cpu_to_be64(amount); - add(zeroes, sizeof(zeroes), addp); - add(&b, sizeof(b), addp); - if (style & TX_AMOUNT_INCLUDE_CT) { - /* Two more zeroes: Rangeproof and Noncecommitment */ - if (output && (style & TX_OUTPUT_AMOUNT_HASHPROOF)) { - struct sha256_double h; - sha256_double(&h, zeroes, 2); - add(&h, sizeof(h), addp); - } else { - add_varint(0, add, addp, style); - add_varint(0, add, addp, style); - } - } - } else { - add_le64(amount, add, addp, style); - } -} - -static void add_input_value(u64 amount, - void (*add)(const void *, size_t, void *), - void *addp, - enum styles style) -{ - return add_value(amount, add, addp, false, style); -} - -static void add_output_value(u64 amount, - void (*add)(const void *, size_t, void *), - void *addp, - enum styles style) -{ - return add_value(amount, add, addp, true, style); -} - static void add_tx_input(const struct bitcoin_tx_input *input, void (*add)(const void *, size_t, void *), void *addp, - u64 dummy_amount, enum styles style) { add(&input->txid, sizeof(input->txid), addp); add_le32(input->index, add, addp, style); - if (style & TX_INPUT_AMOUNT) { - if (style & TX_INPUT_AMOUNT_BUGGY) - add_input_value(dummy_amount, add, addp, style); - else - add_input_value(input->input_amount, add, addp, style); - } - if (style & TX_INPUT_SCRIPTSIG) { - add_varint(input->script_length, add, addp, style); - add(input->script, input->script_length, addp); - } + add_varint(input->script_length, add, addp, style); + add(input->script, input->script_length, addp); add_le32(input->sequence_number, add, addp, style); } @@ -168,14 +80,13 @@ static void add_tx_output(const struct bitcoin_tx_output *output, void (*add)(const void *, size_t, void *), void *addp, enum styles style) { - add_output_value(output->amount, add, addp, style); + add_le64(output->amount, add, addp, style); add_varint(output->script_length, add, addp, style); add(output->script, output->script_length, addp); } static void add_tx(const struct bitcoin_tx *tx, void (*add)(const void *, size_t, void *), void *addp, - u64 dummy_amount, enum styles style) { varint_t i; @@ -183,10 +94,7 @@ static void add_tx(const struct bitcoin_tx *tx, add_le32(tx->version, add, addp, style); add_varint(tx->input_count, add, addp, style); for (i = 0; i < tx->input_count; i++) - add_tx_input(&tx->input[i], add, addp, dummy_amount, style); - - if (style & TX_FEE) - add_le64(tx->fee, add, addp, style); + add_tx_input(&tx->input[i], add, addp, style); add_varint(tx->output_count, add, addp, style); for (i = 0; i < tx->output_count; i++) @@ -210,7 +118,7 @@ void sha256_tx_for_sig(struct sha256_ctx *ctx, const struct bitcoin_tx *tx, for (i = 0; i < tx->input_count; i++) if (i != input_num) assert(tx->input[i].script_length == 0); - add_tx(tx, add_sha, ctx, tx->input[input_num].input_amount, SIG_STYLE); + add_tx(tx, add_sha, ctx, SIG_STYLE); } static void add_linearize(const void *data, size_t len, void *pptr_) @@ -225,7 +133,7 @@ static void add_linearize(const void *data, size_t len, void *pptr_) u8 *linearize_tx(const tal_t *ctx, const struct bitcoin_tx *tx) { u8 *arr = tal_arr(ctx, u8, 0); - add_tx(tx, add_linearize, &arr, 0, LINEARIZE_STYLE); + add_tx(tx, add_linearize, &arr, LINEARIZE_STYLE); return arr; } @@ -233,7 +141,7 @@ void bitcoin_txid(const struct bitcoin_tx *tx, struct sha256_double *txid) { struct sha256_ctx ctx = SHA256_INIT; - add_tx(tx, add_sha, &ctx, 0, TXID_STYLE); + add_tx(tx, add_sha, &ctx, TXID_STYLE); sha256_double_done(&ctx, txid); } @@ -343,41 +251,8 @@ static u64 pull_value(const u8 **cursor, size_t *max) { u64 amount; - if (LINEARIZE_STYLE & TX_AMOUNT_CT_STYLE) { - /* The input is hashed as a 33 byte value (for CT); 25 0, then - * the big-endian value. */ - u8 zeroes[25]; - be64 b; - - if (!pull(cursor, max, zeroes, sizeof(zeroes))) - return 0; - - /* We don't handle CT amounts. */ - if (zeroes[0] != 0) - goto fail; - - if (!pull(cursor, max, &b, sizeof(b))) - return 0; - - amount = be64_to_cpu(b); - if (LINEARIZE_STYLE & TX_AMOUNT_INCLUDE_CT) { - varint_t rp, nc; - - rp = pull_varint(cursor, max); - nc = pull_varint(cursor, max); - if (rp != 0 || nc != 0) - goto fail; - } - } else { - amount = pull_le64(cursor, max); - } + amount = pull_le64(cursor, max); return amount; - -fail: - /* Simulate EOF */ - *cursor = NULL; - *max = 0; - return 0; } static void pull_input(const tal_t *ctx, const u8 **cursor, size_t *max, @@ -385,14 +260,9 @@ static void pull_input(const tal_t *ctx, const u8 **cursor, size_t *max, { pull_sha256_double(cursor, max, &input->txid); input->index = pull_le32(cursor, max); - if (LINEARIZE_STYLE & TX_INPUT_AMOUNT) { - input->input_amount = pull_value(cursor, max); - } - if (LINEARIZE_STYLE & TX_INPUT_SCRIPTSIG) { - input->script_length = pull_varint(cursor, max); - input->script = tal_arr(ctx, u8, input->script_length); - pull(cursor, max, input->script, input->script_length); - } + input->script_length = pull_varint(cursor, max); + input->script = tal_arr(ctx, u8, input->script_length); + pull(cursor, max, input->script, input->script_length); input->sequence_number = pull_le32(cursor, max); } @@ -417,9 +287,6 @@ static struct bitcoin_tx *pull_bitcoin_tx(const tal_t *ctx, for (i = 0; i < tx->input_count; i++) pull_input(tx, cursor, max, tx->input + i); - if (LINEARIZE_STYLE & TX_FEE) - tx->fee = pull_le64(cursor, max); - tx->output_count = pull_varint(cursor, max); tx->output = tal_arr(tx, struct bitcoin_tx_output, tx->output_count); for (i = 0; i < tx->output_count; i++) @@ -441,12 +308,9 @@ struct bitcoin_tx *bitcoin_tx_from_hex(const tal_t *ctx, const char *hex, struct bitcoin_tx *tx; size_t len; - end = memchr(hex, ':', hexlen); - if (!end) { + end = memchr(hex, '\n', hexlen); + if (!end) end = cast_const(char *, hex) + hexlen; - if (hexlen > 0 && hex[hexlen-1] == '\n') - end--; - } len = hex_data_size(end - hex); p = linear_tx = tal_arr(ctx, u8, len); @@ -457,28 +321,9 @@ struct bitcoin_tx *bitcoin_tx_from_hex(const tal_t *ctx, const char *hex, if (!tx) goto fail; - /* Optional appended [:input-amount]* */ - for (len = 0; len < tx->input_count; len++) { - if (*end != ':') - break; - - tx->input[len].input_amount = 0; - end++; - while (end < hex + hexlen && cisdigit(*end)) { - tx->input[len].input_amount *= 10; - tx->input[len].input_amount += *end - '0'; - end++; - } - } - if (len == tx->input_count) { - if (end != hex + hexlen && *end != '\n') - goto fail_free_tx; - } else { - /* Input amounts are compulsory for alpha, to generate sigs */ -#if ALPHA_TXSTYLE + if (end != hex + hexlen && *end != '\n') goto fail_free_tx; -#endif - } + tal_free(linear_tx); return tx; @@ -519,36 +364,3 @@ bool bitcoin_txid_to_hex(const struct sha256_double *txid, reverse_bytes(rev.sha.u.u8, sizeof(rev.sha.u.u8)); return hex_encode(&rev, sizeof(rev), hexstr, hexstr_len); } - -static bool write_input_amounts(int fd, const struct bitcoin_tx *tx) -{ - /* Alpha required input amounts, so append them */ -#if ALPHA_TXSTYLE - size_t i; - - for (i = 0; i < tx->input_count; i++) { - char str[1 + STR_MAX_CHARS(tx->input[i].input_amount)]; - sprintf(str, ":%llu", - (unsigned long long)tx->input[i].input_amount); - if (!write_all(fd, str, strlen(str))) - return false; - } -#endif - return true; -} - -bool bitcoin_tx_write(int fd, const struct bitcoin_tx *tx) -{ - u8 *tx_arr; - char *tx_hex; - bool ok; - - tx_arr = linearize_tx(NULL, tx); - tx_hex = tal_arr(tx_arr, char, hex_str_size(tal_count(tx_arr))); - hex_encode(tx_arr, tal_count(tx_arr), tx_hex, tal_count(tx_hex)); - - ok = write_all(fd, tx_hex, strlen(tx_hex)) - && write_input_amounts(fd, tx); - tal_free(tx_arr); - return ok; -} diff --git a/bitcoin/tx.h b/bitcoin/tx.h index 7ac8815d0..8da6544af 100644 --- a/bitcoin/tx.h +++ b/bitcoin/tx.h @@ -13,9 +13,6 @@ struct bitcoin_tx { varint_t input_count; struct bitcoin_tx_input *input; - /* Only in alpha. */ - u64 fee; - varint_t output_count; struct bitcoin_tx_output *output; u32 lock_time; @@ -28,9 +25,6 @@ struct bitcoin_tx_output { }; struct bitcoin_tx_input { - /* In alpha, this is hashed for signature */ - u64 input_amount; - struct sha256_double txid; u32 index; /* output number referred to by above */ varint_t script_length; @@ -54,13 +48,10 @@ u8 *linearize_tx(const tal_t *ctx, const struct bitcoin_tx *tx); struct bitcoin_tx *bitcoin_tx(const tal_t *ctx, varint_t input_count, varint_t output_count); -/* This takes a raw bitcoin tx in hex, with [:<64-bit-satoshi>] appended - * for each input (required for -DALPHA). */ +/* This takes a raw bitcoin tx in hex. */ struct bitcoin_tx *bitcoin_tx_from_hex(const tal_t *ctx, const char *hex, size_t hexlen); -bool bitcoin_tx_write(int fd, const struct bitcoin_tx *tx); - /* Parse hex string to get txid (reversed, a-la bitcoind). */ bool bitcoin_txid_from_hex(const char *hexstr, size_t hexstr_len, struct sha256_double *txid); diff --git a/close_tx.c b/close_tx.c index c58608b00..ff8b5b72a 100644 --- a/close_tx.c +++ b/close_tx.c @@ -24,7 +24,6 @@ struct bitcoin_tx *create_close_tx(secp256k1_context *secpctx, /* Our input spends the anchor tx output. */ tx->input[0].txid = *anchor_txid; tx->input[0].index = anchor_index; - tx->input[0].input_amount = anchor_satoshis; /* One output is to us. */ tx->output[0].amount = to_us; @@ -38,10 +37,7 @@ struct bitcoin_tx *create_close_tx(secp256k1_context *secpctx, tx->output[1].script = scriptpubkey_p2sh(tx, redeemscript); tx->output[1].script_length = tal_count(tx->output[1].script); - assert(tx->output[0].amount + tx->output[1].amount - <= tx->input[0].input_amount); - tx->fee = tx->input[0].input_amount - - (tx->output[0].amount + tx->output[1].amount); + assert(tx->output[0].amount + tx->output[1].amount <= anchor_satoshis); permute_outputs(tx->output, 2, NULL); return tx; diff --git a/commit_tx.c b/commit_tx.c index f0eedcb24..f46e9544e 100644 --- a/commit_tx.c +++ b/commit_tx.c @@ -56,7 +56,6 @@ struct bitcoin_tx *create_commit_tx(const tal_t *ctx, /* Our input spends the anchor tx output. */ tx->input[0].txid = *anchor_txid; tx->input[0].index = anchor_index; - tx->input[0].input_amount = anchor_satoshis; /* First output is a P2SH to a complex redeem script (usu. for me) */ redeemscript = bitcoin_redeem_secret_or_delay(tx, our_final, @@ -95,11 +94,8 @@ struct bitcoin_tx *create_commit_tx(const tal_t *ctx, total += tx->output[num++].amount; } assert(num == tx->output_count); - - /* Calculate fee; difference of inputs and outputs. */ - assert(total <= tx->input[0].input_amount); - tx->fee = tx->input[0].input_amount - total; - + assert(total <= anchor_satoshis); + permute_outputs(tx->output, tx->output_count, NULL); return tx; } diff --git a/daemon/peer.c b/daemon/peer.c index b96584fa9..de2337442 100644 --- a/daemon/peer.c +++ b/daemon/peer.c @@ -1110,6 +1110,7 @@ const struct bitcoin_tx *bitcoin_spend_ours(struct peer *peer) struct bitcoin_signature sig; struct bitcoin_tx *tx; unsigned int p2sh_out; + uint64_t fee; /* The redeemscript for a commit tx is fairly complex. */ redeemscript = bitcoin_redeem_secret_or_delay(peer, @@ -1123,7 +1124,6 @@ const struct bitcoin_tx *bitcoin_spend_ours(struct peer *peer) bitcoin_txid(commit, &tx->input[0].txid); p2sh_out = find_p2sh_out(commit, redeemscript); tx->input[0].index = p2sh_out; - tx->input[0].input_amount = commit->output[p2sh_out].amount; tx->input[0].sequence_number = bitcoin_nsequence(&peer->them.locktime); tx->output[0].amount = commit->output[p2sh_out].amount; @@ -1145,19 +1145,19 @@ const struct bitcoin_tx *bitcoin_spend_ours(struct peer *peer) /* Now, calculate the fee, given length. */ /* FIXME: Dynamic fees! */ linear = linearize_tx(peer, tx); - tx->fee = fee_by_feerate(tal_count(linear), + fee = fee_by_feerate(tal_count(linear), peer->dstate->config.closing_fee_rate); tal_free(linear); /* FIXME: Fail gracefully in these cases (not worth collecting) */ - if (tx->fee > tx->output[0].amount - || is_dust_amount(tx->output[0].amount - tx->fee)) + if (fee > tx->output[0].amount + || is_dust_amount(tx->output[0].amount - fee)) fatal("Amount of %"PRIu64" won't cover fee %"PRIu64, - tx->output[0].amount, tx->fee); + tx->output[0].amount, fee); /* Re-sign with the real values. */ tx->input[0].script_length = 0; - tx->output[0].amount -= tx->fee; + tx->output[0].amount -= fee; peer_sign_spend(peer, tx, redeemscript, &sig.sig); tx->input[0].script = scriptsig_p2sh_secret(tx, NULL, 0, &sig, diff --git a/protobuf_convert.c b/protobuf_convert.c index d66a59005..eb0e06c14 100644 --- a/protobuf_convert.c +++ b/protobuf_convert.c @@ -11,16 +11,6 @@ Signature *signature_to_proto(const tal_t *ctx, const struct signature *sig) assert(sig_valid(sig)); -#if USE_SCHNORR - memcpy(&pb->r1, sig->schnorr, 8); - memcpy(&pb->r2, sig->schnorr + 8, 8); - memcpy(&pb->r3, sig->schnorr + 16, 8); - memcpy(&pb->r4, sig->schnorr + 24, 8); - memcpy(&pb->s1, sig->schnorr + 32, 8); - memcpy(&pb->s2, sig->schnorr + 40, 8); - memcpy(&pb->s3, sig->schnorr + 48, 8); - memcpy(&pb->s4, sig->schnorr + 56, 8); -#else /* FIXME: Need a portable way to encode signatures in libsecp! */ /* Kill me now... */ @@ -32,7 +22,6 @@ Signature *signature_to_proto(const tal_t *ctx, const struct signature *sig) memcpy(&pb->s2, sig->sig.data + 40, 8); memcpy(&pb->s3, sig->sig.data + 48, 8); memcpy(&pb->s4, sig->sig.data + 56, 8); -#endif return pb; } @@ -40,16 +29,6 @@ Signature *signature_to_proto(const tal_t *ctx, const struct signature *sig) bool proto_to_signature(const Signature *pb, struct signature *sig) { /* Kill me again. */ -#if USE_SCHNORR - memcpy(sig->schnorr, &pb->r1, 8); - memcpy(sig->schnorr + 8, &pb->r2, 8); - memcpy(sig->schnorr + 16, &pb->r3, 8); - memcpy(sig->schnorr + 24, &pb->r4, 8); - memcpy(sig->schnorr + 32, &pb->s1, 8); - memcpy(sig->schnorr + 40, &pb->s2, 8); - memcpy(sig->schnorr + 48, &pb->s3, 8); - memcpy(sig->schnorr + 56, &pb->s4, 8); -#else /* FIXME: Need a portable way to encode signatures in libsecp! */ memcpy(sig->sig.data, &pb->r1, 8); @@ -60,7 +39,6 @@ bool proto_to_signature(const Signature *pb, struct signature *sig) memcpy(sig->sig.data + 40, &pb->s2, 8); memcpy(sig->sig.data + 48, &pb->s3, 8); memcpy(sig->sig.data + 56, &pb->s4, 8); -#endif return sig_valid(sig); } diff --git a/test-cli/scripts/generate-block.sh b/test-cli/scripts/generate-block.sh index 596cb835a..5f2926eff 100755 --- a/test-cli/scripts/generate-block.sh +++ b/test-cli/scripts/generate-block.sh @@ -6,21 +6,9 @@ set -e . `dirname $0`/vars.sh INIT=$1 -case $STYLE in - alpha) - # This is a one-shot in alpha, it seems. - $CLI setgenerate true - # Avoid median time bug by generating 11 blocks - if [ -n "$INIT" ]; then - for i in `seq 11`; do $CLI setgenerate true; done - fi - ;; - bitcoin) - # Initially we need 100 blocks so coinbase matures, giving us funds. - if [ -n "$INIT" ]; then - $CLI generate 101 - else - $CLI generate 1 - fi - ;; -esac +# Initially we need 100 blocks so coinbase matures, giving us funds. +if [ -n "$INIT" ]; then + $CLI generate 101 +else + $CLI generate 1 +fi diff --git a/test-cli/scripts/vars.sh b/test-cli/scripts/vars.sh index 6fbba2a2b..08cd463f9 100644 --- a/test-cli/scripts/vars.sh +++ b/test-cli/scripts/vars.sh @@ -1,23 +1,14 @@ # Sourced by other scripts -if grep -q ^FEATURES.*ALPHA ../Makefile; then - STYLE=alpha - DATADIR=/tmp/alpha-lightning - REGTESTDIR=alpharegtest - CLI="alpha-cli -datadir=$DATADIR" - DAEMON="alphad -datadir=$DATADIR" - SEQ_ENFORCEMENT=true -else - STYLE=bitcoin - DATADIR=/tmp/bitcoin-lightning - CLI="bitcoin-cli -datadir=$DATADIR" - REGTESTDIR=regtest - DAEMON="bitcoind -datadir=$DATADIR" - if grep ^FEATURES ../Makefile | cut -d'#' -f1 | grep -q BIP68; then +STYLE=bitcoin +DATADIR=/tmp/bitcoin-lightning +CLI="bitcoin-cli -datadir=$DATADIR" +REGTESTDIR=regtest +DAEMON="bitcoind -datadir=$DATADIR" +if grep ^FEATURES ../Makefile | cut -d'#' -f1 | grep -q BIP68; then SEQ_ENFORCEMENT=true - else +else SEQ_ENFORCEMENT=false - fi fi #PREFIX="valgrind --vgdb-error=1"