57
57
#include < event2/keyvalq_struct.h>
58
58
#include < sys/signal.h>
59
59
60
+ #include " config/_dbb-config.h"
61
+
60
62
#ifdef DBB_ENABLE_QT
61
63
#include < QApplication>
62
64
#include < QPushButton>
@@ -178,7 +180,6 @@ int main(int argc, char** argv)
178
180
// check devices
179
181
if (!DBB::isConnectionOpen ())
180
182
{
181
- printf (" no connection\n " );
182
183
if (DBB::openConnection ())
183
184
{
184
185
#ifdef DBB_ENABLE_QT
@@ -198,93 +199,9 @@ int main(int argc, char** argv)
198
199
std::this_thread::sleep_for (std::chrono::milliseconds (1000 ));
199
200
}
200
201
});
201
-
202
-
202
+
203
203
ECC_Start ();
204
-
205
- BitPayWalletClient client;
206
-
207
- std::string myName = " test" ;
208
-
209
- printf (" start seed\n " );
210
- client.seed ();
211
- printf (" seed done\n " );
212
- std::string requestPubKey;
213
- if (!client.GetRequestPubKey (requestPubKey))
214
- printf (" Retriving request key failed!\n " );
215
-
216
- std::string copayerHash;
217
- client.GetCopayerHash (myName, copayerHash);
218
- printf (" ---copayer hash: %s\n " , copayerHash.c_str ());
219
- CKey aKey = client.GetNewKey ();
220
- assert (aKey.VerifyPubKey (aKey.GetPubKey ()) == 1 );
221
-
222
- BitpayWalletInvitation invitation;
223
- if (!client.ParseWalletInvitation (" MJRiJFPTE8cJtQ2YBHtasnL3vNy8NF4BRLBNLemcBCMg55DmEWeY9FaXGrQEBjRd1ZsoZ9hVfgL" , invitation))
224
- printf (" parse invitation failed!\n " );
225
-
226
- std::string copayerSignature;
227
- client.GetCopayerSignature (copayerHash, invitation.walletPrivKey , copayerSignature);
228
- printf (" copayerSignature %s\n " , copayerSignature.c_str ());
229
- printf (" walletid: %s\n " , invitation.walletID .c_str ());
230
- printf (" network: %s\n " , invitation.network .c_str ());
231
-
232
- UniValue jsonArgs (UniValue::VOBJ);
233
- jsonArgs.push_back (Pair (" walletId" , invitation.walletID ));
234
- jsonArgs.push_back (Pair (" name" , myName));
235
- jsonArgs.push_back (Pair (" xPubKey" , client.GetXPubKey ()));
236
- jsonArgs.push_back (Pair (" requestPubKey" , requestPubKey));
237
- jsonArgs.push_back (Pair (" isTemporaryRequestKey" , false ));
238
- jsonArgs.push_back (Pair (" copayerSignature" , copayerSignature));
239
-
240
- std::string json = jsonArgs.write ();
241
- printf (" JSON: %s" , json.c_str ());
242
-
243
- std::string method = " post" ;
244
- std::string url = " /v1/wallets/" +invitation.walletID +" /copayers" ;
245
-
246
- std::string xSignature = client.SignRequest (method, url, json);
247
- std::string xIdentity = requestPubKey;
248
- std::string postUrl = " https://bws.bitpay.com/bws/api" ;
249
-
250
- std::string header = " \n\n curl -X POST -H \" Content-Type: application/json\" -d '" +json+" ' --header \" x-identity: " +xIdentity+" \" --header \" x-signature: " +xSignature+" \" -v " +postUrl+url+" \n\n " ;
251
- printf (" header: %s" , header.c_str ());
252
-
253
- ECC_Stop ();
254
-
255
- // unsigned char vchPub[65];
256
- // int clen = 65;
257
- // secp256k1_pubkey_t pubkey;
258
- // assert(secp256k1_ec_seckey_verify(secp256k1_context, vch) == 1);
259
- // int ret = secp256k1_ec_pubkey_create(secp256k1_context, &pubkey, vch);
260
- // unsigned char pubkeyc[65];
261
- // int pubkeyclen = 65;
262
- // secp256k1_ec_pubkey_serialize(secp256k1_context, pubkeyc, &pubkeyclen, &pubkey, true);
263
-
264
- // std::string hexStr = HexStr(pubkeyc, pubkeyc+pubkeyclen, false);
265
- //
266
- // secp256k1_pubkey_t pubkeyNew;
267
- // std::vector<unsigned char> vPubKey = ParseHex(hexStr);
268
- // int suc = secp256k1_ec_pubkey_parse(secp256k1_context, &pubkeyNew, &vPubKey[0], vPubKey.size());
269
-
270
-
271
-
272
- // var message = [method.toLowerCase(), url, JSON.stringify(args)].join('|');
273
- // std::string requestString = "get|/v1/wallets/?r=62416|{}";
274
- // unsigned char hashD[32];
275
- // doubleSha256((char*)requestString.c_str(), hashD);
276
- // secp256k1_ecdsa_signature_t signature;
277
- // suc = secp256k1_ecdsa_sign(secp256k1_context, hashD, &signature, vch, NULL, NULL);
278
- //
279
- // unsigned char sig[74];
280
- // int siglen = 74;
281
- // suc = secp256k1_ecdsa_signature_serialize_der(secp256k1_context, sig, &siglen, &signature);
282
- // std::string hexStrDER = HexStr(sig, sig+siglen, false);
283
- //
284
- //
285
- // std::string header = "\n\ncurl --header \"x-identity: "+hexStr+"\" --header \"x-signature: "+hexStrDER+"\" -v https://bws.bitpay.com/bws/api/v1/wallets/\n\n";
286
- // printf("header: %s", header.c_str());
287
-
204
+
288
205
#ifdef DBB_ENABLE_QT
289
206
#if QT_VERSION > 0x050100
290
207
// Generate high-dpi pixmaps
@@ -295,7 +212,7 @@ int main(int argc, char** argv)
295
212
std::thread httpThread ([&]() {
296
213
event_base_dispatch (base);
297
214
});
298
-
215
+
299
216
QApplication app (argc, argv);
300
217
301
218
widget = new DBBDaemonGui (0 );
@@ -306,5 +223,6 @@ int main(int argc, char** argv)
306
223
event_base_dispatch (base);
307
224
#endif
308
225
226
+ ECC_Stop ();
309
227
exit (1 );
310
228
}
0 commit comments