mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 18:11:28 +01:00
8c22bd9ee1
For future reference, done via: for f in `find wire/ bitcoin/ common/ lightningd -name '*.h' ! -name 'gen*'`; do ID=`echo -n LIGHTNING/$f | tr 'a-z' 'A-Z' | tr -cs 'A-Z0-9' _`; sed 's/^#\(ifndef\|define\) .*_H$/#\1 '$ID/ < $f | sed 's,#endif /..*_H ./$,#endif /* '$ID' */,' | bagto $f; done Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
49 lines
1.6 KiB
C
49 lines
1.6 KiB
C
#ifndef LIGHTNING_BITCOIN_PUBKEY_H
|
|
#define LIGHTNING_BITCOIN_PUBKEY_H
|
|
#include "config.h"
|
|
#include <ccan/crypto/ripemd160/ripemd160.h>
|
|
#include <ccan/crypto/sha256/sha256.h>
|
|
#include <ccan/short_types/short_types.h>
|
|
#include <ccan/tal/tal.h>
|
|
#include <secp256k1.h>
|
|
|
|
struct privkey;
|
|
|
|
#define PUBKEY_DER_LEN 33
|
|
|
|
struct pubkey {
|
|
/* Unpacked pubkey (as used by libsecp256k1 internally) */
|
|
secp256k1_pubkey pubkey;
|
|
};
|
|
|
|
/* Convert from hex string of DER (scriptPubKey from validateaddress) */
|
|
bool pubkey_from_hexstr(const char *derstr, size_t derlen, struct pubkey *key);
|
|
|
|
/* Convert from hex string of DER (scriptPubKey from validateaddress) */
|
|
char *pubkey_to_hexstr(const tal_t *ctx, const struct pubkey *key);
|
|
|
|
/* Convenience wrapper for a raw secp256k1_pubkey */
|
|
char *secp256k1_pubkey_to_hexstr(const tal_t *ctx, const secp256k1_pubkey *key);
|
|
|
|
/* Pubkey from privkey */
|
|
bool pubkey_from_privkey(const struct privkey *privkey,
|
|
struct pubkey *key);
|
|
|
|
/* Pubkey from DER encoding. */
|
|
bool pubkey_from_der(const u8 *der, size_t len, struct pubkey *key);
|
|
|
|
/* Pubkey to DER encoding: must be valid pubkey. */
|
|
void pubkey_to_der(u8 der[PUBKEY_DER_LEN], const struct pubkey *key);
|
|
|
|
/* Are these keys equal? */
|
|
bool pubkey_eq(const struct pubkey *a, const struct pubkey *b);
|
|
|
|
/* Compare the keys `a` and `b`. Return <0 if `a`<`b`, 0 if equal and >0 otherwise */
|
|
int pubkey_cmp(const struct pubkey *a, const struct pubkey *b);
|
|
|
|
/**
|
|
* pubkey_to_hash160 - Get the hash for p2pkh payments for a given pubkey
|
|
*/
|
|
void pubkey_to_hash160(const struct pubkey *pk, struct ripemd160 *hash);
|
|
#endif /* LIGHTNING_BITCOIN_PUBKEY_H */
|