mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 06:41:44 +01:00
script: make DER for signature encoding optional.
Alpha does the sane thing, places signatures raw. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
faae91f3fc
commit
62a002c860
2 changed files with 10 additions and 1 deletions
2
Makefile
2
Makefile
|
@ -5,6 +5,8 @@ PROTOCC:=protoc-c
|
||||||
|
|
||||||
# Alpha has checksequenceverify, segregated witness+input-amount-in-sig+confidentual-transactions, schnorr
|
# Alpha has checksequenceverify, segregated witness+input-amount-in-sig+confidentual-transactions, schnorr
|
||||||
#FEATURES := -DHAS_CSV=1 -DALPHA_TXSTYLE=1 -DUSE_SCHNORR=1
|
#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
|
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
|
||||||
|
|
||||||
|
|
|
@ -85,15 +85,22 @@ static void add_push_key(u8 **scriptp, const struct pubkey *key)
|
||||||
add_push_bytes(scriptp, key->key, pubkey_len(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)
|
static void add_push_sig(u8 **scriptp, const struct bitcoin_signature *sig)
|
||||||
{
|
{
|
||||||
|
/* Bitcoin wants DER encoding. */
|
||||||
|
#ifdef SCRIPTS_USE_DER
|
||||||
u8 der[73];
|
u8 der[73];
|
||||||
size_t len = signature_to_der(der, &sig->sig);
|
size_t len = signature_to_der(der, &sig->sig);
|
||||||
|
|
||||||
/* Append sighash type */
|
/* Append sighash type */
|
||||||
der[len++] = sig->stype;
|
der[len++] = sig->stype;
|
||||||
add_push_bytes(scriptp, der, len);
|
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? */
|
/* FIXME: permute? */
|
||||||
|
|
Loading…
Add table
Reference in a new issue