]> git.bitcoin.ninja Git - ldk-java/blob - ts/structs/Sign.ts
Merge pull request #69 from TheBlueMatt/main
[ldk-java] / ts / structs / Sign.ts
1
2             
3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
5
6
7
8             export class Sign extends CommonBase {
9
10                 bindings_instance?: bindings.LDKSign;
11
12                 constructor(ptr?: number, arg?: bindings.LDKSign, baseSign?: bindings.LDKBaseSign, pubkeys?: ChannelPublicKeys) {
13                     if (Number.isFinite(ptr)) {
14                                         super(ptr);
15                                         this.bindings_instance = null;
16                                     } else {
17                                         // TODO: private constructor instantiation
18                                         super(bindings.LDKSign_new(arg, baseSign, pubkeys == null ? 0 : pubkeys.clone_ptr()));
19                                         this.ptrs_to.push(arg);
20                                         this.ptrs_to.push(baseSign);
21
22                                     }
23                 }
24
25                 protected finalize() {
26                     if (this.ptr != 0) {
27                         bindings.Sign_free(this.ptr);
28                     }
29                     super.finalize();
30                 }
31
32                 static new_impl(arg: SignInterface, baseSign_impl: BaseSign.BaseSignInterface, pubkeys: ChannelPublicKeys): Sign {
33                     const impl_holder: LDKSignHolder = new LDKSignHolder();
34                     let structImplementation = <bindings.LDKSign>{
35                         // todo: in-line interface filling
36                         write (): Uint8Array {
37                                                         Uint8Array ret = arg.write();
38                                 return ret;
39                                                 },
40
41                                                 
42                     };
43                     impl_holder.held = new Sign (null, structImplementation, BaseSign.new_impl(BaseSign_impl, pubkeys).bindings_instance, pubkeys);
44                 }
45             }
46
47             export interface SignInterface {
48                 write(): Uint8Array;
49                                 
50             }
51
52             class LDKSignHolder {
53                 held: Sign;
54             }
55         public Uint8Array write() {
56                 Uint8Array ret = bindings.Sign_write(this.ptr);
57                 return ret;
58         }
59
60         public number clone_ptr() {
61                 number ret = bindings.Sign_clone_ptr(this.ptr);
62                 return ret;
63         }
64
65         public Sign clone() {
66                 number ret = bindings.Sign_clone(this.ptr);
67                 Sign ret_hu_conv = new Sign(null, ret);
68                 ret_hu_conv.ptrs_to.add(this);
69                 return ret_hu_conv;
70         }
71
72 }