fn funding_key<'a>(&'a self) -> &'a SecretKey;
/// Gets the local secret key for blinded revocation pubkey
fn revocation_base_key<'a>(&'a self) -> &'a SecretKey;
- /// Gets the local secret key used in to_remote output of remote commitment tx
- /// (and also as part of obscured commitment number)
- fn payment_base_key<'a>(&'a self) -> &'a SecretKey;
+ /// Gets the local secret key used in the to_remote output of remote commitment tx (ie the
+ /// output to us in transactions our counterparty broadcasts).
+ /// Also as part of obscured commitment number.
+ fn payment_key<'a>(&'a self) -> &'a SecretKey;
/// Gets the local secret key used in HTLC-Success/HTLC-Timeout txn and to_local output
fn delayed_payment_base_key<'a>(&'a self) -> &'a SecretKey;
/// Gets the local htlc secret key used in commitment tx htlc outputs
funding_key: SecretKey,
/// Local secret key for blinded revocation pubkey
revocation_base_key: SecretKey,
- /// Local secret key used in commitment tx htlc outputs
- payment_base_key: SecretKey,
+ /// Local secret key used for our balance in remote-broadcasted commitment transactions
+ payment_key: SecretKey,
/// Local secret key used in HTLC tx
delayed_payment_base_key: SecretKey,
/// Local htlc secret key used in commitment tx htlc outputs
secp_ctx: &Secp256k1<C>,
funding_key: SecretKey,
revocation_base_key: SecretKey,
- payment_base_key: SecretKey,
+ payment_key: SecretKey,
delayed_payment_base_key: SecretKey,
htlc_base_key: SecretKey,
commitment_seed: [u8; 32],
channel_value_satoshis: u64) -> InMemoryChannelKeys {
let local_channel_pubkeys =
InMemoryChannelKeys::make_local_keys(secp_ctx, &funding_key, &revocation_base_key,
- &payment_base_key, &delayed_payment_base_key,
+ &payment_key, &delayed_payment_base_key,
&htlc_base_key);
InMemoryChannelKeys {
funding_key,
revocation_base_key,
- payment_base_key,
+ payment_key,
delayed_payment_base_key,
htlc_base_key,
commitment_seed,
fn make_local_keys<C: Signing>(secp_ctx: &Secp256k1<C>,
funding_key: &SecretKey,
revocation_base_key: &SecretKey,
- payment_base_key: &SecretKey,
+ payment_key: &SecretKey,
delayed_payment_base_key: &SecretKey,
htlc_base_key: &SecretKey) -> ChannelPublicKeys {
let from_secret = |s: &SecretKey| PublicKey::from_secret_key(secp_ctx, s);
ChannelPublicKeys {
funding_pubkey: from_secret(&funding_key),
revocation_basepoint: from_secret(&revocation_base_key),
- payment_basepoint: from_secret(&payment_base_key),
+ payment_point: from_secret(&payment_key),
delayed_payment_basepoint: from_secret(&delayed_payment_base_key),
htlc_basepoint: from_secret(&htlc_base_key),
}
impl ChannelKeys for InMemoryChannelKeys {
fn funding_key(&self) -> &SecretKey { &self.funding_key }
fn revocation_base_key(&self) -> &SecretKey { &self.revocation_base_key }
- fn payment_base_key(&self) -> &SecretKey { &self.payment_base_key }
+ fn payment_key(&self) -> &SecretKey { &self.payment_key }
fn delayed_payment_base_key(&self) -> &SecretKey { &self.delayed_payment_base_key }
fn htlc_base_key(&self) -> &SecretKey { &self.htlc_base_key }
fn commitment_seed(&self) -> &[u8; 32] { &self.commitment_seed }
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error> {
self.funding_key.write(writer)?;
self.revocation_base_key.write(writer)?;
- self.payment_base_key.write(writer)?;
+ self.payment_key.write(writer)?;
self.delayed_payment_base_key.write(writer)?;
self.htlc_base_key.write(writer)?;
self.commitment_seed.write(writer)?;
fn read<R: ::std::io::Read>(reader: &mut R) -> Result<Self, DecodeError> {
let funding_key = Readable::read(reader)?;
let revocation_base_key = Readable::read(reader)?;
- let payment_base_key = Readable::read(reader)?;
+ let payment_key = Readable::read(reader)?;
let delayed_payment_base_key = Readable::read(reader)?;
let htlc_base_key = Readable::read(reader)?;
let commitment_seed = Readable::read(reader)?;
let secp_ctx = Secp256k1::signing_only();
let local_channel_pubkeys =
InMemoryChannelKeys::make_local_keys(&secp_ctx, &funding_key, &revocation_base_key,
- &payment_base_key, &delayed_payment_base_key,
+ &payment_key, &delayed_payment_base_key,
&htlc_base_key);
Ok(InMemoryChannelKeys {
funding_key,
revocation_base_key,
- payment_base_key,
+ payment_key,
delayed_payment_base_key,
htlc_base_key,
commitment_seed,
}
let funding_key = key_step!(b"funding key", commitment_seed);
let revocation_base_key = key_step!(b"revocation base key", funding_key);
- let payment_base_key = key_step!(b"payment base key", revocation_base_key);
- let delayed_payment_base_key = key_step!(b"delayed payment base key", payment_base_key);
+ let payment_key = key_step!(b"payment key", revocation_base_key);
+ let delayed_payment_base_key = key_step!(b"delayed payment base key", payment_key);
let htlc_base_key = key_step!(b"HTLC base key", delayed_payment_base_key);
InMemoryChannelKeys::new(
&self.secp_ctx,
funding_key,
revocation_base_key,
- payment_base_key,
+ payment_key,
delayed_payment_base_key,
htlc_base_key,
commitment_seed,
/// a commitment transaction so that their counterparty can claim all available funds if they
/// broadcast an old state.
pub revocation_basepoint: PublicKey,
- /// The base point which is used (with derive_public_key) to derive a per-commitment payment
- /// public key which receives immediately-spendable non-HTLC-encumbered funds.
- pub payment_basepoint: PublicKey,
+ /// The public key which receives our immediately spendable primary channel balance in
+ /// remote-broadcasted commitment transactions. This key is static across every commitment
+ /// transaction.
+ pub payment_point: PublicKey,
/// The base point which is used (with derive_public_key) to derive a per-commitment payment
/// public key which receives non-HTLC-encumbered funds which are only available for spending
/// after some delay (or can be claimed via the revocation path).
impl_writeable!(ChannelPublicKeys, 33*5, {
funding_pubkey,
revocation_basepoint,
- payment_basepoint,
+ payment_point,
delayed_payment_basepoint,
htlc_basepoint
});
let their_pubkeys = ChannelPublicKeys {
funding_pubkey: msg.funding_pubkey,
revocation_basepoint: msg.revocation_basepoint,
- payment_basepoint: msg.payment_basepoint,
+ payment_point: msg.payment_point,
delayed_payment_basepoint: msg.delayed_payment_basepoint,
htlc_basepoint: msg.htlc_basepoint
};
fn get_commitment_transaction_number_obscure_factor(&self) -> u64 {
let mut sha = Sha256::engine();
- let our_payment_basepoint = PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_base_key());
+ let our_payment_point = PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_key());
- let their_payment_basepoint = &self.their_pubkeys.as_ref().unwrap().payment_basepoint.serialize();
+ let their_payment_point = &self.their_pubkeys.as_ref().unwrap().payment_point.serialize();
if self.channel_outbound {
- sha.input(&our_payment_basepoint.serialize());
- sha.input(their_payment_basepoint);
+ sha.input(&our_payment_point.serialize());
+ sha.input(their_payment_point);
} else {
- sha.input(their_payment_basepoint);
- sha.input(&our_payment_basepoint.serialize());
+ sha.input(their_payment_point);
+ sha.input(&our_payment_point.serialize());
}
let res = Sha256::from_engine(sha).into_inner();
if value_to_b >= (dust_limit_satoshis as i64) {
log_trace!(self, " ...including {} output with value {}", if local { "to_remote" } else { "to_local" }, value_to_b);
let static_payment_pk = if local {
- self.their_pubkeys.as_ref().unwrap().payment_basepoint
+ self.their_pubkeys.as_ref().unwrap().payment_point
} else {
- self.local_keys.pubkeys().payment_basepoint
+ self.local_keys.pubkeys().payment_point
}.serialize();
txouts.push((TxOut {
script_pubkey: Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0)
let their_pubkeys = ChannelPublicKeys {
funding_pubkey: msg.funding_pubkey,
revocation_basepoint: msg.revocation_basepoint,
- payment_basepoint: msg.payment_basepoint,
+ payment_point: msg.payment_point,
delayed_payment_basepoint: msg.delayed_payment_basepoint,
htlc_basepoint: msg.htlc_basepoint
};
max_accepted_htlcs: OUR_MAX_HTLCS,
funding_pubkey: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.funding_key()),
revocation_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.revocation_base_key()),
- payment_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_base_key()),
+ payment_point: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_key()),
delayed_payment_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.delayed_payment_base_key()),
htlc_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.htlc_base_key()),
first_per_commitment_point: PublicKey::from_secret_key(&self.secp_ctx, &local_commitment_secret),
max_accepted_htlcs: OUR_MAX_HTLCS,
funding_pubkey: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.funding_key()),
revocation_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.revocation_base_key()),
- payment_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_base_key()),
+ payment_point: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.payment_key()),
delayed_payment_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.delayed_payment_base_key()),
htlc_basepoint: PublicKey::from_secret_key(&self.secp_ctx, self.local_keys.htlc_base_key()),
first_per_commitment_point: PublicKey::from_secret_key(&self.secp_ctx, &local_commitment_secret),
let their_pubkeys = ChannelPublicKeys {
funding_pubkey: public_from_secret_hex(&secp_ctx, "1552dfba4f6cf29a62a0af13c8d6981d36d0ef8d61ba10fb0fe90da7634d7e13"),
revocation_basepoint: PublicKey::from_slice(&hex::decode("02466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f27").unwrap()[..]).unwrap(),
- payment_basepoint: public_from_secret_hex(&secp_ctx, "4444444444444444444444444444444444444444444444444444444444444444"),
+ payment_point: public_from_secret_hex(&secp_ctx, "4444444444444444444444444444444444444444444444444444444444444444"),
delayed_payment_basepoint: public_from_secret_hex(&secp_ctx, "1552dfba4f6cf29a62a0af13c8d6981d36d0ef8d61ba10fb0fe90da7634d7e13"),
htlc_basepoint: public_from_secret_hex(&secp_ctx, "4444444444444444444444444444444444444444444444444444444444444444")
};
chan_keys.set_remote_channel_pubkeys(&their_pubkeys);
- assert_eq!(their_pubkeys.payment_basepoint.serialize()[..],
+ assert_eq!(their_pubkeys.payment_point.serialize()[..],
hex::decode("032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991").unwrap()[..]);
assert_eq!(their_pubkeys.funding_pubkey.serialize()[..],
assert!(commitment_transaction_number_obscure_factor <= (1 << 48));
let our_channel_close_key_hash = WPubkeyHash::hash(&shutdown_pubkey.serialize());
let shutdown_script = Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0).push_slice(&our_channel_close_key_hash[..]).into_script();
- let payment_base_key_hash = WPubkeyHash::hash(&keys.pubkeys().payment_basepoint.serialize());
- let remote_payment_script = Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0).push_slice(&payment_base_key_hash[..]).into_script();
+ let payment_key_hash = WPubkeyHash::hash(&keys.pubkeys().payment_point.serialize());
+ let remote_payment_script = Builder::new().push_opcode(opcodes::all::OP_PUSHBYTES_0).push_slice(&payment_key_hash[..]).into_script();
let mut onchain_tx_handler = OnchainTxHandler::new(destination_script.clone(), keys.clone(), their_to_self_delay, logger.clone());
} else if self.remote_payment_script == outp.script_pubkey {
spendable_output = Some(SpendableOutputDescriptor::DynamicOutputP2WPKH {
outpoint: BitcoinOutPoint { txid: tx.txid(), vout: i as u32 },
- key: self.keys.payment_base_key().clone(),
+ key: self.keys.payment_key().clone(),
output: outp.clone(),
});
break;
assert!(PublicKey::from_slice(&node0_to_1_send_open_channel.funding_pubkey.serialize()).is_ok());
assert!(PublicKey::from_slice(&node0_to_1_send_open_channel.revocation_basepoint.serialize()).is_ok());
assert!(PublicKey::from_slice(&node0_to_1_send_open_channel.htlc_basepoint.serialize()).is_ok());
- assert!(PublicKey::from_slice(&node0_to_1_send_open_channel.payment_basepoint.serialize()).is_ok());
+ assert!(PublicKey::from_slice(&node0_to_1_send_open_channel.payment_point.serialize()).is_ok());
assert!(PublicKey::from_slice(&node0_to_1_send_open_channel.delayed_payment_basepoint.serialize()).is_ok());
}
pub(crate) max_accepted_htlcs: u16,
pub(crate) funding_pubkey: PublicKey,
pub(crate) revocation_basepoint: PublicKey,
- pub(crate) payment_basepoint: PublicKey,
+ pub(crate) payment_point: PublicKey,
pub(crate) delayed_payment_basepoint: PublicKey,
pub(crate) htlc_basepoint: PublicKey,
pub(crate) first_per_commitment_point: PublicKey,
pub(crate) max_accepted_htlcs: u16,
pub(crate) funding_pubkey: PublicKey,
pub(crate) revocation_basepoint: PublicKey,
- pub(crate) payment_basepoint: PublicKey,
+ pub(crate) payment_point: PublicKey,
pub(crate) delayed_payment_basepoint: PublicKey,
pub(crate) htlc_basepoint: PublicKey,
pub(crate) first_per_commitment_point: PublicKey,
max_accepted_htlcs,
funding_pubkey,
revocation_basepoint,
- payment_basepoint,
+ payment_point,
delayed_payment_basepoint,
htlc_basepoint,
first_per_commitment_point,
max_accepted_htlcs,
funding_pubkey,
revocation_basepoint,
- payment_basepoint,
+ payment_point,
delayed_payment_basepoint,
htlc_basepoint,
first_per_commitment_point,
max_accepted_htlcs: 49340,
funding_pubkey: pubkey_1,
revocation_basepoint: pubkey_2,
- payment_basepoint: pubkey_3,
+ payment_point: pubkey_3,
delayed_payment_basepoint: pubkey_4,
htlc_basepoint: pubkey_5,
first_per_commitment_point: pubkey_6,
max_accepted_htlcs: 49340,
funding_pubkey: pubkey_1,
revocation_basepoint: pubkey_2,
- payment_basepoint: pubkey_3,
+ payment_point: pubkey_3,
delayed_payment_basepoint: pubkey_4,
htlc_basepoint: pubkey_5,
first_per_commitment_point: pubkey_6,
impl ChannelKeys for EnforcingChannelKeys {
fn funding_key(&self) -> &SecretKey { self.inner.funding_key() }
fn revocation_base_key(&self) -> &SecretKey { self.inner.revocation_base_key() }
- fn payment_base_key(&self) -> &SecretKey { self.inner.payment_base_key() }
+ fn payment_key(&self) -> &SecretKey { self.inner.payment_key() }
fn delayed_payment_base_key(&self) -> &SecretKey { self.inner.delayed_payment_base_key() }
fn htlc_base_key(&self) -> &SecretKey { self.inner.htlc_base_key() }
fn commitment_seed(&self) -> &[u8; 32] { self.inner.commitment_seed() }