1
1
use std:: sync:: { Arc } ;
2
- use std:: time:: { SystemTime , UNIX_EPOCH } ;
3
2
3
+ use secp256k1:: constants:: { SECRET_KEY_SIZE , PUBLIC_KEY_SIZE } ;
4
4
use bitcoin:: blockdata:: transaction:: { Transaction } ;
5
+ use bitcoin:: util:: key:: PrivateKey ;
5
6
6
- use lightning:: util:: config:: UserConfig ;
7
7
use lightning:: util:: logger:: { Logger , Record } ;
8
8
9
9
use lightning:: chain:: chaininterface:: { BroadcasterInterface , FeeEstimator , ConfirmationTarget } ;
10
10
use lightning:: chain:: keysinterface:: { KeysManager , InMemoryChannelKeys } ;
11
11
use lightning:: chain:: transaction:: { OutPoint } ;
12
12
13
+ use lightning:: ln:: chan_utils:: ChannelPublicKeys ;
13
14
use lightning:: ln:: channelmonitor:: { ManyChannelMonitor , ChannelMonitor , HTLCUpdate , ChannelMonitorUpdateErr , ChannelMonitorUpdate } ;
14
- use lightning:: ln:: channelmanager:: { ChannelManager } ;
15
15
16
16
use crate :: error:: FFIResult ;
17
17
use crate :: handle:: { Out , Ref , RefMut , HandleShared } ;
18
18
19
+ #[ repr( transparent) ]
20
+ struct SecretKey ( [ u8 ; SECRET_KEY_SIZE ] ) ;
21
+
22
+ #[ repr( transparent) ]
23
+ struct PublicKey ( [ u8 ; PUBLIC_KEY_SIZE ] ) ;
24
+
25
+ /*
26
+ #[repr(C)]
27
+ pub struct ChannelPublicKeys{
28
+ /// The public key which is used to sign all commitment transactions, as it appears in the
29
+ /// on-chain channel lock-in 2-of-2 multisig output.
30
+ pub funding_pubkey: PublicKey,
31
+ /// The base point which is used (with derive_public_revocation_key) to derive per-commitment
32
+ /// revocation keys. The per-commitment revocation private key is then revealed by the owner of
33
+ /// a commitment transaction so that their counterparty can claim all available funds if they
34
+ /// broadcast an old state.
35
+ pub revocation_basepoint: PublicKey,
36
+ /// The base point which is used (with derive_public_key) to derive a per-commitment payment
37
+ /// public key which receives immediately-spendable non-HTLC-encumbered funds.
38
+ pub payment_basepoint: PublicKey,
39
+ /// The base point which is used (with derive_public_key) to derive a per-commitment payment
40
+ /// public key which receives non-HTLC-encumbered funds which are only available for spending
41
+ /// after some delay (or can be claimed via the revocation path).
42
+ pub delayed_payment_basepoint: PublicKey,
43
+ /// The base point which is used (with derive_public_key) to derive a per-commitment public key
44
+ /// which is used to encumber HTLC-in-flight outputs.
45
+ pub htlc_basepoint: PublicKey,
46
+ };
47
+
48
+ */
49
+
50
+ #[ repr( C ) ]
51
+ struct FFIInMemoryChannelKeys {
52
+ /// Private key of anchor tx
53
+ funding_key : SecretKey ,
54
+ /// Local secret key for blinded revocation pubkey
55
+ revocation_base_key : SecretKey ,
56
+ /// Local secret key used in commitment tx htlc outputs
57
+ payment_base_key : SecretKey ,
58
+ /// Local secret key used in HTLC tx
59
+ delayed_payment_base_key : SecretKey ,
60
+ /// Local htlc secret key used in commitment tx htlc outputs
61
+ htlc_base_key : SecretKey ,
62
+ /// Commitment seed
63
+ commitment_seed : [ u8 ; 32 ] ,
64
+ /// Local public keys and basepoints
65
+ pub ( crate ) local_channel_pubkeys : ChannelPublicKeys ,
66
+ /// Remote public keys and base points
67
+ pub ( crate ) remote_channel_pubkeys : Option < ChannelPublicKeys > ,
68
+ /// The total value of this channel
69
+ channel_value_satoshis : u64 ,
70
+ }
71
+
72
+ // #[repr(c)]
73
+ // struct FFIChannelMonitor {
74
+ // }
75
+ #[ repr( C ) ]
76
+ struct FFIOutPoint {
77
+ txid : [ u8 ; 32 ] ,
78
+ index : u16
79
+ }
80
+
19
81
#[ repr( C ) ]
20
82
pub struct FFIManyChannelMonitor {
21
83
add_monitor_ptr : extern "C" fn ( & Self , funding_txo : OutPoint , monitor : ChannelMonitor < InMemoryChannelKeys > ) -> i32 ,
@@ -100,6 +162,3 @@ impl Logger for FFILogger {
100
162
( self . log_ptr ) ( self , record) ;
101
163
}
102
164
}
103
-
104
- type FFIArcChannelManager = ChannelManager < InMemoryChannelKeys , Arc < FFIManyChannelMonitor > , Arc < FFIBroadCaster > , Arc < KeysManager > , Arc < FFIFeeEstimator > > ;
105
- type FFIArcChannelManagerHandle < ' a > = HandleShared < ' a , FFIArcChannelManager > ;
0 commit comments