import org.junit.jupiter.api.Test;
import org.ldk.impl.bindings;
import org.ldk.enums.*;
+import org.ldk.structs.Result_NoneChannelMonitorUpdateErrZ;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
bindings.LDKBroadcasterInterface broad_trait;
bindings.LDKLogger log_trait;
bindings.LDKWatch watcher;
+ ArrayList<Long> results_to_free;
Peer(byte seed) {
this.log_trait = (String arg)-> System.out.println(seed + ": " + arg);
this.broad_trait = tx -> {
// We should broadcast
};
+ this.results_to_free = new ArrayList<>();
this.tx_broadcaster = bindings.LDKBroadcasterInterface_new(this.broad_trait);
this.monitors = new HashMap<>();
this.watcher = new bindings.LDKWatch() {
assert monitors.put(Arrays.toString(bindings.OutPoint_get_txid(funding_txo)), monitor) == null;
}
bindings.OutPoint_free(funding_txo);
- return bindings.CResult_NoneChannelMonitorUpdateErrZ_ok();
+ long res = bindings.CResult_NoneChannelMonitorUpdateErrZ_ok();
+ results_to_free.add(res);
+ return res;
}
@Override
}
bindings.OutPoint_free(funding_txo);
bindings.ChannelMonitorUpdate_free(update);
- return bindings.CResult_NoneChannelMonitorUpdateErrZ_ok();
+ long res = bindings.CResult_NoneChannelMonitorUpdateErrZ_ok();
+ results_to_free.add(res);
+ return res;
}
@Override
bindings.ChannelMonitor_free(mon);
}
}
+ for (Long res : results_to_free) {
+ bindings.CResult_NoneChannelMonitorUpdateErrZ_free(res);
+ }
}
}