Skip to content

Commit 0d77e7c

Browse files
committed
Three small fixes to work around our bindings generator limitations
* Return Self instead of the fully-written types for constructors, * Place definitions before use (in this case for KeysInterface), * Don't import foo::bar::self, but import foo::bar + a spelling fix in the KeysInterface docs for get_onion_rand.
1 parent 9d4b6e7 commit 0d77e7c

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

lightning/src/chain/keysinterface.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -140,28 +140,6 @@ impl Readable for SpendableOutputDescriptor {
140140
}
141141
}
142142

143-
/// A trait to describe an object which can get user secrets and key material.
144-
pub trait KeysInterface: Send + Sync {
145-
/// A type which implements ChannelKeys which will be returned by get_channel_keys.
146-
type ChanKeySigner : ChannelKeys;
147-
148-
/// Get node secret key (aka node_id or network_key)
149-
fn get_node_secret(&self) -> SecretKey;
150-
/// Get destination redeemScript to encumber static protocol exit points.
151-
fn get_destination_script(&self) -> Script;
152-
/// Get shutdown_pubkey to use as PublicKey at channel closure
153-
fn get_shutdown_pubkey(&self) -> PublicKey;
154-
/// Get a new set of ChannelKeys for per-channel secrets. These MUST be unique even if you
155-
/// restarted with some stale data!
156-
fn get_channel_keys(&self, inbound: bool, channel_value_satoshis: u64) -> Self::ChanKeySigner;
157-
/// Get a secret and PRNG seed for construting an onion packet
158-
fn get_onion_rand(&self) -> (SecretKey, [u8; 32]);
159-
/// Get a unique temporary channel id. Channels will be referred to by this until the funding
160-
/// transaction is created, at which point they will use the outpoint in the funding
161-
/// transaction.
162-
fn get_channel_id(&self) -> [u8; 32];
163-
}
164-
165143
/// Set of lightning keys needed to operate a channel as described in BOLT 3.
166144
///
167145
/// Signing services could be implemented on a hardware wallet. In this case,
@@ -267,6 +245,28 @@ pub trait ChannelKeys : Send+Clone {
267245
fn set_remote_channel_pubkeys(&mut self, channel_points: &ChannelPublicKeys);
268246
}
269247

248+
/// A trait to describe an object which can get user secrets and key material.
249+
pub trait KeysInterface: Send + Sync {
250+
/// A type which implements ChannelKeys which will be returned by get_channel_keys.
251+
type ChanKeySigner : ChannelKeys;
252+
253+
/// Get node secret key (aka node_id or network_key)
254+
fn get_node_secret(&self) -> SecretKey;
255+
/// Get destination redeemScript to encumber static protocol exit points.
256+
fn get_destination_script(&self) -> Script;
257+
/// Get shutdown_pubkey to use as PublicKey at channel closure
258+
fn get_shutdown_pubkey(&self) -> PublicKey;
259+
/// Get a new set of ChannelKeys for per-channel secrets. These MUST be unique even if you
260+
/// restarted with some stale data!
261+
fn get_channel_keys(&self, inbound: bool, channel_value_satoshis: u64) -> Self::ChanKeySigner;
262+
/// Get a secret and PRNG seed for constructing an onion packet
263+
fn get_onion_rand(&self) -> (SecretKey, [u8; 32]);
264+
/// Get a unique temporary channel id. Channels will be referred to by this until the funding
265+
/// transaction is created, at which point they will use the outpoint in the funding
266+
/// transaction.
267+
fn get_channel_id(&self) -> [u8; 32];
268+
}
269+
270270
#[derive(Clone)]
271271
/// A simple implementation of ChannelKeys that just keeps the private keys in memory.
272272
pub struct InMemoryChannelKeys {
@@ -506,7 +506,7 @@ impl KeysManager {
506506
/// Note that until the 0.1 release there is no guarantee of backward compatibility between
507507
/// versions. Once the library is more fully supported, the docs will be updated to include a
508508
/// detailed description of the guarantee.
509-
pub fn new(seed: &[u8; 32], network: Network, starting_time_secs: u64, starting_time_nanos: u32) -> KeysManager {
509+
pub fn new(seed: &[u8; 32], network: Network, starting_time_secs: u64, starting_time_nanos: u32) -> Self {
510510
let secp_ctx = Secp256k1::signing_only();
511511
match ExtendedPrivKey::new_master(network.clone(), seed) {
512512
Ok(master_key) => {

lightning/src/ln/chan_utils.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
use bitcoin::blockdata::script::{Script,Builder};
66
use bitcoin::blockdata::opcodes;
77
use bitcoin::blockdata::transaction::{TxIn,TxOut,OutPoint,Transaction, SigHashType};
8-
use bitcoin::consensus::encode::{self, Decodable, Encodable};
8+
use bitcoin::consensus::encode::{Decodable, Encodable};
9+
use bitcoin::consensus::encode;
910
use bitcoin::util::bip143;
1011

1112
use bitcoin::hashes::{Hash, HashEngine};

0 commit comments

Comments
 (0)