Skip to content

Commit

Permalink
Revert "Add API for canceling an async payment waiting to be relayed"
Browse files Browse the repository at this point in the history
This reverts commit 0c7b049.
  • Loading branch information
remyers committed Dec 29, 2022
1 parent 0c7b049 commit 4e5511d
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 37 deletions.
8 changes: 0 additions & 8 deletions eclair-core/src/main/scala/fr/acinq/eclair/Eclair.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import fr.acinq.eclair.io._
import fr.acinq.eclair.message.{OnionMessages, Postman}
import fr.acinq.eclair.payment._
import fr.acinq.eclair.payment.receive.MultiPartHandler.ReceiveStandardPayment
import fr.acinq.eclair.payment.relay.AsyncPaymentTriggerer.Cancel
import fr.acinq.eclair.payment.relay.Relayer.{ChannelBalance, GetOutgoingChannels, OutgoingChannels, RelayFees}
import fr.acinq.eclair.payment.send.ClearRecipient
import fr.acinq.eclair.payment.send.PaymentInitiator._
Expand Down Expand Up @@ -165,8 +164,6 @@ trait Eclair {
def sendOnionMessage(intermediateNodes: Seq[PublicKey], destination: Either[PublicKey, Sphinx.RouteBlinding.BlindedRoute], replyPath: Option[Seq[PublicKey]], userCustomContent: ByteVector)(implicit timeout: Timeout): Future[SendOnionMessageResponse]

def stop(): Future[Unit]

def cancelAsyncPayment(paymentHash: ByteVector32)(implicit timeout: Timeout): Future[Unit]
}

class EclairImpl(appKit: Kit) extends Eclair with Logging {
Expand Down Expand Up @@ -590,9 +587,4 @@ class EclairImpl(appKit: Kit) extends Eclair with Logging {
sys.exit(0)
Future.successful(())
}

override def cancelAsyncPayment(paymentHash: ByteVector32)(implicit timeout: Timeout): Future[Unit] = {
appKit.triggerer ! Cancel(paymentHash)
Future.successful(())
}
}
6 changes: 2 additions & 4 deletions eclair-core/src/main/scala/fr/acinq/eclair/Setup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,7 @@ class Setup(val datadir: File,
channelsListener = channelsListener,
balanceActor = balanceActor,
postman = postman,
wallet = bitcoinClient,
triggerer = triggerer)
wallet = bitcoinClient)

zmqBlockTimeout = after(5 seconds, using = system.scheduler)(Future.failed(BitcoinZMQConnectionTimeoutException))
zmqTxTimeout = after(5 seconds, using = system.scheduler)(Future.failed(BitcoinZMQConnectionTimeoutException))
Expand Down Expand Up @@ -400,8 +399,7 @@ case class Kit(nodeParams: NodeParams,
channelsListener: typed.ActorRef[ChannelsListener.Command],
balanceActor: typed.ActorRef[BalanceActor.Command],
postman: typed.ActorRef[Postman.Command],
wallet: OnChainWallet,
triggerer: typed.ActorRef[AsyncPaymentTriggerer.Command])
wallet: OnChainWallet)

object Kit {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I
val channelsListener = TestProbe()
val balanceActor = TestProbe()
val postman = TestProbe()
val triggerer = TestProbe()
val kit = Kit(
TestConstants.Alice.nodeParams,
system,
Expand All @@ -85,8 +84,7 @@ class EclairImplSpec extends TestKitBaseClass with FixtureAnyFunSuiteLike with I
channelsListener.ref.toTyped,
balanceActor.ref.toTyped,
postman.ref.toTyped,
new DummyOnChainWallet(),
triggerer.ref.toTyped
new DummyOnChainWallet()
)
withFixture(test.toNoArgTest(FixtureParam(register, relayer, router, paymentInitiator, switchboard, paymentHandler, TestProbe(), kit)))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@ trait Payment {
}
}

val cancelAsyncPayment: Route = postRequest("cancelasyncpayment") { implicit t =>
formFields(paymentHashFormParam) { paymentHash =>
complete(eclairApi.cancelAsyncPayment(paymentHash))
}
}

val paymentRoutes: Route = usableBalances ~ payInvoice ~ sendToNode ~ sendToRoute ~ getSentInfo ~ getReceivedInfo ~ cancelAsyncPayment
val paymentRoutes: Route = usableBalances ~ payInvoice ~ sendToNode ~ sendToRoute ~ getSentInfo ~ getReceivedInfo

}
Original file line number Diff line number Diff line change
Expand Up @@ -1210,21 +1210,6 @@ class ApiServiceSpec extends AnyFunSuite with ScalatestRouteTest with IdiomaticM
}
}

test("cancelAsyncPayment") {
val eclair = mock[Eclair]
val mockService = new MockService(eclair)
val paymentHash = randomBytes32()
eclair.cancelAsyncPayment(paymentHash)(any) returns Future.successful(None)

Post("/cancelasyncpayment", FormData("paymentHash" -> paymentHash.toHex).toEntity) ~>
addCredentials(BasicHttpCredentials("", mockApi().password)) ~>
Route.seal(mockService.cancelAsyncPayment) ~>
check {
assert(handled)
assert(status == OK)
}
}

private def matchTestJson(apiName: String, response: String) = {
val resource = getClass.getResourceAsStream(s"/api/$apiName")
val expectedResponse = Try(Source.fromInputStream(resource).mkString).getOrElse {
Expand Down

0 comments on commit 4e5511d

Please sign in to comment.