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);
+ let mut onchain_tx_handler = OnchainTxHandler::new(destination_script.clone(), keys.clone(), their_to_self_delay, their_delayed_payment_base_key.clone(), their_htlc_base_key.clone(), our_to_self_delay);
let local_tx_sequence = initial_local_commitment_tx.unsigned_tx.input[0].sequence as u64;
let local_tx_locktime = initial_local_commitment_tx.unsigned_tx.lock_time as u64;
current_remote_commitment_txid: None,
prev_remote_commitment_txid: None,
- their_htlc_base_key: their_htlc_base_key.clone(),
- their_delayed_payment_base_key: their_delayed_payment_base_key.clone(),
+ their_htlc_base_key: *their_htlc_base_key,
+ their_delayed_payment_base_key: *their_delayed_payment_base_key,
funding_redeemscript,
channel_value_satoshis: channel_value_satoshis,
their_cur_revocation_points: None,
use bitcoin::secp256k1::{Secp256k1, Signature};
use bitcoin::secp256k1;
+use bitcoin::secp256k1::key::PublicKey;
use ln::msgs::DecodeError;
use ln::channelmonitor::{ANTI_REORG_DELAY, CLTV_SHARED_CLAIM_BUFFER, InputMaterial, ClaimRequest};
}
}
+/// Cache remote basepoint to compute any transaction on
+/// remote outputs, either justice or preimage/timeout transactions.
+struct RemoteTxCache {
+ remote_delayed_payment_base_key: PublicKey,
+ remote_htlc_base_key: PublicKey
+}
+
/// Higher-level cache structure needed to re-generate bumped claim txn if needed
#[derive(Clone, PartialEq)]
pub struct ClaimTxBumpMaterial {
prev_local_commitment: Option<LocalCommitmentTransaction>,
prev_local_htlc_sigs: Option<Vec<Option<(usize, Signature)>>>,
local_csv: u16,
+ remote_tx_cache: RemoteTxCache,
+ remote_csv: u16,
key_storage: ChanSigner,
self.local_csv.write(writer)?;
+ self.remote_tx_cache.remote_delayed_payment_base_key.write(writer)?;
+ self.remote_tx_cache.remote_htlc_base_key.write(writer)?;
+ self.remote_csv.write(writer)?;
+
self.key_storage.write(writer)?;
writer.write_all(&byte_utils::be64_to_array(self.pending_claim_requests.len() as u64))?;
let local_csv = Readable::read(reader)?;
+ let remote_tx_cache = {
+ let remote_delayed_payment_base_key = Readable::read(reader)?;
+ let remote_htlc_base_key = Readable::read(reader)?;
+ RemoteTxCache {
+ remote_delayed_payment_base_key,
+ remote_htlc_base_key,
+ }
+ };
+ let remote_csv = Readable::read(reader)?;
+
let key_storage = Readable::read(reader)?;
let pending_claim_requests_len: u64 = Readable::read(reader)?;
prev_local_commitment,
prev_local_htlc_sigs,
local_csv,
+ remote_tx_cache,
+ remote_csv,
key_storage,
claimable_outpoints,
pending_claim_requests,
}
impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
- pub(super) fn new(destination_script: Script, keys: ChanSigner, local_csv: u16) -> Self {
+ pub(super) fn new(destination_script: Script, keys: ChanSigner, local_csv: u16, remote_delayed_payment_base_key: PublicKey, remote_htlc_base_key: PublicKey, remote_csv: u16) -> Self {
let key_storage = keys;
+ let remote_tx_cache = RemoteTxCache {
+ remote_delayed_payment_base_key,
+ remote_htlc_base_key,
+ };
+
OnchainTxHandler {
destination_script,
local_commitment: None,
prev_local_commitment: None,
prev_local_htlc_sigs: None,
local_csv,
+ remote_tx_cache,
+ remote_csv,
key_storage,
pending_claim_requests: HashMap::new(),
claimable_outpoints: HashMap::new(),