Skip to content

Commit 1331727

Browse files
committed
Make inner key public, so a struct can be instantiated by simply let payment_key = DelayedPaymentKey(pk).
1 parent 90e24a5 commit 1331727

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

lightning/src/ln/channel_keys.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use bitcoin::secp256k1::Secp256k1;
1818
use bitcoin::secp256k1;
1919
use crate::ln::msgs::DecodeError;
2020
use crate::util::ser::Readable;
21-
use bitcoin::secp256k1::constants::PUBLIC_KEY_SIZE;
2221
use crate::io;
2322
use crate::util::ser::Writer;
2423
use crate::util::ser::Writeable;
@@ -80,10 +79,6 @@ macro_rules! key_read_write {
8079
fn write<W: Writer>(&self, w: &mut W) -> Result<(), io::Error> {
8180
self.0.serialize().write(w)
8281
}
83-
84-
fn serialized_length(&self) -> usize {
85-
PUBLIC_KEY_SIZE
86-
}
8782
}
8883

8984
impl Readable for $SelfT {
@@ -99,14 +94,14 @@ macro_rules! key_read_write {
9994

10095
/// Used to generate [`local_delayedpubkey`](https://github.com/lightning/bolts/blob/master/03-transactions.md#key-derivation) for the latest state of a channel.
10196
#[derive(PartialEq, Eq, Clone, Copy, Debug, Hash)]
102-
pub struct DelayedPaymentBasepoint(PublicKey);
97+
pub struct DelayedPaymentBasepoint(pub PublicKey);
10398
basepoint_impl!(DelayedPaymentBasepoint);
10499
key_read_write!(DelayedPaymentBasepoint);
105100

106101
/// [delayedpubkey](https://github.com/lightning/bolts/blob/master/03-transactions.md#localpubkey-local_htlcpubkey-remote_htlcpubkey-local_delayedpubkey-and-remote_delayedpubkey-derivation)
107102
/// Used to regenerate the scripts required for a penalty transaction or a spend from a force closed channel.
108103
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
109-
pub struct DelayedPaymentKey(PublicKey);
104+
pub struct DelayedPaymentKey(pub PublicKey);
110105

111106
impl DelayedPaymentKey {
112107
key_impl!(DelayedPaymentBasepoint, "delayedpubkey");
@@ -115,15 +110,15 @@ key_read_write!(DelayedPaymentKey);
115110

116111
/// Used to generate [localpubkey](https://github.com/lightning/bolts/blob/master/03-transactions.md#key-derivation) for the latest state of a channel.
117112
#[derive(PartialEq, Eq, Clone, Copy, Debug, Hash)]
118-
pub struct PaymentBasepoint(PublicKey);
113+
pub struct PaymentBasepoint(pub PublicKey);
119114
basepoint_impl!(PaymentBasepoint);
120115
key_read_write!(PaymentBasepoint);
121116

122117

123118
/// [localpubkey](https://github.com/lightning/bolts/blob/master/03-transactions.md#localpubkey-local_htlcpubkey-remote_htlcpubkey-local_delayedpubkey-and-remote_delayedpubkey-derivation)
124119
/// Used to generate commitment transaction's to_remote ouput.
125120
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
126-
pub struct PaymentKey(PublicKey);
121+
pub struct PaymentKey(pub PublicKey);
127122

128123
impl PaymentKey {
129124
key_impl!(PaymentBasepoint, "localpubkey");
@@ -132,15 +127,15 @@ key_read_write!(PaymentKey);
132127

133128
/// Used to generate [htlcpubkey](https://github.com/lightning/bolts/blob/master/03-transactions.md#key-derivation) for the latest state of a channel.
134129
#[derive(PartialEq, Eq, Clone, Copy, Debug, Hash)]
135-
pub struct HtlcBasepoint(PublicKey);
130+
pub struct HtlcBasepoint(pub PublicKey);
136131
basepoint_impl!(HtlcBasepoint);
137132
key_read_write!(HtlcBasepoint);
138133

139134

140135
/// [htlcpubkey](https://github.com/lightning/bolts/blob/master/03-transactions.md#localpubkey-local_htlcpubkey-remote_htlcpubkey-local_delayedpubkey-and-remote_delayedpubkey-derivation)
141136
/// Used to generate HTLC outputs.
142137
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
143-
pub struct HtlcKey(PublicKey);
138+
pub struct HtlcKey(pub PublicKey);
144139

145140
impl HtlcKey {
146141
key_impl!(HtlcBasepoint, "htlcpubkey");
@@ -164,15 +159,15 @@ fn derive_public_key<T: secp256k1::Signing>(secp_ctx: &Secp256k1<T>, per_commitm
164159

165160
/// Used to generate [htlcpubkey](https://github.com/lightning/bolts/blob/master/03-transactions.md#key-derivation) for the latest state of a channel.
166161
#[derive(PartialEq, Eq, Clone, Copy, Debug, Hash)]
167-
pub struct RevocationBasepoint(PublicKey);
162+
pub struct RevocationBasepoint(pub PublicKey);
168163
basepoint_impl!(RevocationBasepoint);
169164
key_read_write!(RevocationBasepoint);
170165

171166

172167
/// [htlcpubkey](https://github.com/lightning/bolts/blob/master/03-transactions.md#localpubkey-local_htlcpubkey-remote_htlcpubkey-local_delayedpubkey-and-remote_delayedpubkey-derivation)
173168
/// Used to generate HTLC outputs.
174169
#[derive(PartialEq, Eq, Clone, Copy, Debug, Hash)]
175-
pub struct RevocationKey(PublicKey);
170+
pub struct RevocationKey(pub PublicKey);
176171

177172
impl RevocationKey {
178173
/// Derives a per-commitment-transaction revocation public key from its constituent parts. This is

0 commit comments

Comments
 (0)