@@ -404,7 +404,7 @@ class Ldk: NSObject {
404404 channelManagerConstructor = try ChannelManagerConstructor (
405405 channelManagerSerialized: [ UInt8] ( channelManagerSerialized) ,
406406 channelMonitorsSerialized: channelMonitorsSerialized,
407- netGraphSerialized : networkGraph . write ( ) ,
407+ networkGraph : NetworkGraphArgument . instance ( networkGraph ) ,
408408 filter: filter,
409409 params: params
410410 )
@@ -750,86 +750,6 @@ class Ldk: NSObject {
750750 }
751751 }
752752
753- @objc
754- func payWithRoute( _ route: NSArray , destinationNodeId: NSString , amountSats: NSInteger , cltvExpiryDelta: NSInteger , paymentHash: NSString , paymentSecret: NSString , resolve: @escaping RCTPromiseResolveBlock , reject: @escaping RCTPromiseRejectBlock ) {
755- let paymentId = String ( paymentHash) . hexaBytes //TODO allow passing this through from JS but should default to payment hash
756-
757- guard let channelManager = channelManager else {
758- return handleReject ( reject, . init_channel_manager)
759- }
760-
761- guard let networkGraph = networkGraph? . readOnly ( ) else {
762- return handleReject ( reject, . init_network_graph)
763- }
764-
765- //TODO amountSats no longer required
766- let amountMSats = UInt64 ( amountSats) * 1000
767- var paths : [ RouteHop ] = [ ]
768-
769- for hop in route {
770- print ( " HOP: " )
771-
772- let decodedHop = hop as! [ String : Any ]
773-
774- let pubKey = decodedHop [ " dest_node_id " ] ! as! String
775- let shortChannelId = UInt64 ( decodedHop [ " short_channel_id " ] ! as! String ) !
776- let feeMsats = UInt64 ( exactly: decodedHop [ " fee_sats " ] ! as! Int ) ! * 1000
777-
778- var channelFeatures = ChannelFeatures . initWithEmpty ( )
779- var nodeFeatures = NodeFeatures . initWithEmpty ( )
780-
781- //If it's the last hop then it's the full amount
782- if pubKey == String ( destinationNodeId) {
783- //Assume public node
784- let channel = networkGraph. channel ( shortChannelId: shortChannelId)
785-
786- if let cFeatures = channel? . getFeatures ( ) {
787- channelFeatures = cFeatures
788- }
789-
790- if let nFeatures = networkGraph. node ( nodeId: NodeId . initWithPubkey ( pubkey: pubKey. hexaBytes) ) ? . getAnnouncementInfo ( ) ? . getFeatures ( ) {
791- nodeFeatures = nFeatures
792- }
793- }
794-
795- channelManager. listChannels ( ) . forEach { channelDetails in
796- channelDetails. getConfig ( ) ? . getForwardingFeeBaseMsat ( )
797- if channelDetails. getShortChannelId ( ) == shortChannelId {
798- // nodeFeatures = = channelDetails.get_counterparty().get_features() //TODO convert this
799- //TODO get channel features somehow?
800- }
801- }
802-
803- //TODO Check if channel is ours instead of querying graph
804-
805- let hop = RouteHop (
806- pubkeyArg: pubKey. hexaBytes,
807- nodeFeaturesArg: nodeFeatures,
808- shortChannelIdArg: shortChannelId,
809- channelFeaturesArg: channelFeatures,
810- feeMsatArg: feeMsats,
811- cltvExpiryDeltaArg: UInt32 ( cltvExpiryDelta)
812- )
813-
814- paths. append ( hop)
815- }
816-
817- let payee = PaymentParameters . initWithNodeId ( payeePubkey: String ( destinationNodeId) . hexaBytes, finalCltvExpiryDelta: UInt32 ( cltvExpiryDelta) )
818-
819- let route = Route ( pathsArg: [ paths] , paymentParamsArg: payee)
820-
821- let res = channelManager. sendPayment ( route: route, paymentHash: String ( paymentHash) . hexaBytes, paymentSecret: String ( paymentSecret) . hexaBytes, paymentId: paymentId)
822- if res. isOk ( ) {
823- return resolve ( Data ( paymentId) . hexEncodedString ( ) )
824- }
825-
826- guard let error = res. getError ( ) else {
827- return handleReject ( reject, . invoice_payment_fail_unknown)
828- }
829-
830- return handlePaymentSendFailure ( reject, error: error)
831- }
832-
833753 @objc
834754 func abandonPayment( _ paymentId: NSString , resolve: @escaping RCTPromiseResolveBlock , reject: @escaping RCTPromiseRejectBlock ) {
835755 guard let channelManager = channelManager else {
0 commit comments