Browse Source

script: make DER for signature encoding optional.

Alpha does the sane thing, places signatures raw.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 9 years ago
parent
commit
62a002c860
  1. 2
      Makefile
  2. 9
      bitcoin/script.c

2
Makefile

@ -5,6 +5,8 @@ PROTOCC:=protoc-c
# Alpha has checksequenceverify, segregated witness+input-amount-in-sig+confidentual-transactions, schnorr
#FEATURES := -DHAS_CSV=1 -DALPHA_TXSTYLE=1 -DUSE_SCHNORR=1
# Bitcoin uses DER for signatures
FEATURES := -DSCRIPTS_USE_DER
PROGRAMS := test-cli/open-channel test-cli/open-anchor-scriptsigs test-cli/leak-anchor-sigs test-cli/open-commit-sig test-cli/check-commit-sig test-cli/check-anchor-scriptsigs test-cli/get-anchor-depth test-cli/create-steal-tx test-cli/create-commit-spend-tx test-cli/close-channel test-cli/create-close-tx test-cli/update-channel test-cli/update-channel-accept test-cli/update-channel-signature test-cli/update-channel-complete test-cli/create-commit-tx

9
bitcoin/script.c

@ -85,15 +85,22 @@ static void add_push_key(u8 **scriptp, const struct pubkey *key)
add_push_bytes(scriptp, key->key, pubkey_len(key));
}
/* Bitcoin wants DER encoding. */
static void add_push_sig(u8 **scriptp, const struct bitcoin_signature *sig)
{
/* Bitcoin wants DER encoding. */
#ifdef SCRIPTS_USE_DER
u8 der[73];
size_t len = signature_to_der(der, &sig->sig);
/* Append sighash type */
der[len++] = sig->stype;
add_push_bytes(scriptp, der, len);
#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? */

Loading…
Cancel
Save