Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

Commit aa95d00

Browse files
committed
Updated eclair-core to latest wip-android commit (05a48241)
* `Commitments()` renamed to `commitments()`. * `test` chain renamed to `testnet` * Updated `NativeSecp256k1` files as of commit a3d5dda of PR #508 of bitcoin-core/secp256k1 - awaiting for merge. See bitcoin-core/secp256k1#508
1 parent f85f443 commit aa95d00

File tree

4 files changed

+62
-22
lines changed

4 files changed

+62
-22
lines changed

app/src/main/cpp/secp256k1/org_bitcoin_NativeSecp256k1.c

+53-13
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ SECP256K1_API jint JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ec_1secke
124124
}
125125

126126
SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ec_1pubkey_1create
127-
(JNIEnv* env, jclass classObject, jobject byteBufferObject, jlong ctx_l)
127+
(JNIEnv* env, jclass classObject, jobject byteBufferObject, jlong ctx_l, jboolean compressed)
128128
{
129129
secp256k1_context *ctx = (secp256k1_context*)(uintptr_t)ctx_l;
130130
const unsigned char* secKey = (unsigned char*) (*env)->GetDirectBufferAddress(env, byteBufferObject);
@@ -137,11 +137,11 @@ SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1e
137137

138138
int ret = secp256k1_ec_pubkey_create(ctx, &pubkey, secKey);
139139

140-
unsigned char outputSer[33];
141-
size_t outputLen = 33;
140+
unsigned char outputSer[65];
141+
size_t outputLen = 65;
142142

143143
if( ret ) {
144-
int ret2 = secp256k1_ec_pubkey_serialize(ctx,outputSer, &outputLen, &pubkey,SECP256K1_EC_COMPRESSED );(void)ret2;
144+
int ret2 = secp256k1_ec_pubkey_serialize(ctx,outputSer, &outputLen, &pubkey, compressed ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED);(void)ret2;
145145
}
146146

147147
intsarray[0] = outputLen;
@@ -236,18 +236,17 @@ SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1p
236236
}
237237

238238
SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1pubkey_1tweak_1add
239-
(JNIEnv* env, jclass classObject, jobject byteBufferObject, jlong ctx_l, jint publen)
239+
(JNIEnv* env, jclass classObject, jobject byteBufferObject, jlong ctx_l, jint publen, jboolean compressed)
240240
{
241241
secp256k1_context *ctx = (secp256k1_context*)(uintptr_t)ctx_l;
242-
/* secp256k1_pubkey* pubkey = (secp256k1_pubkey*) (*env)->GetDirectBufferAddress(env, byteBufferObject);*/
243242
unsigned char* pkey = (*env)->GetDirectBufferAddress(env, byteBufferObject);
244243
const unsigned char* tweak = (unsigned char*) (pkey + publen);
245244

246245
jobjectArray retArray;
247246
jbyteArray pubArray, intsByteArray;
248247
unsigned char intsarray[2];
249-
unsigned char outputSer[33];
250-
size_t outputLen = 33;
248+
unsigned char outputSer[65];
249+
size_t outputLen = 65;
251250

252251
secp256k1_pubkey pubkey;
253252
int ret = secp256k1_ec_pubkey_parse(ctx, &pubkey, pkey, publen);
@@ -257,7 +256,7 @@ SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1p
257256
}
258257

259258
if( ret ) {
260-
int ret2 = secp256k1_ec_pubkey_serialize(ctx,outputSer, &outputLen, &pubkey,SECP256K1_EC_COMPRESSED );(void)ret2;
259+
int ret2 = secp256k1_ec_pubkey_serialize(ctx,outputSer, &outputLen, &pubkey, compressed ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED);(void)ret2;
261260
}
262261

263262
intsarray[0] = outputLen;
@@ -281,7 +280,7 @@ SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1p
281280
}
282281

283282
SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1pubkey_1tweak_1mul
284-
(JNIEnv* env, jclass classObject, jobject byteBufferObject, jlong ctx_l, jint publen)
283+
(JNIEnv* env, jclass classObject, jobject byteBufferObject, jlong ctx_l, jint publen, jboolean compressed)
285284
{
286285
secp256k1_context *ctx = (secp256k1_context*)(uintptr_t)ctx_l;
287286
unsigned char* pkey = (*env)->GetDirectBufferAddress(env, byteBufferObject);
@@ -290,8 +289,8 @@ SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1p
290289
jobjectArray retArray;
291290
jbyteArray pubArray, intsByteArray;
292291
unsigned char intsarray[2];
293-
unsigned char outputSer[33];
294-
size_t outputLen = 33;
292+
unsigned char outputSer[65];
293+
size_t outputLen = 65;
295294

296295
secp256k1_pubkey pubkey;
297296
int ret = secp256k1_ec_pubkey_parse(ctx, &pubkey, pkey, publen);
@@ -301,7 +300,7 @@ SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1p
301300
}
302301

303302
if( ret ) {
304-
int ret2 = secp256k1_ec_pubkey_serialize(ctx,outputSer, &outputLen, &pubkey,SECP256K1_EC_COMPRESSED );(void)ret2;
303+
int ret2 = secp256k1_ec_pubkey_serialize(ctx,outputSer, &outputLen, &pubkey, compressed ? SECP256K1_EC_COMPRESSED : SECP256K1_EC_UNCOMPRESSED);(void)ret2;
305304
}
306305

307306
intsarray[0] = outputLen;
@@ -332,6 +331,47 @@ SECP256K1_API jlong JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdsa_1p
332331
return 0;
333332
}
334333

334+
SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ec_1pubkey_1decompress
335+
(JNIEnv* env, jclass classObject, jobject byteBufferObject, jlong ctx_l, jint publen)
336+
{
337+
secp256k1_context *ctx = (secp256k1_context*)(uintptr_t)ctx_l;
338+
const unsigned char* pubdata = (*env)->GetDirectBufferAddress(env, byteBufferObject);
339+
340+
secp256k1_pubkey pubkey;
341+
342+
jobjectArray retArray;
343+
jbyteArray pubkeyArray, intsByteArray;
344+
unsigned char intsarray[2];
345+
346+
int ret = secp256k1_ec_pubkey_parse(ctx, &pubkey, pubdata, publen);
347+
348+
unsigned char outputSer[65];
349+
size_t outputLen = 65;
350+
351+
if( ret ) {
352+
int ret2 = secp256k1_ec_pubkey_serialize(ctx,outputSer, &outputLen, &pubkey, SECP256K1_EC_UNCOMPRESSED);(void)ret2;
353+
}
354+
355+
intsarray[0] = outputLen;
356+
intsarray[1] = ret;
357+
358+
retArray = (*env)->NewObjectArray(env, 2,
359+
(*env)->FindClass(env, "[B"),
360+
(*env)->NewByteArray(env, 1));
361+
362+
pubkeyArray = (*env)->NewByteArray(env, outputLen);
363+
(*env)->SetByteArrayRegion(env, pubkeyArray, 0, outputLen, (jbyte*)outputSer);
364+
(*env)->SetObjectArrayElement(env, retArray, 0, pubkeyArray);
365+
366+
intsByteArray = (*env)->NewByteArray(env, 2);
367+
(*env)->SetByteArrayRegion(env, intsByteArray, 0, 2, (jbyte*)intsarray);
368+
(*env)->SetObjectArrayElement(env, retArray, 1, intsByteArray);
369+
370+
(void)classObject;
371+
372+
return retArray;
373+
}
374+
335375
SECP256K1_API jobjectArray JNICALL Java_org_bitcoin_NativeSecp256k1_secp256k1_1ecdh
336376
(JNIEnv* env, jclass classObject, jobject byteBufferObject, jlong ctx_l, jint publen)
337377
{

app/src/main/cpp/secp256k1/org_bitcoin_NativeSecp256k1.h

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/fr/acinq/eclair/wallet/EclairEventService.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ else if (message instanceof ChannelIdAssigned && channelDetailsMap.containsKey((
149149
// ---- we sent a channel sig => update corresponding payment to PENDING in app's DB
150150
else if (message instanceof ChannelSignatureSent) {
151151
ChannelSignatureSent sigSent = (ChannelSignatureSent) message;
152-
Either<WaitingForRevocation, Crypto.Point> nextCommitInfo = sigSent.Commitments().remoteNextCommitInfo();
152+
Either<WaitingForRevocation, Crypto.Point> nextCommitInfo = sigSent.commitments().remoteNextCommitInfo();
153153
if (nextCommitInfo.isLeft()) {
154154
RemoteCommit commit = nextCommitInfo.left().get().nextRemoteCommit();
155155
Iterator<DirectedHtlc> htlcsIterator = commit.spec().htlcs().iterator();
@@ -188,7 +188,7 @@ else if (message instanceof ChannelSignatureSent) {
188188
else if (message instanceof ChannelSignatureReceived && channelDetailsMap.containsKey(((ChannelSignatureReceived) message).channel())) {
189189
ChannelSignatureReceived csr = (ChannelSignatureReceived) message;
190190
ChannelDetails cd = channelDetailsMap.get(csr.channel());
191-
LocalCommit localCommit = csr.Commitments().localCommit();
191+
LocalCommit localCommit = csr.commitments().localCommit();
192192
long outHtlcsAmount = 0L;
193193
Iterator<DirectedHtlc> htlcsIterator = localCommit.spec().htlcs().iterator();
194194
while (htlcsIterator.hasNext()) {
@@ -197,8 +197,8 @@ else if (message instanceof ChannelSignatureReceived && channelDetailsMap.contai
197197
outHtlcsAmount += h.add().amountMsat();
198198
}
199199
}
200-
cd.channelReserveSat = csr.Commitments().localParams().channelReserveSatoshis();
201-
cd.minimumHtlcAmountMsat = csr.Commitments().localParams().htlcMinimumMsat();
200+
cd.channelReserveSat = csr.commitments().localParams().channelReserveSatoshis();
201+
cd.minimumHtlcAmountMsat = csr.commitments().localParams().htlcMinimumMsat();
202202
cd.htlcsInFlightCount = htlcsIterator.size();
203203
cd.balanceMsat = new MilliSatoshi(localCommit.spec().toLocalMsat() + outHtlcsAmount);
204204
cd.capacityMsat = new MilliSatoshi(localCommit.spec().totalFunds());

app/src/main/resources/application.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
eclair {
2-
chain = "test"
2+
chain = "testnet"
33
local-features = "88"
44
}
55
akka {

0 commit comments

Comments
 (0)