Skip to content

Commit bd9a5ee

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 10d96a1 commit bd9a5ee

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
@@ -41,7 +41,7 @@ interface LDKNode {
4141
PublicKey node_id();
4242
NetAddress? listening_address();
4343
[Throws=NodeError]
44-
Address new_funding_address();
44+
Address new_onchain_address();
4545
[Throws=NodeError]
4646
Txid send_to_onchain_address([ByRef]Address address, u64 amount_msat);
4747
[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
//!
@@ -730,7 +730,7 @@ impl<K: KVStore + Sync + Send + 'static> Node<K> {
730730
}
731731

732732
/// Retrieve a new on-chain/funding address.
733-
pub fn new_funding_address(&self) -> Result<Address, Error> {
733+
pub fn new_onchain_address(&self) -> Result<Address, Error> {
734734
let funding_address = self.wallet.get_new_address()?;
735735
log_info!(self.logger, "Generated new funding address: {}", funding_address);
736736
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

@@ -278,15 +278,15 @@ fn channel_open_fails_when_funds_insufficient() {
278278
builder_a.set_esplora_server(esplora_url.clone());
279279
let node_a = builder_a.build();
280280
node_a.start().unwrap();
281-
let addr_a = node_a.new_funding_address().unwrap();
281+
let addr_a = node_a.new_onchain_address().unwrap();
282282

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

291291
let premine_amount_sat = 100_000;
292292

@@ -337,7 +337,7 @@ fn start_stop_reinit() {
337337
let node = builder.build();
338338
let expected_node_id = node.node_id();
339339

340-
let funding_address = node.new_funding_address().unwrap();
340+
let funding_address = node.new_onchain_address().unwrap();
341341
let expected_amount = Amount::from_sat(100000);
342342

343343
premine_and_distribute_funds(&bitcoind, &electrsd, vec![funding_address], expected_amount);
@@ -393,7 +393,7 @@ fn start_stop_reinit_fs_store() {
393393
let node = builder.build_with_fs_store();
394394
let expected_node_id = node.node_id();
395395

396-
let funding_address = node.new_funding_address().unwrap();
396+
let funding_address = node.new_onchain_address().unwrap();
397397
let expected_amount = Amount::from_sat(100000);
398398

399399
premine_and_distribute_funds(&bitcoind, &electrsd, vec![funding_address], expected_amount);
@@ -446,14 +446,14 @@ fn onchain_spend_receive() {
446446
builder_a.set_esplora_server(esplora_url.clone());
447447
let node_a = builder_a.build();
448448
node_a.start().unwrap();
449-
let addr_a = node_a.new_funding_address().unwrap();
449+
let addr_a = node_a.new_onchain_address().unwrap();
450450

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

458458
premine_and_distribute_funds(
459459
&bitcoind,
@@ -479,7 +479,7 @@ fn onchain_spend_receive() {
479479
assert!(node_b.spendable_onchain_balance_sats().unwrap() > 98000);
480480
assert!(node_b.spendable_onchain_balance_sats().unwrap() < 100000);
481481

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

0 commit comments

Comments
 (0)