Skip to content

Commit aceb1c7

Browse files
authored
Merge pull request #115 from arik-so/arik/2023/07/wrapped-with-anchor-fix
Fix wrapped trait implementations with anchor return values
2 parents d1d262e + ec2a974 commit aceb1c7

File tree

505 files changed

+164
-3519
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

505 files changed

+164
-3519
lines changed

ci/LDKSwift/Tests/LDKSwiftTests/HumanObjectPeerTestInstance.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class HumanObjectPeerTestInstance {
5858
let monitors: [String: ChannelMonitor]
5959
private(set) var filter: Filter?
6060
private(set) var explicitKeysManager: KeysManager!
61-
private(set) var wrappedSignerProvider: SignerProvider?
61+
private(set) var wrappedKeysManager: WrappedSignerProviderTests.MyKeysManager?
6262
private(set) var router: GossipSync!
6363
private(set) var channelManager: ChannelManager!
6464
private(set) var peerManager: PeerManager!
@@ -291,8 +291,7 @@ public class HumanObjectPeerTestInstance {
291291
self.explicitKeysManager = keysManager
292292

293293
if master.configuration.useWrappedSignerProvider {
294-
let keysManager = WrappedSignerProviderTests.MyKeysManager(seed: keySeed, startingTimeSecs: timestamp_seconds, startingTimeNanos: timestamp_nanos)
295-
self.wrappedSignerProvider = keysManager.signerProvider;
294+
self.wrappedKeysManager = WrappedSignerProviderTests.MyKeysManager(seed: keySeed, startingTimeSecs: timestamp_seconds, startingTimeNanos: timestamp_nanos)
296295
}
297296

298297
if master.configuration.useRouter {
@@ -325,7 +324,7 @@ public class HumanObjectPeerTestInstance {
325324
let score = probabalisticScorer.asScore()
326325
let multiThreadedScorer = MultiThreadedLockableScore(score: score)
327326

328-
let signerProvider = master.configuration.useWrappedSignerProvider ? self.wrappedSignerProvider! : self.explicitKeysManager.asSignerProvider()
327+
let signerProvider = master.configuration.useWrappedSignerProvider ? self.wrappedKeysManager!.signerProvider : self.explicitKeysManager.asSignerProvider()
329328
let constructionParameters = ChannelManagerConstructionParameters(
330329
config: UserConfig.initWithDefault(),
331330
entropySource: self.explicitKeysManager.asEntropySource(),

ci/LDKSwift/Tests/LDKSwiftTests/WrappedSignerProviderTests.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class WrappedSignerProviderTests: XCTestCase {
8383
}
8484

8585
class MyNodeSigner: NodeSigner {
86-
var myKeysManager: MyKeysManager?
86+
weak var myKeysManager: MyKeysManager?
8787
override func ecdh(recipient: Bindings.Recipient, otherKey: [UInt8], tweak: [UInt8]?) -> Bindings.Result_SharedSecretNoneZ {
8888
print("entering wrapper: ecdh()")
8989
return myKeysManager!.keysManager.asNodeSigner().ecdh(recipient: recipient, otherKey: otherKey, tweak: tweak)
@@ -112,15 +112,15 @@ class WrappedSignerProviderTests: XCTestCase {
112112
}
113113

114114
class MyEntropySource: EntropySource {
115-
var myKeysManager: MyKeysManager?
115+
weak var myKeysManager: MyKeysManager?
116116
override func getSecureRandomBytes() -> [UInt8] {
117117
print("entering wrapper: getSecureRandomBytes()")
118118
return myKeysManager!.keysManager.asEntropySource().getSecureRandomBytes()
119119
}
120120
}
121121

122122
class MySignerProvider: SignerProvider {
123-
var myKeysManager: MyKeysManager?
123+
weak var myKeysManager: MyKeysManager?
124124
override func deriveChannelSigner(channelValueSatoshis: UInt64, channelKeysId: [UInt8]) -> Bindings.WriteableEcdsaChannelSigner {
125125
print("entering wrapper: deriveChannelSigner()")
126126
return myKeysManager!.keysManager.asSignerProvider().deriveChannelSigner(channelValueSatoshis: channelValueSatoshis, channelKeysId: channelKeysId)
@@ -143,8 +143,13 @@ class WrappedSignerProviderTests: XCTestCase {
143143

144144
override func getShutdownScriptpubkey() -> Bindings.ShutdownScript {
145145
print("entering wrapper: getShutdownScriptpubkey()")
146-
let scriptPubkey = myKeysManager!.keysManager.asSignerProvider().getShutdownScriptpubkey()
147-
return scriptPubkey
146+
147+
let randomHex = "6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000"
148+
let randomHexBytes = LDKSwiftTests.hexStringToBytes(hexString: randomHex)!
149+
let witnessProgram = ShutdownScript.newWitnessProgram(version: 1, program: randomHexBytes)
150+
let witnessBasedScript = witnessProgram.getValue()!
151+
152+
return witnessBasedScript
148153
}
149154
}
150155

out/Bindings.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,19 @@ open class NativeTypeWrapper: Hashable {
5959
return false
6060
}
6161

62+
internal func dangle(_ shouldDangle: Bool = true) -> Self {
63+
self.dangling = shouldDangle
64+
return self
65+
}
66+
67+
internal func dangleRecursively() -> Self {
68+
self.dangling = true
69+
for currentAnchor in self.anchors {
70+
currentAnchor.dangleRecursively()
71+
}
72+
return self
73+
}
74+
6275
internal func noOpRetain() {
6376
/* there to make sure object gets retained until after this call */
6477
}

out/enums/complex/APIError.swift

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -436,12 +436,6 @@ extension Bindings {
436436
}
437437

438438

439-
internal func dangle(_ shouldDangle: Bool = true) -> APIError {
440-
self.dangling = shouldDangle
441-
return self
442-
}
443-
444-
445439
internal func danglingClone() -> APIError {
446440
let dangledClone = self.clone()
447441
dangledClone.dangling = true
@@ -534,12 +528,6 @@ extension Bindings {
534528
}
535529

536530

537-
internal func dangle(_ shouldDangle: Bool = true) -> APIMisuseError {
538-
self.dangling = shouldDangle
539-
return self
540-
}
541-
542-
543531
}
544532

545533

@@ -619,12 +607,6 @@ extension Bindings {
619607
}
620608

621609

622-
internal func dangle(_ shouldDangle: Bool = true) -> FeeRateTooHigh {
623-
self.dangling = shouldDangle
624-
return self
625-
}
626-
627-
628610
}
629611

630612

@@ -696,12 +678,6 @@ extension Bindings {
696678
}
697679

698680

699-
internal func dangle(_ shouldDangle: Bool = true) -> InvalidRoute {
700-
self.dangling = shouldDangle
701-
return self
702-
}
703-
704-
705681
}
706682

707683

@@ -773,12 +749,6 @@ extension Bindings {
773749
}
774750

775751

776-
internal func dangle(_ shouldDangle: Bool = true) -> ChannelUnavailable {
777-
self.dangling = shouldDangle
778-
return self
779-
}
780-
781-
782752
}
783753

784754

@@ -850,12 +820,6 @@ extension Bindings {
850820
}
851821

852822

853-
internal func dangle(_ shouldDangle: Bool = true) -> IncompatibleShutdownScript {
854-
self.dangling = shouldDangle
855-
return self
856-
}
857-
858-
859823
}
860824

861825

out/enums/complex/Balance.swift

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,6 @@ extension Bindings {
380380
}
381381

382382

383-
internal func dangle(_ shouldDangle: Bool = true) -> Balance {
384-
self.dangling = shouldDangle
385-
return self
386-
}
387-
388-
389383
internal func danglingClone() -> Balance {
390384
let dangledClone = self.clone()
391385
dangledClone.dangling = true
@@ -477,12 +471,6 @@ extension Bindings {
477471
}
478472

479473

480-
internal func dangle(_ shouldDangle: Bool = true) -> ClaimableOnChannelClose {
481-
self.dangling = shouldDangle
482-
return self
483-
}
484-
485-
486474
}
487475

488476

@@ -562,12 +550,6 @@ extension Bindings {
562550
}
563551

564552

565-
internal func dangle(_ shouldDangle: Bool = true) -> ClaimableAwaitingConfirmations {
566-
self.dangling = shouldDangle
567-
return self
568-
}
569-
570-
571553
}
572554

573555

@@ -646,12 +628,6 @@ extension Bindings {
646628
}
647629

648630

649-
internal func dangle(_ shouldDangle: Bool = true) -> ContentiousClaimable {
650-
self.dangling = shouldDangle
651-
return self
652-
}
653-
654-
655631
}
656632

657633

@@ -731,12 +707,6 @@ extension Bindings {
731707
}
732708

733709

734-
internal func dangle(_ shouldDangle: Bool = true) -> MaybeTimeoutClaimableHTLC {
735-
self.dangling = shouldDangle
736-
return self
737-
}
738-
739-
740710
}
741711

742712

@@ -816,12 +786,6 @@ extension Bindings {
816786
}
817787

818788

819-
internal func dangle(_ shouldDangle: Bool = true) -> MaybePreimageClaimableHTLC {
820-
self.dangling = shouldDangle
821-
return self
822-
}
823-
824-
825789
}
826790

827791

@@ -894,12 +858,6 @@ extension Bindings {
894858
}
895859

896860

897-
internal func dangle(_ shouldDangle: Bool = true) -> CounterpartyRevokedOutputClaimable {
898-
self.dangling = shouldDangle
899-
return self
900-
}
901-
902-
903861
}
904862

905863

out/enums/complex/Bech32Error.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,6 @@ extension Bindings {
174174
}
175175

176176

177-
internal func dangle(_ shouldDangle: Bool = true) -> Bech32Error {
178-
self.dangling = shouldDangle
179-
return self
180-
}
181-
182-
183177
internal func danglingClone() -> Bech32Error {
184178
let dangledClone = self.clone()
185179
dangledClone.dangling = true

out/enums/complex/ClosureReason.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -443,12 +443,6 @@ extension Bindings {
443443
}
444444

445445

446-
internal func dangle(_ shouldDangle: Bool = true) -> ClosureReason {
447-
self.dangling = shouldDangle
448-
return self
449-
}
450-
451-
452446
internal func danglingClone() -> ClosureReason {
453447
let dangledClone = self.clone()
454448
dangledClone.dangling = true
@@ -549,12 +543,6 @@ extension Bindings {
549543
}
550544

551545

552-
internal func dangle(_ shouldDangle: Bool = true) -> CounterpartyForceClosed {
553-
self.dangling = shouldDangle
554-
return self
555-
}
556-
557-
558546
}
559547

560548

@@ -627,12 +615,6 @@ extension Bindings {
627615
}
628616

629617

630-
internal func dangle(_ shouldDangle: Bool = true) -> ProcessingError {
631-
self.dangling = shouldDangle
632-
return self
633-
}
634-
635-
636618
}
637619

638620

out/enums/complex/DecodeError.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,6 @@ extension Bindings {
332332
}
333333

334334

335-
internal func dangle(_ shouldDangle: Bool = true) -> DecodeError {
336-
self.dangling = shouldDangle
337-
return self
338-
}
339-
340-
341335
internal func danglingClone() -> DecodeError {
342336
let dangledClone = self.clone()
343337
dangledClone.dangling = true

out/enums/complex/Destination.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -193,12 +193,6 @@ extension Bindings {
193193
}
194194

195195

196-
internal func dangle(_ shouldDangle: Bool = true) -> Destination {
197-
self.dangling = shouldDangle
198-
return self
199-
}
200-
201-
202196
internal func danglingClone() -> Destination {
203197
let dangledClone = self.clone()
204198
dangledClone.dangling = true

out/enums/complex/EffectiveCapacity.swift

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,6 @@ extension Bindings {
299299
}
300300

301301

302-
internal func dangle(_ shouldDangle: Bool = true) -> EffectiveCapacity {
303-
self.dangling = shouldDangle
304-
return self
305-
}
306-
307-
308302
internal func danglingClone() -> EffectiveCapacity {
309303
let dangledClone = self.clone()
310304
dangledClone.dangling = true
@@ -398,12 +392,6 @@ extension Bindings {
398392
}
399393

400394

401-
internal func dangle(_ shouldDangle: Bool = true) -> ExactLiquidity {
402-
self.dangling = shouldDangle
403-
return self
404-
}
405-
406-
407395
}
408396

409397

@@ -472,12 +460,6 @@ extension Bindings {
472460
}
473461

474462

475-
internal func dangle(_ shouldDangle: Bool = true) -> MaximumHTLC {
476-
self.dangling = shouldDangle
477-
return self
478-
}
479-
480-
481463
}
482464

483465

@@ -554,12 +536,6 @@ extension Bindings {
554536
}
555537

556538

557-
internal func dangle(_ shouldDangle: Bool = true) -> Total {
558-
self.dangling = shouldDangle
559-
return self
560-
}
561-
562-
563539
}
564540

565541

0 commit comments

Comments
 (0)