mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
script: Use pkh to construct p2pkh output scripts
So far we always needed to know the public key, which was not the case for addresses that we don't own. Moving the hashing outside of the script construction allows us to send to arbitrary addresses. I also added the hash computation to the pubkey primitives.
This commit is contained in:
committed by
Rusty Russell
parent
f10b779c83
commit
40165ba6d5
@@ -99,3 +99,13 @@ static char *privkey_to_hexstr(const tal_t *ctx, const struct privkey *secret)
|
||||
}
|
||||
REGISTER_TYPE_TO_STRING(privkey, privkey_to_hexstr);
|
||||
REGISTER_TYPE_TO_HEXSTR(secret);
|
||||
|
||||
void pubkey_to_hash160(const struct pubkey *pk, struct ripemd160 *hash)
|
||||
{
|
||||
u8 der[PUBKEY_DER_LEN];
|
||||
struct sha256 h;
|
||||
|
||||
pubkey_to_der(der, pk);
|
||||
sha256(&h, der, sizeof(der));
|
||||
ripemd160(hash, h.u.u8, sizeof(h));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user