[C#] Update auto-generated C# bindings
[ldk-java] / c_sharp / src / org / ldk / structs / BroadcasterInterface.cs
1
2 using org.ldk.impl;
3 using org.ldk.enums;
4 using org.ldk.util;
5 using System;
6
7 namespace org { namespace ldk { namespace structs {
8
9
10
11 /** An implementation of BroadcasterInterface */
12 public interface BroadcasterInterfaceInterface {
13         /**Sends a list of transactions out to (hopefully) be mined.
14          * This only needs to handle the actual broadcasting of transactions, LDK will automatically
15          * rebroadcast transactions that haven't made it into a block.
16          * 
17          * In some cases LDK may attempt to broadcast a transaction which double-spends another
18          * and this isn't a bug and can be safely ignored.
19          * 
20          * If more than one transaction is given, these transactions should be considered to be a
21          * package and broadcast together. Some of the transactions may or may not depend on each other,
22          * be sure to manage both cases correctly.
23          * 
24          * Bitcoin transaction packages are defined in BIP 331 and here:
25          * <https://github.com/bitcoin/bitcoin/blob/master/doc/policy/packages.md>
26          */
27         void broadcast_transactions(byte[][] txs);
28 }
29
30 /**
31  * An interface to send a transaction to the Bitcoin network.
32  */
33 public class BroadcasterInterface : CommonBase {
34         internal bindings.LDKBroadcasterInterface bindings_instance;
35         internal long instance_idx;
36
37         internal BroadcasterInterface(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
38         ~BroadcasterInterface() {
39                 if (ptr != 0) { bindings.BroadcasterInterface_free(ptr); }
40         }
41
42         private class LDKBroadcasterInterfaceHolder { internal BroadcasterInterface held; }
43         private class LDKBroadcasterInterfaceImpl : bindings.LDKBroadcasterInterface {
44                 internal LDKBroadcasterInterfaceImpl(BroadcasterInterfaceInterface arg, LDKBroadcasterInterfaceHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
45                 private BroadcasterInterfaceInterface arg;
46                 private LDKBroadcasterInterfaceHolder impl_holder;
47                 public void broadcast_transactions(long _txs) {
48                         int _txs_conv_8_len = InternalUtils.getArrayLength(_txs);
49                         byte[][] _txs_conv_8_arr = new byte[_txs_conv_8_len][];
50                         for (int i = 0; i < _txs_conv_8_len; i++) {
51                                 long _txs_conv_8 = InternalUtils.getU64ArrayElem(_txs, i);
52                                 byte[] _txs_conv_8_conv = InternalUtils.decodeUint8Array(_txs_conv_8);
53                                 _txs_conv_8_arr[i] = _txs_conv_8_conv;
54                         }
55                         bindings.free_buffer(_txs);
56                         arg.broadcast_transactions(_txs_conv_8_arr);
57                                 GC.KeepAlive(arg);
58                 }
59         }
60
61         /** Creates a new instance of BroadcasterInterface from a given implementation */
62         public static BroadcasterInterface new_impl(BroadcasterInterfaceInterface arg) {
63                 LDKBroadcasterInterfaceHolder impl_holder = new LDKBroadcasterInterfaceHolder();
64                 LDKBroadcasterInterfaceImpl impl = new LDKBroadcasterInterfaceImpl(arg, impl_holder);
65                 long[] ptr_idx = bindings.LDKBroadcasterInterface_new(impl);
66
67                 impl_holder.held = new BroadcasterInterface(null, ptr_idx[0]);
68                 impl_holder.held.instance_idx = ptr_idx[1];
69                 impl_holder.held.bindings_instance = impl;
70                 return impl_holder.held;
71         }
72
73         /**
74          * Sends a list of transactions out to (hopefully) be mined.
75          * This only needs to handle the actual broadcasting of transactions, LDK will automatically
76          * rebroadcast transactions that haven't made it into a block.
77          * 
78          * In some cases LDK may attempt to broadcast a transaction which double-spends another
79          * and this isn't a bug and can be safely ignored.
80          * 
81          * If more than one transaction is given, these transactions should be considered to be a
82          * package and broadcast together. Some of the transactions may or may not depend on each other,
83          * be sure to manage both cases correctly.
84          * 
85          * Bitcoin transaction packages are defined in BIP 331 and here:
86          * <https://github.com/bitcoin/bitcoin/blob/master/doc/policy/packages.md>
87          */
88         public void broadcast_transactions(byte[][] txs) {
89                 bindings.BroadcasterInterface_broadcast_transactions(this.ptr, InternalUtils.encodeUint64Array(InternalUtils.mapArray(txs, txs_conv_8 => InternalUtils.encodeUint8Array(txs_conv_8))));
90                 GC.KeepAlive(this);
91                 GC.KeepAlive(txs);
92         }
93
94 }
95 } } }