Skip to content

Commit ccae92d

Browse files
authored
(Minor) Minimize conflicts with feature branches (#1765)
* optional label in getReceiveAddress * use a separate variable for channel version
1 parent 205653d commit ccae92d

15 files changed

+38
-28
lines changed

eclair-core/src/main/scala/fr/acinq/eclair/Eclair.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class EclairImpl(appKit: Kit) extends Eclair {
243243

244244
override def newAddress(): Future[String] = {
245245
appKit.wallet match {
246-
case w: BitcoinCoreWallet => w.getReceiveAddress
246+
case w: BitcoinCoreWallet => w.getReceiveAddress()
247247
case _ => Future.failed(new IllegalArgumentException("this call is only available with a bitcoin core backend"))
248248
}
249249
}

eclair-core/src/main/scala/fr/acinq/eclair/Setup.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ class Setup(datadir: File,
242242
_ <- Future.firstCompletedOf(routerInitialized.future :: routerTimeout :: Nil)
243243

244244
wallet = new BitcoinCoreWallet(bitcoin)
245-
_ = wallet.getReceiveAddress.map(address => logger.info(s"initial wallet address=$address"))
245+
_ = wallet.getReceiveAddress().map(address => logger.info(s"initial wallet address=$address"))
246246

247247
// do not change the name of this actor. it is used in the configuration to specify a custom bounded mailbox
248248
backupHandler = if (config.getBoolean("enable-db-backup")) {

eclair-core/src/main/scala/fr/acinq/eclair/blockchain/EclairWallet.scala

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ trait EclairWallet {
3030

3131
def getBalance: Future[OnChainBalance]
3232

33-
def getReceiveAddress: Future[String]
33+
/**
34+
* @param label used if implemented with bitcoin core, can be ignored by implementation
35+
*/
36+
def getReceiveAddress(label: String = ""): Future[String]
3437

3538
def getReceivePubkey(receiveAddress: Option[String] = None): Future[PublicKey]
3639

eclair-core/src/main/scala/fr/acinq/eclair/blockchain/bitcoind/BitcoinCoreWallet.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ class BitcoinCoreWallet(rpcClient: BitcoinJsonRPCClient)(implicit ec: ExecutionC
113113
OnChainBalance(toSatoshi(confirmed), toSatoshi(unconfirmed))
114114
})
115115

116-
override def getReceiveAddress: Future[String] = for {
117-
JString(address) <- rpcClient.invoke("getnewaddress")
116+
override def getReceiveAddress(label: String): Future[String] = for {
117+
JString(address) <- rpcClient.invoke("getnewaddress", label)
118118
} yield address
119119

120120
override def getReceivePubkey(receiveAddress: Option[String] = None): Future[Crypto.PublicKey] = for {
121-
address <- receiveAddress.map(Future.successful).getOrElse(getReceiveAddress)
121+
address <- receiveAddress.map(Future.successful).getOrElse(getReceiveAddress())
122122
JString(rawKey) <- rpcClient.invoke("getaddressinfo", address).map(_ \ "pubkey")
123123
} yield PublicKey(ByteVector.fromValidHex(rawKey))
124124

eclair-core/src/main/scala/fr/acinq/eclair/channel/Helpers.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ object Helpers {
226226
/** NB: this is a blocking call, use carefully! */
227227
def getFinalScriptPubKey(wallet: EclairWallet, chainHash: ByteVector32): ByteVector = {
228228
import scala.concurrent.duration._
229-
val finalAddress = Await.result(wallet.getReceiveAddress, 40 seconds)
229+
val finalAddress = Await.result(wallet.getReceiveAddress(), 40 seconds)
230230

231231
Script.write(addressToPublicKeyScript(finalAddress, chainHash))
232232
}

eclair-core/src/test/scala/fr/acinq/eclair/blockchain/TestWallet.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TestWallet extends EclairWallet {
3232

3333
override def getBalance: Future[OnChainBalance] = Future.successful(OnChainBalance(1105 sat, 561 sat))
3434

35-
override def getReceiveAddress: Future[String] = Future.successful("bcrt1qwcv8naajwn8fjhu8z59q9e6ucrqr068rlcenux")
35+
override def getReceiveAddress(label: String): Future[String] = Future.successful("bcrt1qwcv8naajwn8fjhu8z59q9e6ucrqr068rlcenux")
3636

3737
override def getReceivePubkey(receiveAddress: Option[String] = None): Future[Crypto.PublicKey] = Future.successful(PublicKey(hex"028feba10d0eafd0fad8fe20e6d9206e6bd30242826de05c63f459a00aced24b12"))
3838

eclair-core/src/test/scala/fr/acinq/eclair/blockchain/bitcoind/BitcoinCoreWalletSpec.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class BitcoinCoreWalletSpec extends TestKitBaseClass with BitcoindService with A
175175
wallet.getBalance.pipeTo(sender.ref)
176176
assert(sender.expectMsgType[OnChainBalance].confirmed > 0.sat)
177177

178-
wallet.getReceiveAddress.pipeTo(sender.ref)
178+
wallet.getReceiveAddress().pipeTo(sender.ref)
179179
val address = sender.expectMsgType[String]
180180
assert(Try(addressToPublicKeyScript(address, Block.RegtestGenesisBlock.hash)).isSuccess)
181181

@@ -231,7 +231,7 @@ class BitcoinCoreWalletSpec extends TestKitBaseClass with BitcoindService with A
231231
wallet.getBalance.pipeTo(sender.ref)
232232
assert(sender.expectMsgType[OnChainBalance].confirmed > 0.sat)
233233

234-
wallet.getReceiveAddress.pipeTo(sender.ref)
234+
wallet.getReceiveAddress().pipeTo(sender.ref)
235235
val address = sender.expectMsgType[String]
236236
assert(Try(addressToPublicKeyScript(address, Block.RegtestGenesisBlock.hash)).isSuccess)
237237

@@ -274,7 +274,7 @@ class BitcoinCoreWalletSpec extends TestKitBaseClass with BitcoindService with A
274274
val sender = TestProbe()
275275
val wallet = new BitcoinCoreWallet(bitcoinrpcclient)
276276

277-
wallet.getReceiveAddress.pipeTo(sender.ref)
277+
wallet.getReceiveAddress().pipeTo(sender.ref)
278278
val address = sender.expectMsgType[String]
279279

280280
wallet.getReceivePubkey(receiveAddress = Some(address)).pipeTo(sender.ref)

eclair-core/src/test/scala/fr/acinq/eclair/channel/TxPublisherSpec.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class TxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike with Bitcoin
105105
val bitcoinWallet = new BitcoinCoreWallet(walletRpcClient)
106106
val probe = TestProbe()
107107
utxos.foreach(amount => {
108-
bitcoinWallet.getReceiveAddress.pipeTo(probe.ref)
108+
bitcoinWallet.getReceiveAddress().pipeTo(probe.ref)
109109
val walletAddress = probe.expectMsgType[String]
110110
sendToAddress(walletAddress, amount, probe)
111111
})
@@ -279,7 +279,7 @@ class TxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike with Bitcoin
279279
assert(mempoolTx1.txid === commitTx.txid)
280280

281281
// add more funds to our wallet
282-
bitcoinWallet.getReceiveAddress.pipeTo(probe.ref)
282+
bitcoinWallet.getReceiveAddress().pipeTo(probe.ref)
283283
val walletAddress = probe.expectMsgType[String]
284284
sendToAddress(walletAddress, 1 millibtc, probe)
285285
createBlocks(1)
@@ -456,7 +456,7 @@ class TxPublisherSpec extends TestKitBaseClass with AnyFunSuiteLike with Bitcoin
456456
txPublisher ! ParentTxConfirmed(htlcSuccess, commitTx.txid)
457457

458458
// Add more funds to our wallet to allow bumping HTLC txs.
459-
bitcoinWallet.getReceiveAddress.pipeTo(probe.ref)
459+
bitcoinWallet.getReceiveAddress().pipeTo(probe.ref)
460460
val walletAddress = probe.expectMsgType[String]
461461
sendToAddress(walletAddress, 1 millibtc, probe)
462462
createBlocks(1)

eclair-core/src/test/scala/fr/acinq/eclair/channel/states/b/WaitForFundingCreatedInternalStateSpec.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ class WaitForFundingCreatedInternalStateSpec extends TestKitBaseClass with Fixtu
4646
}
4747
val setup = init(wallet = noopWallet)
4848
import setup._
49+
val channelVersion = ChannelVersion.STANDARD
4950
val aliceInit = Init(Alice.channelParams.features)
5051
val bobInit = Init(Bob.channelParams.features)
5152
within(30 seconds) {
52-
alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, TestConstants.fundingSatoshis, TestConstants.pushMsat, TestConstants.feeratePerKw, TestConstants.feeratePerKw, None, Alice.channelParams, alice2bob.ref, bobInit, ChannelFlags.Empty, ChannelVersion.STANDARD)
53-
bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, Bob.channelParams, bob2alice.ref, aliceInit, ChannelVersion.STANDARD)
53+
alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, TestConstants.fundingSatoshis, TestConstants.pushMsat, TestConstants.feeratePerKw, TestConstants.feeratePerKw, None, Alice.channelParams, alice2bob.ref, bobInit, ChannelFlags.Empty, channelVersion)
54+
bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, Bob.channelParams, bob2alice.ref, aliceInit, channelVersion)
5455
alice2bob.expectMsgType[OpenChannel]
5556
alice2bob.forward(bob)
5657
bob2alice.expectMsgType[AcceptChannel]

eclair-core/src/test/scala/fr/acinq/eclair/channel/states/b/WaitForFundingCreatedStateSpec.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,13 @@ class WaitForFundingCreatedStateSpec extends TestKitBaseClass with FixtureAnyFun
5757
val setup = init(aliceNodeParams, bobNodeParams)
5858

5959
import setup._
60+
val channelVersion = ChannelVersion.STANDARD
6061
val aliceInit = Init(aliceParams.features)
6162
val bobInit = Init(bobParams.features)
6263
within(30 seconds) {
63-
alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, fundingSatoshis, pushMsat, TestConstants.feeratePerKw, TestConstants.feeratePerKw, None, aliceParams, alice2bob.ref, bobInit, ChannelFlags.Empty, ChannelVersion.STANDARD)
64+
alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, fundingSatoshis, pushMsat, TestConstants.feeratePerKw, TestConstants.feeratePerKw, None, aliceParams, alice2bob.ref, bobInit, ChannelFlags.Empty, channelVersion)
6465
alice2blockchain.expectMsgType[TxPublisher.SetChannelId]
65-
bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, bobParams, bob2alice.ref, aliceInit, ChannelVersion.STANDARD)
66+
bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, bobParams, bob2alice.ref, aliceInit, channelVersion)
6667
bob2blockchain.expectMsgType[TxPublisher.SetChannelId]
6768
alice2bob.expectMsgType[OpenChannel]
6869
alice2bob.forward(bob)

eclair-core/src/test/scala/fr/acinq/eclair/channel/states/b/WaitForFundingSignedStateSpec.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,13 @@ class WaitForFundingSignedStateSpec extends TestKitBaseClass with FixtureAnyFunS
5454
val setup = init(aliceNodeParams, bobNodeParams)
5555

5656
import setup._
57+
val channelVersion = ChannelVersion.STANDARD
5758
val aliceInit = Init(aliceParams.features)
5859
val bobInit = Init(bobParams.features)
5960
within(30 seconds) {
60-
alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, fundingSatoshis, pushMsat, TestConstants.feeratePerKw, TestConstants.feeratePerKw, None, aliceParams, alice2bob.ref, bobInit, ChannelFlags.Empty, ChannelVersion.STANDARD)
61+
alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, fundingSatoshis, pushMsat, TestConstants.feeratePerKw, TestConstants.feeratePerKw, None, aliceParams, alice2bob.ref, bobInit, ChannelFlags.Empty, channelVersion)
6162
alice2blockchain.expectMsgType[TxPublisher.SetChannelId]
62-
bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, bobParams, bob2alice.ref, aliceInit, ChannelVersion.STANDARD)
63+
bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, bobParams, bob2alice.ref, aliceInit, channelVersion)
6364
bob2blockchain.expectMsgType[TxPublisher.SetChannelId]
6465
alice2bob.expectMsgType[OpenChannel]
6566
alice2bob.forward(bob)

eclair-core/src/test/scala/fr/acinq/eclair/channel/states/c/WaitForFundingConfirmedStateSpec.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ class WaitForFundingConfirmedStateSpec extends TestKitBaseClass with FixtureAnyF
4242
override def withFixture(test: OneArgTest): Outcome = {
4343
val setup = init()
4444
import setup._
45+
val channelVersion = ChannelVersion.STANDARD
4546
val aliceInit = Init(Alice.channelParams.features)
4647
val bobInit = Init(Bob.channelParams.features)
4748
within(30 seconds) {
48-
alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, TestConstants.fundingSatoshis, TestConstants.pushMsat, TestConstants.feeratePerKw, TestConstants.feeratePerKw, None, Alice.channelParams, alice2bob.ref, bobInit, ChannelFlags.Empty, ChannelVersion.STANDARD)
49+
alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, TestConstants.fundingSatoshis, TestConstants.pushMsat, TestConstants.feeratePerKw, TestConstants.feeratePerKw, None, Alice.channelParams, alice2bob.ref, bobInit, ChannelFlags.Empty, channelVersion)
4950
alice2blockchain.expectMsgType[TxPublisher.SetChannelId]
50-
bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, Bob.channelParams, bob2alice.ref, aliceInit, ChannelVersion.STANDARD)
51+
bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, Bob.channelParams, bob2alice.ref, aliceInit, channelVersion)
5152
bob2blockchain.expectMsgType[TxPublisher.SetChannelId]
5253
alice2bob.expectMsgType[OpenChannel]
5354
alice2bob.forward(bob)

eclair-core/src/test/scala/fr/acinq/eclair/channel/states/c/WaitForFundingLockedStateSpec.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ class WaitForFundingLockedStateSpec extends TestKitBaseClass with FixtureAnyFunS
4343
override def withFixture(test: OneArgTest): Outcome = {
4444
val setup = init()
4545
import setup._
46+
val channelVersion = ChannelVersion.STANDARD
4647
val aliceInit = Init(Alice.channelParams.features)
4748
val bobInit = Init(Bob.channelParams.features)
4849
within(30 seconds) {
49-
alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, TestConstants.fundingSatoshis, TestConstants.pushMsat, TestConstants.feeratePerKw, TestConstants.feeratePerKw, Some(initialRelayFees), Alice.channelParams, alice2bob.ref, bobInit, ChannelFlags.Empty, ChannelVersion.STANDARD)
50+
alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, TestConstants.fundingSatoshis, TestConstants.pushMsat, TestConstants.feeratePerKw, TestConstants.feeratePerKw, Some(initialRelayFees), Alice.channelParams, alice2bob.ref, bobInit, ChannelFlags.Empty, channelVersion)
5051
alice2blockchain.expectMsgType[TxPublisher.SetChannelId]
51-
bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, Bob.channelParams, bob2alice.ref, aliceInit, ChannelVersion.STANDARD)
52+
bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, Bob.channelParams, bob2alice.ref, aliceInit, channelVersion)
5253
bob2blockchain.expectMsgType[TxPublisher.SetChannelId]
5354
alice2bob.expectMsgType[OpenChannel]
5455
alice2bob.forward(bob)

eclair-core/src/test/scala/fr/acinq/eclair/channel/states/h/ClosingStateSpec.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,12 @@ class ClosingStateSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with
6363

6464
if (unconfirmedFundingTx) {
6565
within(30 seconds) {
66+
val channelVersion = ChannelVersion.STANDARD
6667
val aliceInit = Init(Alice.channelParams.features)
6768
val bobInit = Init(Bob.channelParams.features)
68-
alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, TestConstants.fundingSatoshis, TestConstants.pushMsat, TestConstants.feeratePerKw, TestConstants.feeratePerKw, None, Alice.channelParams, alice2bob.ref, bobInit, ChannelFlags.Empty, ChannelVersion.STANDARD)
69+
alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, TestConstants.fundingSatoshis, TestConstants.pushMsat, TestConstants.feeratePerKw, TestConstants.feeratePerKw, None, Alice.channelParams, alice2bob.ref, bobInit, ChannelFlags.Empty, channelVersion)
6970
alice2blockchain.expectMsgType[TxPublisher.SetChannelId]
70-
bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, Bob.channelParams, bob2alice.ref, aliceInit, ChannelVersion.STANDARD)
71+
bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, Bob.channelParams, bob2alice.ref, aliceInit, channelVersion)
7172
bob2blockchain.expectMsgType[TxPublisher.SetChannelId]
7273
alice2bob.expectMsgType[OpenChannel]
7374
alice2bob.forward(bob)

eclair-core/src/test/scala/fr/acinq/eclair/interop/rustytests/RustyTestsSpec.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,16 @@ class RustyTestsSpec extends TestKitBaseClass with Matchers with FixtureAnyFunSu
6363
val feeEstimator = new TestFeeEstimator
6464
val aliceNodeParams = Alice.nodeParams.copy(blockCount = blockCount, onChainFeeConf = Alice.nodeParams.onChainFeeConf.copy(feeEstimator = feeEstimator))
6565
val bobNodeParams = Bob.nodeParams.copy(blockCount = blockCount, onChainFeeConf = Bob.nodeParams.onChainFeeConf.copy(feeEstimator = feeEstimator))
66+
val channelVersion = ChannelVersion.STANDARD
6667
val alice: TestFSMRef[State, Data, Channel] = TestFSMRef(new Channel(aliceNodeParams, wallet, Bob.nodeParams.nodeId, alice2blockchain.ref, relayer, FakeTxPublisherFactory(alice2blockchain)), alicePeer.ref)
6768
val bob: TestFSMRef[State, Data, Channel] = TestFSMRef(new Channel(bobNodeParams, wallet, Alice.nodeParams.nodeId, bob2blockchain.ref, relayer, FakeTxPublisherFactory(bob2blockchain)), bobPeer.ref)
6869
val aliceInit = Init(Alice.channelParams.features)
6970
val bobInit = Init(Bob.channelParams.features)
7071
// alice and bob will both have 1 000 000 sat
7172
feeEstimator.setFeerate(FeeratesPerKw.single(FeeratePerKw(10000 sat)))
72-
alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, 2000000 sat, 1000000000 msat, feeEstimator.getFeeratePerKw(target = 2), feeEstimator.getFeeratePerKw(target = 6), None, Alice.channelParams, pipe, bobInit, ChannelFlags.Empty, ChannelVersion.STANDARD)
73+
alice ! INPUT_INIT_FUNDER(ByteVector32.Zeroes, 2000000 sat, 1000000000 msat, feeEstimator.getFeeratePerKw(target = 2), feeEstimator.getFeeratePerKw(target = 6), None, Alice.channelParams, pipe, bobInit, ChannelFlags.Empty, channelVersion)
7374
alice2blockchain.expectMsgType[TxPublisher.SetChannelId]
74-
bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, Bob.channelParams, pipe, aliceInit, ChannelVersion.STANDARD)
75+
bob ! INPUT_INIT_FUNDEE(ByteVector32.Zeroes, Bob.channelParams, pipe, aliceInit, channelVersion)
7576
bob2blockchain.expectMsgType[TxPublisher.SetChannelId]
7677
pipe ! (alice, bob)
7778
within(30 seconds) {

0 commit comments

Comments
 (0)