Skip to content

Commit 8519e8f

Browse files
committed
Drop OutPoint::new since the struct is all pub
This makes it easier for our automated bindings generator to function as it tries to automatically create a ::new if the struct contains only pub elements who's type is convertible.
1 parent d2520f4 commit 8519e8f

File tree

7 files changed

+15
-20
lines changed

7 files changed

+15
-20
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
266266
let tx = Transaction { version: $chan_id, lock_time: 0, input: Vec::new(), output: vec![TxOut {
267267
value: *channel_value_satoshis, script_pubkey: output_script.clone(),
268268
}]};
269-
funding_output = OutPoint::new(tx.txid(), 0);
269+
funding_output = OutPoint { txid: tx.txid(), index: 0 };
270270
$source.funding_transaction_generated(&temporary_channel_id, funding_output);
271271
channel_txn.push(tx);
272272
} else { panic!("Wrong event type"); }

fuzz/src/full_stack.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ pub fn do_test(data: &[u8], logger: &Arc<dyn Logger>) {
474474
let funding_output = 'search_loop: loop {
475475
let funding_txid = tx.txid();
476476
if let None = loss_detector.txids_confirmed.get(&funding_txid) {
477-
let outpoint = OutPoint::new(funding_txid, 0);
477+
let outpoint = OutPoint { txid: funding_txid, index: 0 };
478478
for chan in channelmanager.list_channels() {
479479
if chan.channel_id == outpoint.to_channel_id() {
480480
tx.version += 1;

lightning/src/chain/transaction.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ pub struct OutPoint {
1616
}
1717

1818
impl OutPoint {
19-
/// Creates a new `OutPoint` from the txid and the index.
20-
pub fn new(txid: Txid, index: u16) -> OutPoint {
21-
OutPoint { txid, index }
22-
}
23-
2419
/// Convert an `OutPoint` to a lightning channel id.
2520
pub fn to_channel_id(&self) -> [u8; 32] {
2621
let mut res = [0; 32];

lightning/src/ln/channel.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1493,7 +1493,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
14931493
panic!("Should not have advanced channel commitment tx numbers prior to funding_created");
14941494
}
14951495

1496-
let funding_txo = OutPoint::new(msg.funding_txid, msg.funding_output_index);
1496+
let funding_txo = OutPoint{ txid: msg.funding_txid, index: msg.funding_output_index };
14971497
self.funding_txo = Some(funding_txo.clone());
14981498

14991499
let (remote_initial_commitment_tx, local_initial_commitment_tx, our_signature) = match self.funding_created_signature(&msg.signature) {
@@ -4395,7 +4395,7 @@ mod tests {
43954395
let tx = Transaction { version: 1, lock_time: 0, input: Vec::new(), output: vec![TxOut {
43964396
value: 10000000, script_pubkey: output_script.clone(),
43974397
}]};
4398-
let funding_outpoint = OutPoint::new(tx.txid(), 0);
4398+
let funding_outpoint = OutPoint{ txid: tx.txid(), index: 0 };
43994399
let funding_created_msg = node_a_chan.get_outbound_funding_created(funding_outpoint).unwrap();
44004400
let (funding_signed_msg, _) = node_b_chan.funding_created(&funding_created_msg).unwrap();
44014401

@@ -4460,7 +4460,7 @@ mod tests {
44604460
chan.their_to_self_delay = 144;
44614461
chan.our_dust_limit_satoshis = 546;
44624462

4463-
let funding_info = OutPoint::new(Txid::from_hex("8984484a580b825b9972d7adb15050b3ab624ccd731946b3eeddb92f4e7ef6be").unwrap(), 0);
4463+
let funding_info = OutPoint{ txid: Txid::from_hex("8984484a580b825b9972d7adb15050b3ab624ccd731946b3eeddb92f4e7ef6be").unwrap(), index: 0 };
44644464
chan.funding_txo = Some(funding_info);
44654465

44664466
let their_pubkeys = ChannelPublicKeys {

lightning/src/ln/functional_test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ pub fn create_funding_transaction<'a, 'b, 'c>(node: &Node<'a, 'b, 'c>, expected_
318318
let tx = Transaction { version: chan_id as u32, lock_time: 0, input: Vec::new(), output: vec![TxOut {
319319
value: *channel_value_satoshis, script_pubkey: output_script.clone(),
320320
}]};
321-
let funding_outpoint = OutPoint::new(tx.txid(), 0);
321+
let funding_outpoint = OutPoint { txid: tx.txid(), index: 0 };
322322
(*temporary_channel_id, tx, funding_outpoint)
323323
},
324324
_ => panic!("Unexpected event"),

lightning/src/ln/functional_tests.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ fn pre_funding_lock_shutdown_test() {
818818
nodes[0].block_notifier.block_connected(&Block { header, txdata: vec![tx.clone()]}, 1);
819819
nodes[1].block_notifier.block_connected(&Block { header, txdata: vec![tx.clone()]}, 1);
820820

821-
nodes[0].node.close_channel(&OutPoint::new(tx.txid(), 0).to_channel_id()).unwrap();
821+
nodes[0].node.close_channel(&OutPoint { txid: tx.txid(), index: 0 }.to_channel_id()).unwrap();
822822
let node_0_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
823823
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &node_0_shutdown);
824824
let node_1_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
@@ -3079,7 +3079,7 @@ fn test_force_close_fail_back() {
30793079
// Now check that if we add the preimage to ChannelMonitor it broadcasts our HTLC-Success..
30803080
{
30813081
let mut monitors = nodes[2].chan_monitor.simple_monitor.monitors.lock().unwrap();
3082-
monitors.get_mut(&OutPoint::new(Txid::from_slice(&payment_event.commitment_msg.channel_id[..]).unwrap(), 0)).unwrap()
3082+
monitors.get_mut(&OutPoint{ txid: Txid::from_slice(&payment_event.commitment_msg.channel_id[..]).unwrap(), index: 0 }).unwrap()
30833083
.provide_payment_preimage(&our_payment_hash, &our_payment_preimage);
30843084
}
30853085
nodes[2].block_notifier.block_connected_checked(&header, 1, &[&tx], &[1]);
@@ -6673,7 +6673,7 @@ fn test_upfront_shutdown_script() {
66736673
// We test that in case of peer committing upfront to a script, if it changes at closing, we refuse to sign
66746674
let flags = InitFeatures::known();
66756675
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 2, 1000000, 1000000, flags.clone(), flags.clone());
6676-
nodes[0].node.close_channel(&OutPoint::new(chan.3.txid(), 0).to_channel_id()).unwrap();
6676+
nodes[0].node.close_channel(&OutPoint { txid: chan.3.txid(), index: 0 }.to_channel_id()).unwrap();
66776677
let mut node_0_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[2].node.get_our_node_id());
66786678
node_0_shutdown.scriptpubkey = Builder::new().push_opcode(opcodes::all::OP_RETURN).into_script().to_p2sh();
66796679
// Test we enforce upfront_scriptpbukey if by providing a diffrent one at closing that we disconnect peer
@@ -6683,7 +6683,7 @@ fn test_upfront_shutdown_script() {
66836683

66846684
// We test that in case of peer committing upfront to a script, if it doesn't change at closing, we sign
66856685
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 2, 1000000, 1000000, flags.clone(), flags.clone());
6686-
nodes[0].node.close_channel(&OutPoint::new(chan.3.txid(), 0).to_channel_id()).unwrap();
6686+
nodes[0].node.close_channel(&OutPoint { txid: chan.3.txid(), index: 0 }.to_channel_id()).unwrap();
66876687
let node_0_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[2].node.get_our_node_id());
66886688
// We test that in case of peer committing upfront to a script, if it oesn't change at closing, we sign
66896689
nodes[2].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &node_0_shutdown);
@@ -6697,7 +6697,7 @@ fn test_upfront_shutdown_script() {
66976697
// We test that if case of peer non-signaling we don't enforce committed script at channel opening
66986698
let flags_no = InitFeatures::known().clear_upfront_shutdown_script();
66996699
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 1000000, flags_no, flags.clone());
6700-
nodes[0].node.close_channel(&OutPoint::new(chan.3.txid(), 0).to_channel_id()).unwrap();
6700+
nodes[0].node.close_channel(&OutPoint { txid: chan.3.txid(), index: 0 }.to_channel_id()).unwrap();
67016701
let mut node_1_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
67026702
node_1_shutdown.scriptpubkey = Builder::new().push_opcode(opcodes::all::OP_RETURN).into_script().to_p2sh();
67036703
nodes[1].node.handle_shutdown(&nodes[0].node.get_our_node_id(), &node_1_shutdown);
@@ -6711,7 +6711,7 @@ fn test_upfront_shutdown_script() {
67116711
// We test that if user opt-out, we provide a zero-length script at channel opening and we are able to close
67126712
// channel smoothly, opt-out is from channel initiator here
67136713
let chan = create_announced_chan_between_nodes_with_value(&nodes, 1, 0, 1000000, 1000000, flags.clone(), flags.clone());
6714-
nodes[1].node.close_channel(&OutPoint::new(chan.3.txid(), 0).to_channel_id()).unwrap();
6714+
nodes[1].node.close_channel(&OutPoint { txid: chan.3.txid(), index: 0 }.to_channel_id()).unwrap();
67156715
let mut node_0_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
67166716
node_0_shutdown.scriptpubkey = Builder::new().push_opcode(opcodes::all::OP_RETURN).into_script().to_p2sh();
67176717
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &node_0_shutdown);
@@ -6725,7 +6725,7 @@ fn test_upfront_shutdown_script() {
67256725
//// We test that if user opt-out, we provide a zero-length script at channel opening and we are able to close
67266726
//// channel smoothly
67276727
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 1000000, flags.clone(), flags.clone());
6728-
nodes[1].node.close_channel(&OutPoint::new(chan.3.txid(), 0).to_channel_id()).unwrap();
6728+
nodes[1].node.close_channel(&OutPoint { txid: chan.3.txid(), index: 0 }.to_channel_id()).unwrap();
67296729
let mut node_0_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
67306730
node_0_shutdown.scriptpubkey = Builder::new().push_opcode(opcodes::all::OP_RETURN).into_script().to_p2sh();
67316731
nodes[0].node.handle_shutdown(&nodes[1].node.get_our_node_id(), &node_0_shutdown);
@@ -7526,7 +7526,7 @@ fn test_bump_txn_sanitize_tracking_maps() {
75267526
connect_blocks(&nodes[0].block_notifier, 5, 130, false, header_130.bitcoin_hash());
75277527
{
75287528
let monitors = nodes[0].chan_monitor.simple_monitor.monitors.lock().unwrap();
7529-
if let Some(monitor) = monitors.get(&OutPoint::new(chan.3.txid(), 0)) {
7529+
if let Some(monitor) = monitors.get(&OutPoint { txid: chan.3.txid(), index: 0 }) {
75307530
assert!(monitor.onchain_tx_handler.pending_claim_requests.is_empty());
75317531
assert!(monitor.onchain_tx_handler.claimable_outpoints.is_empty());
75327532
}

lightning/src/util/macro_logger.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ macro_rules! log_bytes {
4343
pub(crate) struct DebugFundingChannelId<'a>(pub &'a Txid, pub u16);
4444
impl<'a> std::fmt::Display for DebugFundingChannelId<'a> {
4545
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
46-
for i in OutPoint::new(self.0.clone(), self.1).to_channel_id().iter() {
46+
for i in (OutPoint { txid: self.0.clone(), index: self.1 }).to_channel_id().iter() {
4747
write!(f, "{:02x}", i)?;
4848
}
4949
Ok(())

0 commit comments

Comments
 (0)