mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-09 09:04:25 +01:00
common/derive_basepoints: add routines for marshal/unmarshal.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
committed by
Christian Decker
parent
ad9dbaaa3f
commit
b2b85100d7
@@ -2432,10 +2432,7 @@ static void init_channel(struct peer *peer)
|
||||
&peer->their_commit_sig,
|
||||
&peer->cs,
|
||||
&funding_pubkey[REMOTE],
|
||||
&points[REMOTE].revocation,
|
||||
&points[REMOTE].payment,
|
||||
&points[REMOTE].htlc,
|
||||
&points[REMOTE].delayed_payment,
|
||||
&points[REMOTE],
|
||||
&peer->remote_per_commit,
|
||||
&peer->old_remote_per_commit,
|
||||
&funder,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <common/cryptomsg.h>
|
||||
#include <common/channel_config.h>
|
||||
#include <common/derive_basepoints.h>
|
||||
|
||||
# Begin! (passes gossipd-client fd)
|
||||
channel_init,1000
|
||||
@@ -16,10 +17,7 @@ channel_init,,feerate_max,u32
|
||||
channel_init,,first_commit_sig,secp256k1_ecdsa_signature
|
||||
channel_init,,crypto_state,struct crypto_state
|
||||
channel_init,,remote_fundingkey,struct pubkey
|
||||
channel_init,,remote_revocation_basepoint,struct pubkey
|
||||
channel_init,,remote_payment_basepoint,struct pubkey
|
||||
channel_init,,remote_htlc_basepoint,struct pubkey
|
||||
channel_init,,remote_delayed_payment_basepoint,struct pubkey
|
||||
channel_init,,remote_basepoints,struct basepoints
|
||||
channel_init,,remote_per_commit,struct pubkey
|
||||
channel_init,,old_remote_per_commit,struct pubkey
|
||||
channel_init,,funder,enum side
|
||||
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#include <ccan/crypto/sha256/sha256.h>
|
||||
#include <common/derive_basepoints.h>
|
||||
#include <common/utils.h>
|
||||
#include <wire/wire.h>
|
||||
|
||||
bool derive_basepoints(const struct secret *seed,
|
||||
struct pubkey *funding_pubkey,
|
||||
@@ -85,3 +86,20 @@ bool per_commit_point(const struct sha256 *shaseed,
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void towire_basepoints(u8 **pptr, const struct basepoints *b)
|
||||
{
|
||||
towire_pubkey(pptr, &b->revocation);
|
||||
towire_pubkey(pptr, &b->payment);
|
||||
towire_pubkey(pptr, &b->htlc);
|
||||
towire_pubkey(pptr, &b->delayed_payment);
|
||||
}
|
||||
|
||||
void fromwire_basepoints(const u8 **ptr, size_t *max,
|
||||
struct basepoints *b)
|
||||
{
|
||||
fromwire_pubkey(ptr, max, &b->revocation);
|
||||
fromwire_pubkey(ptr, max, &b->payment);
|
||||
fromwire_pubkey(ptr, max, &b->htlc);
|
||||
fromwire_pubkey(ptr, max, &b->delayed_payment);
|
||||
}
|
||||
|
||||
@@ -75,4 +75,9 @@ static inline u64 revocations_received(const struct shachain *shachain)
|
||||
{
|
||||
return (1ULL << SHACHAIN_BITS) - (shachain_next_index(shachain) + 1);
|
||||
}
|
||||
|
||||
void towire_basepoints(u8 **pptr, const struct basepoints *b);
|
||||
void fromwire_basepoints(const u8 **ptr, size_t *max,
|
||||
struct basepoints *b);
|
||||
|
||||
#endif /* LIGHTNING_COMMON_DERIVE_BASEPOINTS_H */
|
||||
|
||||
@@ -260,10 +260,7 @@ bool peer_start_channeld(struct channel *channel,
|
||||
&channel->last_sig,
|
||||
cs,
|
||||
&channel->channel_info.remote_fundingkey,
|
||||
&channel->channel_info.theirbase.revocation,
|
||||
&channel->channel_info.theirbase.payment,
|
||||
&channel->channel_info.theirbase.htlc,
|
||||
&channel->channel_info.theirbase.delayed_payment,
|
||||
&channel->channel_info.theirbase,
|
||||
&channel->channel_info.remote_per_commit,
|
||||
&channel->channel_info.old_remote_per_commit,
|
||||
channel->funder,
|
||||
|
||||
@@ -440,16 +440,13 @@ enum watch_result onchaind_funding_spent(struct channel *channel,
|
||||
channel->our_config.to_self_delay,
|
||||
get_feerate(ld->topology, FEERATE_NORMAL),
|
||||
channel->our_config.dust_limit_satoshis,
|
||||
&channel->channel_info.theirbase.revocation,
|
||||
&our_last_txid,
|
||||
p2wpkh_for_keyidx(tmpctx, ld,
|
||||
channel->final_key_idx),
|
||||
channel->remote_shutdown_scriptpubkey,
|
||||
&final_key,
|
||||
channel->funder,
|
||||
&channel->channel_info.theirbase.payment,
|
||||
&channel->channel_info.theirbase.htlc,
|
||||
&channel->channel_info.theirbase.delayed_payment,
|
||||
&channel->channel_info.theirbase,
|
||||
tx,
|
||||
blockheight,
|
||||
/* FIXME: config for 'reasonable depth' */
|
||||
|
||||
@@ -2136,11 +2136,9 @@ int main(int argc, char *argv[])
|
||||
const tal_t *ctx = tal(NULL, char);
|
||||
u8 *msg;
|
||||
struct secret seed;
|
||||
struct pubkey remote_payment_basepoint, remote_htlc_basepoint,
|
||||
remote_per_commit_point, old_remote_per_commit_point,
|
||||
remote_revocation_basepoint, remote_delayed_payment_basepoint;
|
||||
struct pubkey remote_per_commit_point, old_remote_per_commit_point;
|
||||
enum side funder;
|
||||
struct basepoints basepoints;
|
||||
struct basepoints basepoints, remote_basepoints;
|
||||
struct shachain shachain;
|
||||
struct bitcoin_tx *tx;
|
||||
struct secrets secrets;
|
||||
@@ -2170,15 +2168,12 @@ int main(int argc, char *argv[])
|
||||
&to_self_delay[REMOTE],
|
||||
&feerate_per_kw,
|
||||
&dust_limit_satoshis,
|
||||
&remote_revocation_basepoint,
|
||||
&our_broadcast_txid,
|
||||
&scriptpubkey[LOCAL],
|
||||
&scriptpubkey[REMOTE],
|
||||
&our_wallet_pubkey,
|
||||
&funder,
|
||||
&remote_payment_basepoint,
|
||||
&remote_htlc_basepoint,
|
||||
&remote_delayed_payment_basepoint,
|
||||
&remote_basepoints,
|
||||
&tx,
|
||||
&tx_blockheight,
|
||||
&reasonable_depth,
|
||||
@@ -2246,7 +2241,7 @@ int main(int argc, char *argv[])
|
||||
struct sha256 revocation_preimage;
|
||||
u64 commit_num = unmask_commit_number(tx, funder,
|
||||
&basepoints.payment,
|
||||
&remote_payment_basepoint);
|
||||
&remote_basepoints.payment);
|
||||
|
||||
status_trace("commitnum = %"PRIu64
|
||||
", revocations_received = %"PRIu64,
|
||||
@@ -2256,10 +2251,10 @@ int main(int argc, char *argv[])
|
||||
handle_our_unilateral(tx, tx_blockheight, &txid,
|
||||
&secrets,
|
||||
&shaseed,
|
||||
&remote_revocation_basepoint,
|
||||
&remote_payment_basepoint,
|
||||
&remote_basepoints.revocation,
|
||||
&remote_basepoints.payment,
|
||||
&basepoints.payment,
|
||||
&remote_htlc_basepoint,
|
||||
&remote_basepoints.htlc,
|
||||
&basepoints.htlc,
|
||||
&basepoints.delayed_payment,
|
||||
commit_num,
|
||||
@@ -2283,10 +2278,10 @@ int main(int argc, char *argv[])
|
||||
&secrets,
|
||||
&basepoints.revocation,
|
||||
&basepoints.payment,
|
||||
&remote_payment_basepoint,
|
||||
&remote_basepoints.payment,
|
||||
&basepoints.htlc,
|
||||
&remote_htlc_basepoint,
|
||||
&remote_delayed_payment_basepoint,
|
||||
&remote_basepoints.htlc,
|
||||
&remote_basepoints.delayed_payment,
|
||||
commit_num,
|
||||
htlcs,
|
||||
tell_if_missing, tell_immediately,
|
||||
@@ -2307,10 +2302,10 @@ int main(int argc, char *argv[])
|
||||
&old_remote_per_commit_point,
|
||||
&basepoints.revocation,
|
||||
&basepoints.payment,
|
||||
&remote_payment_basepoint,
|
||||
&remote_htlc_basepoint,
|
||||
&remote_basepoints.payment,
|
||||
&remote_basepoints.htlc,
|
||||
&basepoints.htlc,
|
||||
&remote_delayed_payment_basepoint,
|
||||
&remote_basepoints.delayed_payment,
|
||||
commit_num,
|
||||
htlcs,
|
||||
tell_if_missing,
|
||||
@@ -2323,10 +2318,10 @@ int main(int argc, char *argv[])
|
||||
&remote_per_commit_point,
|
||||
&basepoints.revocation,
|
||||
&basepoints.payment,
|
||||
&remote_payment_basepoint,
|
||||
&remote_htlc_basepoint,
|
||||
&remote_basepoints.payment,
|
||||
&remote_basepoints.htlc,
|
||||
&basepoints.htlc,
|
||||
&remote_delayed_payment_basepoint,
|
||||
&remote_basepoints.delayed_payment,
|
||||
commit_num,
|
||||
htlcs,
|
||||
tell_if_missing,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include <common/derive_basepoints.h>
|
||||
#include <common/htlc_wire.h>
|
||||
|
||||
# Begin! Here's the onchain tx which spends funding tx, followed by all HTLCs.
|
||||
onchain_init,5001
|
||||
onchain_init,,seed,struct secret
|
||||
@@ -12,7 +14,6 @@ onchain_init,,local_to_self_delay,u32
|
||||
onchain_init,,remote_to_self_delay,u32
|
||||
onchain_init,,feerate_per_kw,u32
|
||||
onchain_init,,local_dust_limit_satoshi,u64
|
||||
onchain_init,,remote_revocation_basepoint,struct pubkey
|
||||
# Gives an easy way to tell if it's our unilateral close or theirs...
|
||||
onchain_init,,our_broadcast_txid,struct bitcoin_txid
|
||||
onchain_init,,local_scriptpubkey_len,u16
|
||||
@@ -22,9 +23,7 @@ onchain_init,,remote_scriptpubkey,remote_scriptpubkey_len*u8
|
||||
onchain_init,,ourwallet_pubkey,struct pubkey
|
||||
# We need these two for commit number obscurer
|
||||
onchain_init,,funder,enum side
|
||||
onchain_init,,remote_payment_basepoint,struct pubkey
|
||||
onchain_init,,remote_htlc_basepoint,struct pubkey
|
||||
onchain_init,,remote_delayed_payment_basepoint,struct pubkey
|
||||
onchain_init,,remote_basepoints,struct basepoints
|
||||
onchain_init,,tx,struct bitcoin_tx
|
||||
onchain_init,,tx_blockheight,u32
|
||||
onchain_init,,reasonable_depth,u32
|
||||
|
||||
|
@@ -55,7 +55,7 @@ bool fromwire_onchain_depth(const void *p UNNEEDED, struct bitcoin_txid *txid UN
|
||||
bool fromwire_onchain_htlc(const void *p UNNEEDED, struct htlc_stub *htlc UNNEEDED, bool *tell_if_missing UNNEEDED, bool *tell_immediately UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_onchain_htlc called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_onchain_init */
|
||||
bool fromwire_onchain_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct secret *seed UNNEEDED, struct shachain *shachain UNNEEDED, u64 *funding_amount_satoshi UNNEEDED, struct pubkey *old_remote_per_commitment_point UNNEEDED, struct pubkey *remote_per_commitment_point UNNEEDED, u32 *local_to_self_delay UNNEEDED, u32 *remote_to_self_delay UNNEEDED, u32 *feerate_per_kw UNNEEDED, u64 *local_dust_limit_satoshi UNNEEDED, struct pubkey *remote_revocation_basepoint UNNEEDED, struct bitcoin_txid *our_broadcast_txid UNNEEDED, u8 **local_scriptpubkey UNNEEDED, u8 **remote_scriptpubkey UNNEEDED, struct pubkey *ourwallet_pubkey UNNEEDED, enum side *funder UNNEEDED, struct pubkey *remote_payment_basepoint UNNEEDED, struct pubkey *remote_htlc_basepoint UNNEEDED, struct pubkey *remote_delayed_payment_basepoint UNNEEDED, struct bitcoin_tx **tx UNNEEDED, u32 *tx_blockheight UNNEEDED, u32 *reasonable_depth UNNEEDED, secp256k1_ecdsa_signature **htlc_signature UNNEEDED, u64 *num_htlcs UNNEEDED, u32 *min_possible_feerate UNNEEDED, u32 *max_possible_feerate UNNEEDED)
|
||||
bool fromwire_onchain_init(const tal_t *ctx UNNEEDED, const void *p UNNEEDED, struct secret *seed UNNEEDED, struct shachain *shachain UNNEEDED, u64 *funding_amount_satoshi UNNEEDED, struct pubkey *old_remote_per_commitment_point UNNEEDED, struct pubkey *remote_per_commitment_point UNNEEDED, u32 *local_to_self_delay UNNEEDED, u32 *remote_to_self_delay UNNEEDED, u32 *feerate_per_kw UNNEEDED, u64 *local_dust_limit_satoshi UNNEEDED, struct bitcoin_txid *our_broadcast_txid UNNEEDED, u8 **local_scriptpubkey UNNEEDED, u8 **remote_scriptpubkey UNNEEDED, struct pubkey *ourwallet_pubkey UNNEEDED, enum side *funder UNNEEDED, struct basepoints *remote_basepoints UNNEEDED, struct bitcoin_tx **tx UNNEEDED, u32 *tx_blockheight UNNEEDED, u32 *reasonable_depth UNNEEDED, secp256k1_ecdsa_signature **htlc_signature UNNEEDED, u64 *num_htlcs UNNEEDED, u32 *min_possible_feerate UNNEEDED, u32 *max_possible_feerate UNNEEDED)
|
||||
{ fprintf(stderr, "fromwire_onchain_init called!\n"); abort(); }
|
||||
/* Generated stub for fromwire_onchain_known_preimage */
|
||||
bool fromwire_onchain_known_preimage(const void *p UNNEEDED, struct preimage *preimage UNNEEDED)
|
||||
|
||||
Reference in New Issue
Block a user