Skip to content

Commit f4fde82

Browse files
committed
Rename new_funding_address to new_onchain_address
As we're using the `onchain` keyword everywhere in the API to discern onchain-operations (e.g., `send_to_onchain_address`, `spendable_onchain_balance`, etc.) we also align the funding API call here and rename `new_funding_address` to `new_onchain_address`.
1 parent 280947c commit f4fde82

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn main() {
2727

2828
node.start().unwrap();
2929

30-
let funding_address = node.new_funding_address();
30+
let funding_address = node.new_onchain_address();
3131

3232
// .. fund address ..
3333

bindings/kotlin/ldk-node-android/lib/src/androidTest/kotlin/org/lightningdevkit/ldknode/AndroidLibTest.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
1616
@RunWith(AndroidJUnit4::class)
1717
class AndroidLibTest {
1818
@Test fun node_start_stop() {
19-
val network: Network = "regtest"
20-
assertEquals(network, "regtest")
19+
val network = Network.REGTEST
2120

21+
val esplora_url = "http://127.0.0.1:3002"
2222
val tmpDir1 = createTempDirectory("ldk_node").toString()
2323
println("Random dir 1: $tmpDir1")
2424
val tmpDir2 = createTempDirectory("ldk_node").toString()
@@ -27,8 +27,8 @@ class AndroidLibTest {
2727
val listenAddress1 = "127.0.0.1:2323"
2828
val listenAddress2 = "127.0.0.1:2324"
2929

30-
val config1 = Config(tmpDir1, "http://127.0.0.1:3002", network, listenAddress1, 2048u)
31-
val config2 = Config(tmpDir2, "http://127.0.0.1:3002", network, listenAddress2, 2048u)
30+
val config1 = Config(tmpDir1, network, listenAddress1, 2048u)
31+
val config2 = Config(tmpDir2, network, listenAddress2, 2048u)
3232

3333
val builder1 = Builder.fromConfig(config1)
3434
val builder2 = Builder.fromConfig(config2)
@@ -45,10 +45,10 @@ class AndroidLibTest {
4545
val nodeId2 = node2.nodeId()
4646
println("Node Id 2: $nodeId2")
4747

48-
val address1 = node1.newFundingAddress()
48+
val address1 = node1.newOnchainAddress()
4949
println("Funding address 1: $address1")
5050

51-
val address2 = node2.newFundingAddress()
51+
val address2 = node2.newOnchainAddress()
5252
println("Funding address 2: $address2")
5353

5454
node1.stop()

bindings/kotlin/ldk-node-jvm/lib/src/test/kotlin/org/lightningdevkit/ldknode/LibraryTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ class LibraryTest {
9191
val nodeId2 = node2.nodeId()
9292
println("Node Id 2: $nodeId2")
9393

94-
val address1 = node1.newFundingAddress()
94+
val address1 = node1.newOnchainAddress()
9595
println("Funding address 1: $address1")
9696

97-
val address2 = node2.newFundingAddress()
97+
val address2 = node2.newOnchainAddress()
9898
println("Funding address 2: $address2")
9999

100100
val txid1 = sendToAddress(address1, 100000u)

bindings/ldk_node.udl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ interface LDKNode {
4040
PublicKey node_id();
4141
NetAddress? listening_address();
4242
[Throws=NodeError]
43-
Address new_funding_address();
43+
Address new_onchain_address();
4444
[Throws=NodeError]
4545
Txid send_to_onchain_address([ByRef]Address address, u64 amount_msat);
4646
[Throws=NodeError]

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
//!
4343
//! node.start().unwrap();
4444
//!
45-
//! let funding_address = node.new_funding_address();
45+
//! let funding_address = node.new_onchain_address();
4646
//!
4747
//! // .. fund address ..
4848
//!
@@ -728,7 +728,7 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
728728
}
729729

730730
/// Retrieve a new on-chain/funding address.
731-
pub fn new_funding_address(&self) -> Result<Address, Error> {
731+
pub fn new_onchain_address(&self) -> Result<Address, Error> {
732732
let funding_address = self.wallet.get_new_address()?;
733733
log_info!(self.logger, "Generated new funding address: {}", funding_address);
734734
Ok(funding_address)

src/test/functional_tests.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ fn channel_full_cycle_0conf() {
5656
fn do_channel_full_cycle<K: KVStore + Sync + Send>(
5757
node_a: Node<K>, node_b: Node<K>, bitcoind: &BitcoinD, electrsd: &ElectrsD, allow_0conf: bool,
5858
) {
59-
let addr_a = node_a.new_funding_address().unwrap();
60-
let addr_b = node_b.new_funding_address().unwrap();
59+
let addr_a = node_a.new_onchain_address().unwrap();
60+
let addr_b = node_b.new_onchain_address().unwrap();
6161

6262
let premine_amount_sat = 100_000;
6363

@@ -277,15 +277,15 @@ fn channel_open_fails_when_funds_insufficient() {
277277
builder_a.set_esplora_server(esplora_url.clone());
278278
let node_a = builder_a.build();
279279
node_a.start().unwrap();
280-
let addr_a = node_a.new_funding_address().unwrap();
280+
let addr_a = node_a.new_onchain_address().unwrap();
281281

282282
println!("\n== Node B ==");
283283
let config_b = random_config();
284284
let mut builder_b = NodeBuilder::from_config(config_b);
285285
builder_b.set_esplora_server(esplora_url);
286286
let node_b = builder_b.build();
287287
node_b.start().unwrap();
288-
let addr_b = node_b.new_funding_address().unwrap();
288+
let addr_b = node_b.new_onchain_address().unwrap();
289289

290290
let premine_amount_sat = 100_000;
291291

@@ -335,7 +335,7 @@ fn start_stop_reinit() {
335335
let node = builder.build();
336336
let expected_node_id = node.node_id();
337337

338-
let funding_address = node.new_funding_address().unwrap();
338+
let funding_address = node.new_onchain_address().unwrap();
339339
let expected_amount = Amount::from_sat(100000);
340340

341341
premine_and_distribute_funds(&bitcoind, &electrsd, vec![funding_address], expected_amount);
@@ -391,7 +391,7 @@ fn start_stop_reinit_fs_store() {
391391
let node = builder.build_with_fs_store();
392392
let expected_node_id = node.node_id();
393393

394-
let funding_address = node.new_funding_address().unwrap();
394+
let funding_address = node.new_onchain_address().unwrap();
395395
let expected_amount = Amount::from_sat(100000);
396396

397397
premine_and_distribute_funds(&bitcoind, &electrsd, vec![funding_address], expected_amount);
@@ -444,14 +444,14 @@ fn onchain_spend_receive() {
444444
builder_a.set_esplora_server(esplora_url.clone());
445445
let node_a = builder_a.build();
446446
node_a.start().unwrap();
447-
let addr_a = node_a.new_funding_address().unwrap();
447+
let addr_a = node_a.new_onchain_address().unwrap();
448448

449449
let config_b = random_config();
450450
let mut builder_b = NodeBuilder::from_config(config_b);
451451
builder_b.set_esplora_server(esplora_url);
452452
let node_b = builder_b.build();
453453
node_b.start().unwrap();
454-
let addr_b = node_b.new_funding_address().unwrap();
454+
let addr_b = node_b.new_onchain_address().unwrap();
455455

456456
premine_and_distribute_funds(
457457
&bitcoind,
@@ -477,7 +477,7 @@ fn onchain_spend_receive() {
477477
assert!(node_b.spendable_onchain_balance_sats().unwrap() > 98000);
478478
assert!(node_b.spendable_onchain_balance_sats().unwrap() < 100000);
479479

480-
let addr_b = node_b.new_funding_address().unwrap();
480+
let addr_b = node_b.new_onchain_address().unwrap();
481481
let txid = node_a.send_all_to_onchain_address(&addr_b).unwrap();
482482
generate_blocks_and_wait(&bitcoind, &electrsd, 6);
483483
wait_for_tx(&electrsd, txid);

0 commit comments

Comments
 (0)