mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
lightningd: export bitcoin_pubkey as bip32_pubkey.
We're going to need it. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
2874e46c69
commit
afc31cd68f
@ -246,3 +246,20 @@ const struct utxo **build_utxos(const tal_t *ctx,
|
|||||||
|
|
||||||
return tal_free(utxos);
|
return tal_free(utxos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool bip32_pubkey(const struct ext_key *bip32_base,
|
||||||
|
struct pubkey *pubkey, u32 index)
|
||||||
|
{
|
||||||
|
struct ext_key ext;
|
||||||
|
|
||||||
|
assert(index < BIP32_INITIAL_HARDENED_CHILD);
|
||||||
|
if (bip32_key_from_parent(bip32_base, index,
|
||||||
|
BIP32_FLAG_KEY_PUBLIC, &ext) != WALLY_OK)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!secp256k1_ec_pubkey_parse(secp256k1_ctx, &pubkey->pubkey,
|
||||||
|
ext.pub_key, sizeof(ext.pub_key)))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -13,4 +13,9 @@ const struct utxo **build_utxos(const tal_t *ctx,
|
|||||||
|
|
||||||
/* Once we've spent them, mark them confirmed. */
|
/* Once we've spent them, mark them confirmed. */
|
||||||
void confirm_utxos(struct lightningd *ld, const struct utxo **utxos);
|
void confirm_utxos(struct lightningd *ld, const struct utxo **utxos);
|
||||||
|
|
||||||
|
struct ext_key;
|
||||||
|
bool bip32_pubkey(const struct ext_key *bip32_base,
|
||||||
|
struct pubkey *pubkey, u32 index);
|
||||||
|
|
||||||
#endif /* LIGHTNING_LIGHTNINGD_BUILD_UTXOS_H */
|
#endif /* LIGHTNING_LIGHTNINGD_BUILD_UTXOS_H */
|
||||||
|
@ -36,22 +36,6 @@ static void destroy_peer(struct peer *peer)
|
|||||||
peer->condition);
|
peer->condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bitcoin_pubkey(struct lightningd *ld,
|
|
||||||
struct pubkey *pubkey, u32 index)
|
|
||||||
{
|
|
||||||
struct ext_key ext;
|
|
||||||
|
|
||||||
assert(index < BIP32_INITIAL_HARDENED_CHILD);
|
|
||||||
assert(index < ld->bip32_max_index);
|
|
||||||
if (bip32_key_from_parent(ld->bip32_base, index,
|
|
||||||
BIP32_FLAG_KEY_PUBLIC, &ext) != WALLY_OK)
|
|
||||||
fatal("BIP32 of %u failed", index);
|
|
||||||
|
|
||||||
if (!secp256k1_ec_pubkey_parse(secp256k1_ctx, &pubkey->pubkey,
|
|
||||||
ext.pub_key, sizeof(ext.pub_key)))
|
|
||||||
fatal("Parse of BIP32 child %u pubkey failed", index);
|
|
||||||
}
|
|
||||||
|
|
||||||
void peer_set_condition(struct peer *peer, const char *fmt, ...)
|
void peer_set_condition(struct peer *peer, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
@ -591,8 +575,10 @@ static void opening_gen_funding(struct subdaemon *opening, const u8 *resp,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fc->change)
|
if (fc->change
|
||||||
bitcoin_pubkey(fc->peer->ld, &changekey, fc->change_keyindex);
|
&& !bip32_pubkey(fc->peer->ld->bip32_base,
|
||||||
|
&changekey, fc->change_keyindex))
|
||||||
|
fatal("Error deriving change key %u", fc->change_keyindex);
|
||||||
|
|
||||||
fc->funding_tx = funding_tx(fc, &outnum, fc->utxomap, fc->satoshi,
|
fc->funding_tx = funding_tx(fc, &outnum, fc->utxomap, fc->satoshi,
|
||||||
&fc->local_fundingkey,
|
&fc->local_fundingkey,
|
||||||
|
Loading…
Reference in New Issue
Block a user