mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +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:
@@ -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? */
|
||||
|
||||
Reference in New Issue
Block a user