Browse Source

Makefile: remove all the old Elements Alpha support.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 8 years ago
parent
commit
700c536a27
  1. 10
      Makefile
  2. 26
      bitcoin/locktime.c
  3. 12
      bitcoin/script.c
  4. 4
      bitcoin/tx.c
  5. 17
      daemon/test/scripts/get-new-address.sh
  6. 2
      daemon/test/scripts/setup.sh
  7. 1
      daemon/test/scripts/vars.sh

10
Makefile

@ -13,14 +13,8 @@ BOLTDIR := ../lightning-rfc/
# If you don't have (working) valgrind. # If you don't have (working) valgrind.
#NO_VALGRIND := 1 #NO_VALGRIND := 1
# Bitcoin uses DER for signatures (Add BIP68 & HAS_CSV if it's supported) # This is where we add new features as bitcoin adds them.
BITCOIN_FEATURES := \ FEATURES :=
-DHAS_BIP68=1 \
-DHAS_CLTV=1 \
-DHAS_CSV=1 \
-DSCRIPTS_USE_DER=1
FEATURES := $(BITCOIN_FEATURES)
TEST_PROGRAMS := \ TEST_PROGRAMS := \
test/test_protocol \ test/test_protocol \

26
bitcoin/locktime.c

@ -1,8 +1,6 @@
#include "bitcoin/locktime.h" #include "bitcoin/locktime.h"
#include <assert.h> #include <assert.h>
/* Alpha uses simple locktimes a-la the tx locktime field; BIP68 uses
* a bitmask */
#define SECONDS_POINT 500000000 #define SECONDS_POINT 500000000
#define BIP68_SECONDS_FLAG (1<<22) #define BIP68_SECONDS_FLAG (1<<22)
@ -32,66 +30,42 @@ static bool abs_is_seconds(u32 locktime)
bool seconds_to_rel_locktime(u32 seconds, struct rel_locktime *rel) bool seconds_to_rel_locktime(u32 seconds, struct rel_locktime *rel)
{ {
#if HAS_BIP68
if ((seconds >> BIP68_SECONDS_SHIFT) > BIP68_LOCKTIME_MASK) if ((seconds >> BIP68_SECONDS_SHIFT) > BIP68_LOCKTIME_MASK)
return false; return false;
rel->locktime = BIP68_SECONDS_FLAG | (seconds >> BIP68_SECONDS_SHIFT); rel->locktime = BIP68_SECONDS_FLAG | (seconds >> BIP68_SECONDS_SHIFT);
return true; return true;
#else
/* Make abs-style time by adding SECONDS_POINT. */
return abs_seconds_to_locktime(seconds + SECONDS_POINT, &rel->locktime);
#endif
} }
bool blocks_to_rel_locktime(u32 blocks, struct rel_locktime *rel) bool blocks_to_rel_locktime(u32 blocks, struct rel_locktime *rel)
{ {
#if HAS_BIP68
if (blocks > BIP68_LOCKTIME_MASK) if (blocks > BIP68_LOCKTIME_MASK)
return false; return false;
#endif
rel->locktime = blocks; rel->locktime = blocks;
return true; return true;
} }
bool rel_locktime_is_seconds(const struct rel_locktime *rel) bool rel_locktime_is_seconds(const struct rel_locktime *rel)
{ {
#if HAS_BIP68
return rel->locktime & BIP68_SECONDS_FLAG; return rel->locktime & BIP68_SECONDS_FLAG;
#else
return abs_is_seconds(rel->locktime);
#endif
} }
u32 rel_locktime_to_seconds(const struct rel_locktime *rel) u32 rel_locktime_to_seconds(const struct rel_locktime *rel)
{ {
assert(rel_locktime_is_seconds(rel)); assert(rel_locktime_is_seconds(rel));
#if HAS_BIP68
return (rel->locktime & BIP68_LOCKTIME_MASK) << BIP68_SECONDS_SHIFT; return (rel->locktime & BIP68_LOCKTIME_MASK) << BIP68_SECONDS_SHIFT;
#else
return rel->locktime - SECONDS_POINT;
#endif
} }
u32 rel_locktime_to_blocks(const struct rel_locktime *rel) u32 rel_locktime_to_blocks(const struct rel_locktime *rel)
{ {
assert(!rel_locktime_is_seconds(rel)); assert(!rel_locktime_is_seconds(rel));
#if HAS_BIP68
return rel->locktime & BIP68_LOCKTIME_MASK; return rel->locktime & BIP68_LOCKTIME_MASK;
#else
return rel->locktime;
#endif
} }
u32 bitcoin_nsequence(const struct rel_locktime *rel) u32 bitcoin_nsequence(const struct rel_locktime *rel)
{ {
#if HAS_BIP68
/* Can't set disable bit, or other bits except low 16 and bit 22 */ /* Can't set disable bit, or other bits except low 16 and bit 22 */
assert(!(rel->locktime & ~(BIP68_SECONDS_FLAG|BIP68_LOCKTIME_MASK))); assert(!(rel->locktime & ~(BIP68_SECONDS_FLAG|BIP68_LOCKTIME_MASK)));
return rel->locktime; return rel->locktime;
#else
/* Alpha uses the original proposal: simply invert the bits. */
return ~rel->locktime;
#endif
} }
bool seconds_to_abs_locktime(u32 seconds, struct abs_locktime *abs) bool seconds_to_abs_locktime(u32 seconds, struct abs_locktime *abs)

12
bitcoin/script.c

@ -33,20 +33,8 @@
#define OP_CHECKSIG 0xAC #define OP_CHECKSIG 0xAC
#define OP_CHECKMULTISIG 0xAE #define OP_CHECKMULTISIG 0xAE
#define OP_HASH160 0xA9 #define OP_HASH160 0xA9
#if HAS_CSV
#define OP_CHECKSEQUENCEVERIFY 0xB2 #define OP_CHECKSEQUENCEVERIFY 0xB2
#else
/* OP_NOP, otherwise bitcoind complains */
#define OP_CHECKSEQUENCEVERIFY 0x61
#endif
#if HAS_CLTV
#define OP_CHECKLOCKTIMEVERIFY 0xB1 #define OP_CHECKLOCKTIMEVERIFY 0xB1
#else
/* OP_NOP, otherwise bitcoind complains */
#define OP_CHECKLOCKTIMEVERIFY 0x61
#endif
/* Bitcoin's OP_HASH160 is RIPEMD(SHA256()) */ /* Bitcoin's OP_HASH160 is RIPEMD(SHA256()) */
static void hash160(struct ripemd160 *redeemhash, const void *mem, size_t len) static void hash160(struct ripemd160 *redeemhash, const void *mem, size_t len)

4
bitcoin/tx.c

@ -307,11 +307,7 @@ struct bitcoin_tx *bitcoin_tx(const tal_t *ctx, varint_t input_count,
tx->input[i].witness = NULL; tx->input[i].witness = NULL;
} }
tx->lock_time = 0; tx->lock_time = 0;
#if HAS_BIP68
tx->version = 2; tx->version = 2;
#else
tx->version = 1;
#endif
return tx; return tx;
} }

17
daemon/test/scripts/get-new-address.sh

@ -1,17 +0,0 @@
#! /bin/sh
# Alpha defaults to confidential addresses. We don't handle those (yet?)
# so extract the unconfidential address.
set -e
. `dirname $0`/vars.sh
case $STYLE in
alpha)
A=`$CLI getnewaddress`
$CLI validateaddress $A | sed -n 's/.*"unconfidential" : "\([A-Za-z0-9]*\)".*/\1/p'
;;
bitcoin)
$CLI getnewaddress
;;
esac

2
daemon/test/scripts/setup.sh

@ -47,6 +47,6 @@ fi
`dirname $0`/generate-block.sh init `dirname $0`/generate-block.sh init
A1=$(`dirname $0`/get-new-address.sh) A1=$($CLI getnewaddress)
TX=`$CLI sendmany "" "{ \"$A1\":0.01 }"` TX=`$CLI sendmany "" "{ \"$A1\":0.01 }"`
`dirname $0`/generate-block.sh `dirname $0`/generate-block.sh

1
daemon/test/scripts/vars.sh

@ -3,7 +3,6 @@
# Suppress sync if we can, for speedup. # Suppress sync if we can, for speedup.
if which eatmydata >/dev/null; then EATMYDATA=eatmydata; fi if which eatmydata >/dev/null; then EATMYDATA=eatmydata; fi
STYLE=bitcoin
DATADIR=/tmp/bitcoin-lightning$VARIANT DATADIR=/tmp/bitcoin-lightning$VARIANT
CLI="bitcoin-cli -datadir=$DATADIR" CLI="bitcoin-cli -datadir=$DATADIR"
REGTESTDIR=regtest REGTESTDIR=regtest

Loading…
Cancel
Save