-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDiscoBall.cs
1612 lines (1339 loc) ยท 71.1 KB
/
DiscoBall.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
๏ปฟusing SUP.P2FK;
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using SUP.RPCClient;
using NBitcoin;
using Newtonsoft.Json;
using System.Linq;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Timers;
using NAudio.Wave;
using System.Drawing;
using Gma.QrCodeNet.Encoding;
using Gma.QrCodeNet.Encoding.Windows.Render;
using System.Drawing.Imaging;
using System.Drawing.Printing;
namespace SUP
{
public partial class DiscoBall : Form
{
private string _fromaddress;
private string _toaddress;
private string _fromimageurl;
private string _toimageurl;
private string messagecache;
// GPT3 AUDIO RECORDING MAGIC
private WaveInEvent waveIn;
private BufferedWaveProvider bufferedWaveProvider;
private WaveFileWriter writer;
private WaveOut waveOut;
private WaveFileReader reader;
private string mainnetURL = @"http://127.0.0.1:18332";
private string mainnetLogin = "good-user";
private string mainnetPassword = "better-password";
private string mainnetVersionByte = "111";
private string wavFileName = @"sup.wav";
private bool isRecording = false;
private bool isPrint = false;
private System.Timers.Timer recordTimer;
private DateTime startTime;
private QrEncoder encoder = new QrEncoder();
private GraphicsRenderer renderer = new GraphicsRenderer(new FixedModuleSize(2, QuietZoneModules.Two));
System.Drawing.Image bmIm;
private Random random = new Random();
public DiscoBall(string fromaddress = "", string fromimageurl = "", string toaddress = "", string toimageurl = "", bool isprivate = false, bool testnet = true)
{
InitializeComponent();
CreateEmojiPanel();
_fromaddress = fromaddress;
_toaddress = toaddress;
_fromimageurl = fromimageurl;
_toimageurl = toimageurl;
if (isprivate) { btnEncryptionStatus.Text = "PRIVATE ๐ค"; btnInquiry.Visible = false; }
System.Windows.Forms.ToolTip myTooltip = new System.Windows.Forms.ToolTip();
myTooltip.SetToolTip(supMessage, "enter the text of your message here. you can also include searchable #keywords.\nto include #keywords without them showing surround them with << >>\nexample << #rad #radical #RAD #RADICAL >>\n\nnote: if you are attaching a gif and you would like to include it in the default gif results\nadd the keyword #gif in your message along with a few #keywords to help other sup users find it.");
myTooltip.SetToolTip(btnAttach, "click to attach any url entered in the url text box. if no url is listed you will be prompted to select a file.\nyour file will be uploaded to IPFS and attached to the message.\nnote: if private your file will be encrypted prior to being uploaded to IPFS and attached.");
myTooltip.SetToolTip(btnEMOJI, "click to select and add an emoji to your message.");
myTooltip.SetToolTip(btnGIF, "click to select and add a gif to your message.");
myTooltip.SetToolTip(btnInquiry, "click to create and add a poll to your message.");
myTooltip.SetToolTip(btnPrint, "click to generate a paper message. right click to print or save it to disk.\npaper messages can be sent via US MAIL if private they can only be read by the recipient.\nnote: paper messages require a mobile app to view ( still in development ).");
myTooltip.SetToolTip(btnRecord, "click and hold this button to record an audio message.\nrelease the button when finished and it will be attached to your message.\nleft click the attachment to review your recording.\nif you are not happy, right click to remove it and try again.");
myTooltip.SetToolTip(btnRefresh, "click to etch your message to the active blockchain");
myTooltip.SetToolTip(btnEncryptionStatus, "this indicator informs you if the current message is\npublic ( viewable by everyone ) or private ( viewable by the recipient only )");
myTooltip.SetToolTip(btnFromSelector, "click to select from a list of local profiles.");
myTooltip.SetToolTip(btnToSelector, "click to select a profile you are currently following.");
ContextMenuStrip contextMenu = new ContextMenuStrip();
// Add a "Save to Disk" menu item
ToolStripMenuItem hideMenuItem = new ToolStripMenuItem("Exit");
ToolStripMenuItem saveMenuItem = new ToolStripMenuItem("Save to Disk");
ToolStripMenuItem printMenuItem = new ToolStripMenuItem("Print");
saveMenuItem.Click += SaveMenuItem_Click;
hideMenuItem.Click += HideMenuItem_Click;
printMenuItem.Click += PrintMenuItem_Click;
contextMenu.Items.Add(hideMenuItem);
contextMenu.Items.Add(saveMenuItem);
contextMenu.Items.Add(printMenuItem);
// Assign the context menu to the PictureBox
pictureBox1.ContextMenuStrip = contextMenu;
if (!testnet)
{
mainnetURL = @"http://127.0.0.1:8332";
mainnetLogin = "good-user";
mainnetPassword = "better-password";
mainnetVersionByte = "0";
}
}
private void DiscoBall_Load(object sender, EventArgs e)
{
fromImage.ImageLocation = _fromimageurl;
toImage.ImageLocation = _toimageurl;
txtFromAddress.Text = _fromaddress;
txtToAddress.Text = _toaddress;
// GPT3 Initialize NAudio objects for recording and playback
waveIn = new WaveInEvent();
waveIn.BufferMilliseconds = 100; // Increase the buffer size (adjust as needed)
waveIn.DataAvailable += WaveIn_DataAvailable;
waveIn.RecordingStopped += WaveIn_RecordingStopped;
bufferedWaveProvider = new BufferedWaveProvider(waveIn.WaveFormat);
bufferedWaveProvider.BufferLength = waveIn.BufferMilliseconds * 2 * waveIn.WaveFormat.AverageBytesPerSecond;
// Initialize the timer to prevent loss of last few seconds of recordings
recordTimer = new System.Timers.Timer();
recordTimer.Interval = 1000; // 2 seconds
recordTimer.Elapsed += RecordTimer_Elapsed;
recordTimer.AutoReset = false; // Only trigger once
}
private string GetRandomDelimiter()
{
string[] delimiters = { "\\", "/", ":", "*", "?", "\"", "<", ">", "|" };
return delimiters[random.Next(delimiters.Length)];
}
private void PrintImage(System.Drawing.Image img)
{
bmIm = img;
PrintDocument pd = new PrintDocument();
pd.PrintPage += this.pd_PrintPage;
pd.OriginAtMargins = false;
pd.DefaultPageSettings.Landscape = false;
pd.Print();
}
void pd_PrintPage(object sender, PrintPageEventArgs e)
{
System.Drawing.Image i = bmIm;
float newWidth = i.Width * 100 / i.HorizontalResolution;
float newHeight = i.Height * 100 / i.VerticalResolution;
float widthFactor = newWidth / e.PageBounds.Width;
float heightFactor = newHeight / e.PageBounds.Height;
if (widthFactor > 1 || heightFactor > 1)
{
if (widthFactor > heightFactor)
{
newWidth = newWidth / widthFactor;
newHeight = newHeight / widthFactor;
}
else
{
newWidth = newWidth / heightFactor;
newHeight = newHeight / heightFactor;
}
}
// Calculate the x and y coordinates of the top-left corner of the image
float x = (e.PageBounds.Width - newWidth) / 2;
float y = (e.PageBounds.Height - newHeight) / 2;
e.Graphics.DrawImage(i, x, y, (int)newWidth, (int)newHeight);
}
public async void btnAttach_Click(object sender, EventArgs e)
{
if (flowAttachments.Controls.Count < 6)
{
string imgurn = "";
List<string> imageExtensions = new List<string> { ".bmp", ".gif", ".ico", ".jpeg", ".jpg", ".png", ".tif", ".tiff", "" };
if (txtAttach.Text != "")
{
imgurn = txtAttach.Text;
if (!txtAttach.Text.ToLower().StartsWith("http"))
{
imgurn = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\root\" + txtAttach.Text.Replace("BTC:", "").Replace("MZC:", "").Replace("LTC:", "").Replace("DOG:", "").Replace("IPFS:", "").Replace("btc:", "").Replace("mzc:", "").Replace("ltc:", "").Replace("dog:", "").Replace("ipfs:", "").Replace(@"/", @"\");
if (txtAttach.Text.ToLower().StartsWith("ipfs:")) { imgurn = imgurn.Replace(@"\root\", @"\ipfs\"); }
}
string extension2 = Path.GetExtension(imgurn).ToLower();
if (imageExtensions.Contains(extension2))
{
try
{
Root root = new Root();
Regex regexTransactionId = new Regex(@"\b[0-9a-f]{64}\b");
Match urimatch = regexTransactionId.Match(txtAttach.Text);
string transactionid = urimatch.Value;
switch (txtAttach.Text.Substring(0, 4).ToUpper())
{
case "MZC:":
root = Root.GetRootByTransactionId(transactionid, "good-user", "better-password", @"http://127.0.0.1:12832", "50");
break;
case "BTC:":
root = Root.GetRootByTransactionId(transactionid, "good-user", "better-password", @"http://127.0.0.1:8332", "0");
break;
case "LTC:":
root = Root.GetRootByTransactionId(transactionid, "good-user", "better-password", @"http://127.0.0.1:9332", "48");
break;
case "DOG:":
root = Root.GetRootByTransactionId(transactionid, "good-user", "better-password", @"http://127.0.0.1:22555", "30");
break;
case "IPFS":
if (txtAttach.Text.Length == 51) { imgurn += @"\artifact"; }
if (!System.IO.Directory.Exists(@"ipfs/" + txtAttach.Text.Substring(5, 46) + "-build") && !System.IO.File.Exists(@"ipfs/" + txtAttach.Text.Substring(5, 46)))
{
Task ipfsTask = Task.Run(() =>
{
Directory.CreateDirectory(@"ipfs/" + txtAttach.Text.Substring(5, 46) + "-build");
Process process2 = new Process();
process2.StartInfo.FileName = @"ipfs\ipfs.exe";
process2.StartInfo.Arguments = "get " + txtAttach.Text.Substring(5, 46) + @" -o ipfs\" + txtAttach.Text.Substring(5, 46);
process2.Start();
process2.WaitForExit();
if (System.IO.File.Exists("ipfs/" + txtAttach.Text.Substring(5, 46)))
{
try { System.IO.File.Move("ipfs/" + txtAttach.Text.Substring(5, 46), "ipfs/" + txtAttach.Text.Substring(5, 46) + "_tmp"); }
catch
{
System.IO.File.Delete("ipfs/" + txtAttach.Text.Substring(5, 46) + "_tmp");
System.IO.File.Move("ipfs/" + txtAttach.Text.Substring(5, 46), "ipfs/" + txtAttach.Text.Substring(5, 46) + "_tmp");
}
string fileName = txtAttach.Text.Replace(@"//", "").Replace(@"\\", "").Substring(51);
if (fileName == "")
{
fileName = "artifact";
}
else { fileName = fileName.Replace(@"/", "").Replace(@"\", ""); }
Directory.CreateDirectory(@"ipfs/" + txtAttach.Text.Substring(5, 46));
try { System.IO.File.Move("ipfs/" + txtAttach.Text.Substring(5, 46) + "_tmp", imgurn); } catch { }
}
try
{
if (File.Exists("IPFS_PINNING_ENABLED"))
{
Process process3 = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = @"ipfs\ipfs.exe",
Arguments = "pin add " + txtAttach.Text.Substring(5, 46),
UseShellExecute = false,
CreateNoWindow = true
}
};
process3.Start();
}
}
catch { }
try { Directory.Delete(@"ipfs/" + txtAttach.Text.Substring(5, 46)); } catch { }
try
{
Directory.Delete(@"ipfs/" + txtAttach.Text.Substring(5, 46) + "-build");
}
catch { }
});
}
else
{
}
break;
default:
root = Root.GetRootByTransactionId(transactionid, mainnetLogin, mainnetPassword, mainnetURL, mainnetVersionByte);
break;
}
}
catch { }
if (File.Exists(imgurn) || (imgurn.ToUpper().StartsWith("HTTP") && extension2 != ""))
{
PictureBox pictureBox = new PictureBox();
// Set the PictureBox properties
pictureBox.Tag = txtAttach.Text;
pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox.Width = 50;
pictureBox.Height = 50;
pictureBox.ImageLocation = imgurn;
pictureBox.MouseClick += PictureBox_MouseClick;
// Add the PictureBox to the FlowLayoutPanel
this.Invoke((MethodInvoker)delegate
{
flowAttachments.Controls.Add(pictureBox);
});
}
else
{
PictureBox pictureBox = new PictureBox();
// Set the PictureBox properties
pictureBox.Tag = txtAttach.Text;
pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox.Width = 50;
pictureBox.Height = 50;
pictureBox.ImageLocation = @"includes\HugPuddle.jpg";
pictureBox.MouseClick += PictureBox_MouseClick;
// Add the PictureBox to the FlowLayoutPanel
this.Invoke((MethodInvoker)delegate
{
flowAttachments.Controls.Add(pictureBox);
});
}
}
else
{
PictureBox pictureBox = new PictureBox();
// Set the PictureBox properties
pictureBox.Tag = txtAttach.Text;
pictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox.Width = 50;
pictureBox.Height = 50;
pictureBox.ImageLocation = @"includes\HugPuddle.jpg";
pictureBox.MouseClick += PictureBox_MouseClick;
// Add the PictureBox to the FlowLayoutPanel
this.Invoke((MethodInvoker)delegate
{
flowAttachments.Controls.Add(pictureBox);
});
}
}
else
{
System.Windows.Forms.OpenFileDialog openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string filePath = openFileDialog1.FileName;
ProcessFileAsync(filePath);
}
}
}
this.Invoke((MethodInvoker)delegate
{
txtAttach.Text = "";
});
}
private void PictureBox_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
PictureBox pictureBox = (PictureBox)sender;
flowAttachments.Controls.Remove(pictureBox);
}
}
private void discoButton_Click(object sender, EventArgs e)
{
if (txtAttach.Text.Length > 0)
{
DialogResult result = MessageBox.Show("You have an unattached URL in the attachment box.\nMake sure to click the ๐ to attach a URL to your message.\nAre you sure you want to send this?", "Confirmation", MessageBoxButtons.YesNo);
if (result == DialogResult.No)
{
return;
}
}
string transMessage = supMessage.Text;
List<string> encodedList = new List<string>();
foreach (Control attach in flowAttachments.Controls)
{
if (attach.Tag != null)
{
transMessage = transMessage + "<<" + attach.Tag.ToString() + ">>";
}
}
int salt;
using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
{
byte[] saltBytes = new byte[4];
rng.GetBytes(saltBytes);
salt = -Math.Abs(BitConverter.ToInt32(saltBytes, 0) % 100000);
}
transMessage = transMessage + "<<" + salt.ToString() + ">>";
byte[] messageBytes = Encoding.UTF8.GetBytes(transMessage);
string OBJP2FK = GetRandomDelimiter() + messageBytes.Length + GetRandomDelimiter() + transMessage + txtINQJson.Text;
byte[] OBJP2FKBytes = new byte[] { };
PROState toProfile = PROState.GetProfileByAddress(_toaddress, mainnetLogin, mainnetPassword, mainnetURL, mainnetVersionByte);
string signature = "";
string signatureAddress = "";
NetworkCredential credentials = new NetworkCredential(mainnetLogin, mainnetPassword);
NBitcoin.RPC.RPCClient rpcClient = new NBitcoin.RPC.RPCClient(credentials, new Uri(mainnetURL), Network.Main);
if (txtFromAddress.Text != "")
{
System.Security.Cryptography.SHA256 mySHA256 = SHA256Managed.Create();
byte[] hashValue = new byte[] { };
hashValue = mySHA256.ComputeHash(Encoding.UTF8.GetBytes(OBJP2FK));
signatureAddress = txtFromAddress.Text;
try { signature = rpcClient.SendCommand("signmessage", signatureAddress, BitConverter.ToString(hashValue).Replace("-", String.Empty)).ResultString; }
catch (Exception ex)
{
lblObjectStatus.Text = ex.Message;
return;
}
}
if (btnEncryptionStatus.Text == "PRIVATE ๐ค")
{
OBJP2FK = "SIG" + GetRandomDelimiter() + "88" + GetRandomDelimiter() + signature + OBJP2FK;
byte[] combinedBytes = Root.EncryptRootBytes(mainnetLogin, mainnetPassword, mainnetURL, signatureAddress, Encoding.UTF8.GetBytes(OBJP2FK), toProfile.PKX, toProfile.PKY);
// Split byte array into chunks of maximum length 20
for (int i = 0; i < combinedBytes.Length; i += 20)
{
byte[] bytechunk = combinedBytes.Skip(i).Take(20).ToArray();
string address = "";
if (bytechunk.Length < 20)
{
int diff = 20 - bytechunk.Length;
byte[] paddedBytes = bytechunk.Concat(new byte[diff].Select(x => (byte)'#')).ToArray();
bytechunk = paddedBytes;
}
address = Base58.EncodeWithCheckSum(new byte[] { byte.Parse(mainnetVersionByte) }.Concat(bytechunk).ToArray());
encodedList.Add(address);
}
}
else
{
if (txtFromAddress.Text != "")
{
OBJP2FK = "SIG" + GetRandomDelimiter() + "88" + GetRandomDelimiter() + signature + OBJP2FK;
}
byte[] inputBytes = Encoding.UTF8.GetBytes(OBJP2FK); // Convert the string to bytes
for (int i = 0; i < inputBytes.Length; i += 20)
{
byte[] chunkBytes = new byte[Math.Min(20, inputBytes.Length - i)];
Array.Copy(inputBytes, i, chunkBytes, 0, chunkBytes.Length);
// Right-pad the chunkBytes with '#' if it's less than 20 bytes
if (chunkBytes.Length < 20)
{
byte[] paddedChunkBytes = new byte[20];
Array.Copy(chunkBytes, paddedChunkBytes, chunkBytes.Length);
for (int j = chunkBytes.Length; j < 20; j++)
{
paddedChunkBytes[j] = (byte)'#';
}
chunkBytes = paddedChunkBytes;
}
string chunkBase58 = Base58.EncodeWithCheckSum(
new byte[] { (byte)Int32.Parse(mainnetVersionByte) }.Concat(chunkBytes).ToArray());
if (!encodedList.Contains(chunkBase58))
{
encodedList.Add(chunkBase58);
}
else
{
DialogResult result = MessageBox.Show("The following duplicate information was detected: [ " + chunkBase58 + " ]. Sorry, you must still use Apertus.io for etchings that require repetitive data", "Confirmation", MessageBoxButtons.OK);
}
}
}
string pattern = @"#[^\s]{1,20}";
Regex regex = new Regex(pattern);
foreach (Match match in regex.Matches(supMessage.Text))
{
string keyword = match.Value.Substring(1);
string encodedKeyword = Root.GetPublicAddressByKeyword(keyword, mainnetVersionByte);
string P2FKASCII = Root.GetKeywordByPublicAddress(encodedKeyword, "ASCII");
Regex regexSpecialChars = new Regex(@"([\\/:*?""<>|])+");
if (regexSpecialChars.IsMatch(P2FKASCII))
{
MessageBox.Show("Sup!? Found characters within a #keyword " + keyword + " that could corrupt the message. Use at your own risk!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
encodedList.Add(encodedKeyword);
}
// Remove spaces from txtToAddress.Text
string inputText = txtToAddress.Text.Replace(" ", "");
// Split the input text by comma or semicolon
char[] delimiters = { ',', ';' };
string[] addresses = inputText.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
// Iterate through the addresses in reverse order and add them to the beginning of encodedList if not already present
for (int i = addresses.Length - 1; i >= 0; i--)
{
string address = addresses[i].Trim(); // Trim any leading/trailing spaces
if (!encodedList.Contains(address) && address != signatureAddress)
{
encodedList.Add(address); // Add to the beginning of the list
}
}
//this will add the order specific inq address if one exists.
if (txtINQAddress.Text != "") { encodedList.Add(txtINQAddress.Text); }
if (txtFromAddress.Text != "") { encodedList.Add(signatureAddress); }
lblObjectStatus.Text = "cost: " + (0.00000546 * encodedList.Count).ToString("0.00000000") + " + miner fee";
if (File.Exists(@"WALKIE_TALKIE_ENABLED") && flowAttachments.Contains(this.btnPlay))
{
// Perform the action
var recipients = new Dictionary<string, decimal>();
foreach (var encodedAddress in encodedList)
{
try { recipients.Add(encodedAddress, 0.00000546m); } catch { }
}
CoinRPC a = new CoinRPC(new Uri(mainnetURL), new NetworkCredential(mainnetLogin, mainnetPassword));
try
{
string accountsString = "";
try { accountsString = rpcClient.SendCommand("listaccounts").ResultString; } catch { }
var accounts = JsonConvert.DeserializeObject<Dictionary<string, decimal>>(accountsString);
var keyWithLargestValue = accounts.Aggregate((x, y) => x.Value > y.Value ? x : y).Key;
var results = a.SendMany(keyWithLargestValue, recipients);
lblTransactionId.Text = results;
txtAttach.Text = "";
flowAttachments.Controls.Clear();
supMessage.Text = "";
}
catch (Exception ex) { lblObjectStatus.Text = ex.Message; }
}
else
{
if (isPrint)
{
var recipients = new Dictionary<string, decimal>();
foreach (var encodedAddress in encodedList)
{
try { recipients.Add(encodedAddress, 0.00000546m); } catch { }
}
string addressList = JsonConvert.SerializeObject(recipients);
PrintMessage(addressList);
isPrint = false;
//pictureBox1.Visible=false;
}
else
{
DialogResult result = MessageBox.Show("Are you sure you want to send this?", "Confirmation", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
// Perform the action
var recipients = new Dictionary<string, decimal>();
foreach (var encodedAddress in encodedList)
{
try { recipients.Add(encodedAddress, 0.00000546m); } catch { }
}
CoinRPC a = new CoinRPC(new Uri(mainnetURL), new NetworkCredential(mainnetLogin, mainnetPassword));
try
{
string accountsString = "";
try { accountsString = rpcClient.SendCommand("listaccounts").ResultString; } catch { }
var accounts = JsonConvert.DeserializeObject<Dictionary<string, decimal>>(accountsString);
var keyWithLargestValue = accounts.Aggregate((x, y) => x.Value > y.Value ? x : y).Key;
var results = a.SendMany(keyWithLargestValue, recipients);
lblTransactionId.Text = results;
txtAttach.Text = "";
flowAttachments.Controls.Clear();
supMessage.Text = "";
txtINQAddress.Text = "";
txtINQJson.Text = "";
}
catch (Exception ex) { lblObjectStatus.Text = ex.Message; }
}
}
}
}
private void btnGIF_Click(object sender, EventArgs e)
{
GifTool gifToolForm = new GifTool(this); // Pass the reference to the current form as the parent form
gifToolForm.ShowDialog();
}
private void btnEMOJI_Click(object sender, EventArgs e)
{
// Show/hide the emoji panel based on its current visibility
emojiPanel.Visible = !emojiPanel.Visible;
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
// Clean up NAudio resources
waveIn?.Dispose();
writer?.Dispose();
if (waveOut != null)
{
waveOut.Stop();
waveOut.Dispose();
waveOut = null;
}
if (reader != null)
{
reader.Dispose();
reader = null;
}
try { File.Delete(wavFileName); } catch { }
}
private void BtnRecord_MouseDown(object sender, MouseEventArgs e)
{
btnRecord.BackColor = System.Drawing.Color.Blue;
btnRecord.ForeColor = System.Drawing.Color.Yellow;
// Start recording audio if not already recording
if (!isRecording)
{
startTime = DateTime.Now;
waveIn.StartRecording();
isRecording = true;
}
}
private void BtnRecord_MouseUp(object sender, MouseEventArgs e)
{
recordTimer.Start(); // Start the delay timer when the button is released
}
private void BtnPlay_Click(object sender, MouseEventArgs e)
{
if (waveOut != null)
{
waveOut.Stop();
waveOut.Dispose();
waveOut = null;
}
waveOut = new WaveOut();
waveOut.PlaybackStopped += waveOut_PlaybackStopped;
reader = new WaveFileReader(wavFileName);
waveOut.Init(reader);
waveOut.Play();
}
private void BtnPlay_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
flowAttachments.Controls.Remove(this.btnPlay);
try { File.Delete(wavFileName); } catch { }
}
}
private void WaveIn_DataAvailable(object sender, WaveInEventArgs e)
{
// Add recorded data to the bufferedWaveProvider
bufferedWaveProvider.AddSamples(e.Buffer, 0, e.BytesRecorded);
// If writer is not initialized and recording has started, create the WaveFileWriter
if (writer == null && isRecording)
{
writer = new WaveFileWriter(wavFileName, waveIn.WaveFormat);
}
// If writer is initialized, write the recorded data to the file
if (writer != null)
{
writer.Write(e.Buffer, 0, e.BytesRecorded);
// Flush the writer to ensure data is written immediately (optional, but recommended)
writer.Flush();
}
}
private async void WaveIn_RecordingStopped(object sender, StoppedEventArgs e)
{
// Clean up after recording is stopped
if (writer != null)
{
isRecording = false;
writer?.Dispose();
writer = null;
}
TimeSpan duration = DateTime.Now - startTime;
if (duration.TotalSeconds < 2.2)
{
// Do nothing, as the time difference is less than 2.2 second
return;
}
string proccessingFile = wavFileName;
string processingid = Guid.NewGuid().ToString();
string ipfsHash = "";
try
{
// Attempt to remove the existing btnINQ control
flowAttachments.Controls.RemoveByKey("btnPlay");
}
catch (ArgumentException)
{
// Control with the specified name doesn't exist, so no need to handle the exception
}
this.btnPlay = new System.Windows.Forms.Button();
this.btnPlay.Font = new System.Drawing.Font("Segoe UI Emoji", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.btnPlay.ForeColor = System.Drawing.Color.Black;
this.btnPlay.Name = "btnPlay";
this.btnPlay.Padding = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.btnPlay.RightToLeft = System.Windows.Forms.RightToLeft.No;
this.btnPlay.Size = new System.Drawing.Size(50, 46);
this.btnPlay.Text = "โถ๏ธ";
this.btnPlay.UseVisualStyleBackColor = true;
this.btnPlay.MouseClick += new MouseEventHandler(BtnPlay_Click);
this.btnPlay.MouseUp += new MouseEventHandler(BtnPlay_MouseUp);
if (btnEncryptionStatus.Text == "PRIVATE ๐ค")
{
if (waveOut != null)
{
waveOut.Stop();
waveOut.Dispose();
waveOut = null;
}
if (reader != null)
{
reader.Dispose();
reader = null;
}
byte[] rootbytes = Root.GetRootBytesByFile(new string[] { wavFileName });
PROState toProfile = PROState.GetProfileByAddress(txtToAddress.Text, mainnetLogin, mainnetPassword, mainnetURL, mainnetVersionByte);
rootbytes = Root.EncryptRootBytes(mainnetLogin, mainnetPassword, mainnetURL, txtToAddress.Text, rootbytes, toProfile.PKX, toProfile.PKY, true);
string proccessingDirectory = @"root\" + processingid;
Directory.CreateDirectory(proccessingDirectory);
proccessingFile = proccessingDirectory + @"\SEC";
File.WriteAllBytes(proccessingFile, rootbytes);
}
// Add file to IPFS
Task<string> addTask = Task.Run(() =>
{
Process process = new Process();
process.StartInfo.FileName = @"ipfs\ipfs.exe";
process.StartInfo.Arguments = "add \"" + proccessingFile + "\"";
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = false;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
string hash = output.Split(' ')[1];
this.Invoke((MethodInvoker)delegate
{
if (btnEncryptionStatus.Text == "PRIVATE ๐ค")
{
this.btnPlay.Tag = "IPFS:" + hash + @"\SEC";
}
else
{
// Set the PictureBox properties
this.btnPlay.Tag = "IPFS:" + hash + @"\" + wavFileName;
}
flowAttachments.Controls.Add(this.btnPlay);
});
return "IPFS:" + hash;
});
ipfsHash = await addTask;
try { Directory.Delete(@"root\" + processingid, true); } catch { }
if (File.Exists(@"WALKIE_TALKIE_ENABLED"))
{
btnRefresh.PerformClick();
}
}
private void waveOut_PlaybackStopped(object sender, StoppedEventArgs e)
{
if (waveOut != null)
{
waveOut.Stop();
waveOut.Dispose();
waveOut = null;
}
if (reader != null)
{
reader.Dispose();
reader = null;
}
}
private void RecordTimer_Elapsed(object sender, ElapsedEventArgs e)
{
btnRecord.BackColor = System.Drawing.Color.White;
btnRecord.ForeColor = System.Drawing.Color.Black;
if (isRecording)
{
waveIn.StopRecording();
isRecording = false;
// Dispose the MemoryStream to release resources
waveIn?.Dispose();
// Save the recorded data to a WAV file
if (writer != null)
{
writer.Dispose();
writer = null;
}
}
}
private void CreateEmojiPanel()
{
emojiPanel.BorderStyle = BorderStyle.FixedSingle;
string[] emojis = {
"๐", "๐", "๐", "๐", "๐", "๐
", "๐", "๐คฃ", "๐", "๐",
"๐ฅฐ", "๐", "๐", "๐", "๐", "๐ป", "๐ค", "๐คฉ", "๐ฅณ", "๐",
"๐", "๐", "๐", "๐", "๐", "๐", "โน๏ธ", "๐ฃ", "๐ข", "๐ญ",
"๐ค", "๐ฉ", "๐ฅบ", "๐ฐ", "๐ฑ", "๐จ", "๐ข", "๐ ", "๐ก", "๐คฏ",
"๐ณ", "๐ซ", "๐", "๐ฃ", "๐ฎ", "๐ฉ", "๐ฅฑ", "๐ช", "๐ด", "๐ท",
"๐ค", "๐ค", "๐คข", "๐คฎ", "๐คง", "๐ต", "๐คจ", "๐ง", "๐", "๐",
"๐ถ", "๐", "๐", "๐ค", "๐คซ", "๐คญ", "๐คฅ", "๐", "๐", "๐ฌ",
"๐", "โน๏ธ", "๐ฆ", "๐ง", "๐ฎ", "๐ฒ", "๐ฅด", "๐คค", "๐ด", "๐ช",
"๐ต", "๐ค", "๐ฅบ", "๐ฅด", "๐ฌ", "๐คซ", "๐คญ", "๐ง", "๐ค", "๐",
"๐ฟ", "๐น", "๐บ", "๐", "๐ป", "๐ฝ", "๐ค", "๐ฉ", "๐บ", "๐ธ",
"๐น", "๐ป", "๐ผ", "๐ฝ", "๐", "๐ฟ", "๐พ", "๐", "๐", "๐",
"๐ค", "๐", "๐", "๐", "โ", "๐ค", "๐ค", "๐ค", "โ๏ธ", "๐ค",
"๐", "๐", "๐", "๐", "๐", "โ๏ธ", "โ", "๐ค", "๐", "๐",
"๐", "๐ค", "โ๏ธ", "๐", "๐ช", "๐ฆพ", "๐", "๐ฆต", "๐ฆฟ", "๐ฆถ",
"๐", "๐ฆป", "๐", "๐ง ", "๐ฆท", "๐ฆด", "๐", "๐", "๐
", "๐",
"๐ฅ", "๐ฅ", "๐ฃ", "๐", "๐", "๐", "๐", "๐", "๐ฉ", "๐งข",
"๐", "๐", "๐ฆ", "๐ฑ", "๐ป", "๐ฅ", "โจ๏ธ", "๐ฒ", "๐", "โ๏ธ",
"๐ง", "๐ฅ", "๐ค", "โ๏ธ", "๐ฌ", "๐ฎ", "๐ฏ", "๐ข", "๐ฃ", "๐ ",
"๐", "๐", "๐", "๐ป", "๐", "๐", "๐", "๐ค", "๐ง", "๐ถ",
"๐ต", "๐ฅ", "๐ท", "๐บ", "๐ธ","๐ป", "๐น", "๐ค",
"๐ฌ", "๐บ", "๐ฝ", "๐ฅ", "๐ฟ", "๐", "๐ฆ", "๐", "๐พ", "๐น๏ธ",
"๐ฎ", "๐ฒ", "โ๏ธ", "๐งฉ", "๐งธ", "๐ฏ", "๐ณ", "๐ฎ", "๐ฐ",
"๐", "๐ธ", "๐", "๐", "๐", "๐", "๐ช", "โ๏ธ", "๐ ", "๐",
"๐", "๐", "๐", "๐", "๐
", "๐", "๐", "๐", "๐", "๐",
"๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐",
"๐", "๐", "๐", "๐", "๐", "๐ก", "๐ค", "โ
", "๐ฅ", "๐ฆ",
"๐ง", "โ๏ธ", "๐ฉ", "๐จ", "โ๏ธ", "โ๏ธ", "โ", "๐ฌ", "๐จ", "๐ช",
"๐ซ", "๐ฆ", "๐", "โ", "๐ง", "๐ฉ", "๐จ", "โ๏ธ", "โ", "๐",
"๐", "๐", "๐พ", "๐ป", "๐ผ", "๐ธ", "๐ฎ", "๐ต", "๐น", "๐ฅ",
"๐บ", "๐ท", "๐ฑ", "๐ด", "๐ฒ", "๐ณ", "๐ต", "๐ฟ", "โ๏ธ", "๐",
"๐", "๐", "๐", "๐", "๐ฐ", "๐", "๐", "๐", "๐", "๐",
"๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐", "๐ฅญ", "๐",
"๐ฅฅ", "๐ฅ", "๐
", "๐", "๐ฅ", "๐ฅฆ", "๐ฅ", "๐ถ", "๐ฝ", "๐ฅ",
"๐", "๐ฅ", "๐ ", "๐ฅ", "๐", "๐ฅ", "๐ฅจ", "๐ง", "๐ฅ", "๐ณ",
"๐ฅ", "๐ฅฉ", "๐", "๐", "๐ฆด", "๐ญ", "๐", "๐", "๐", "๐ฅช",
"๐ฅ", "๐ฎ", "๐ฏ", "๐ฅ", "๐ฅ", "๐", "๐", "๐ฒ", "๐", "๐ฃ",
"๐ฑ", "๐ฅ", "๐ค", "๐ข", "๐ก", "๐ฆ", "๐ง", "๐จ", "๐ฉ", "๐ช",
"๐", "๐ฐ", "๐ง", "๐ฅง", "๐ซ", "๐ฌ", "๐ญ", "๐ฎ", "๐ฏ", "๐ผ",
"๐ฅค", "๐บ", "๐ป", "๐ฅ", "๐ท", "๐ฅ", "๐ธ", "๐น", "๐พ", "๐ฅ",
"๐ด", "๐ง", "๐ฝ๏ธ", "๐ฅข", "๐ง", "๐ฅ", "๐ฅก", "๐ง", "๐ฅค", "๐ฅข",
"๐ฝ๏ธ", "๐ฅ", "๐ด", "๐ฅ", "๐ธ", "๐ท", "๐ฅ", "๐พ", "๐ป", "๐บ",
"๐ฏ", "๐ฎ", "๐ญ", "๐ฌ", "๐ซ", "๐", "๐ฐ", "๐ฅง", "๐ฉ", "๐จ",
"๐ง", "๐ฆ", "๐ก", "๐ข", "๐ค", "๐ฅ", "๐ฑ", "๐ฃ", "๐", "๐",
"๐", "๐ฅ", "๐ฅ", "๐ฏ", "๐ฎ", "๐ฅช", "๐", "๐", "๐", "๐ญ",
"๐ฆด", "๐", "๐",
"๐ถ", "๐ง", "๐ฆ", "๐ง", "๐ง", "๐ฑโโ๏ธ", "๐ฑโโ๏ธ", "๐ง", "๐จ", "๐งโโ๏ธ",
"๐จโ๐ฆฐ", "๐จโ๐ฆฑ", "๐จโ๐ฆณ", "๐จโ๐ฆฒ", "๐งโ๐ฆฐ", "๐งโ๐ฆฑ", "๐งโ๐ฆณ", "๐งโ๐ฆฒ", "๐ฉ", "๐ฉโ๐ฆฐ",
"๐ฉโ๐ฆฑ", "๐ฉโ๐ฆณ", "๐ฉโ๐ฆฒ", "๐งโ๐ฆฐ", "๐งโ๐ฆฑ", "๐งโ๐ฆณ", "๐งโ๐ฆฒ", "๐ง", "๐ด", "๐ต",
"๐โโ๏ธ", "๐โโ๏ธ", "๐โโ๏ธ", "๐โโ๏ธ", "๐
โโ๏ธ", "๐
โโ๏ธ", "๐โโ๏ธ", "๐โโ๏ธ", "๐โโ๏ธ", "๐โโ๏ธ",
"๐โโ๏ธ", "๐โโ๏ธ", "๐งโโ๏ธ", "๐งโโ๏ธ", "๐โโ๏ธ", "๐โโ๏ธ", "๐คฆโโ๏ธ", "๐คฆโโ๏ธ", "๐คทโโ๏ธ", "๐คทโโ๏ธ",
"๐ถโโ๏ธ", "๐ถโโ๏ธ", "๐โโ๏ธ", "๐โโ๏ธ", "๐", "๐บ", "๐ด", "๐ฏโโ๏ธ", "๐ฏโโ๏ธ", "๐งโโ๏ธ",
"๐งโโ๏ธ", "๐งโโ๏ธ", "๐งโโ๏ธ", "๐คบ", "๐", "โท๏ธ", "๐", "๐โ๏ธ", "๐โ๏ธ", "๐โโ๏ธ",
"๐โโ๏ธ", "๐ฃโโ๏ธ", "๐ฃโโ๏ธ", "๐งโโ๏ธ", "๐งโโ๏ธ", "๐งโโ๏ธ", "๐งโโ๏ธ", "๐", "๐", "๐งโ๐คโ๐ง",
"๐ฌ", "๐ญ", "๐ซ", "๐ฉโโค๏ธโ๐จ", "๐จโโค๏ธโ๐จ", "๐ฉโโค๏ธโ๐ฉ", "๐", "๐ฉโโค๏ธโ๐โ๐จ", "๐จโโค๏ธโ๐โ๐จ", "๐ฉโ","โค๏ธโ๐ฅ", "โค๏ธโ๐ฉน", "๐", "๐ฉโโค๏ธโ๐โ๐ฉ", "๐ช", "๐จโ๐ฉโ๐ฆ", "๐จโ๐ฉโ๐ง", "๐จโ๐ฉโ๐ฆโ๐ฆ", "๐จโ๐ฉโ๐งโ๐ง", "๐จโ๐จโ๐ฆ",
"๐จโ๐จโ๐ง", "๐จโ๐จโ๐ฆโ๐ฆ", "๐จโ๐จโ๐งโ๐ง", "๐ฉโ๐ฉโ๐ฆ", "๐ฉโ๐ฉโ๐ง", "๐ฉโ๐ฉโ๐ฆโ๐ฆ", "๐ฉโ๐ฉโ๐งโ๐ง", "๐จโ๐ฆ", "๐จโ๐ฆโ๐ฆ", "๐จโ๐ง",
"๐จโ๐งโ๐ฆ", "๐จโ๐งโ๐ง", "๐ฉโ๐ฆ", "๐ฉโ๐ฆโ๐ฆ", "๐ฉโ๐ง", "๐ฉโ๐งโ๐ฆ", "๐ฉโ๐งโ๐ง", "๐ฃ", "๐ค", "๐ฅ", "๐ฃ",
"๐งณ", "๐", "โ๏ธ", "๐งต", "๐งถ", "๐งท", "๐งน", "๐งบ",
"๐งป", "๐งผ", "๐", "๐ฌ", "โฐ๏ธ",
"๐ชฆ", "โฑ๏ธ", "๐ฟ", "๐บ", "๐ฎ", "๐ฟ", "๐งฟ", "๐", "๐",
"๐", "๐", "๐", "๐", "๐", "๐๏ธ", "๐ช",
"๐จ", "โ๏ธ", "โ๏ธ", "๐ ", "๐ก", "โ๏ธ", "๐ช", "๐ซ", "๐ช", "๐น",
"๐ก", "๐งฑ", "๐งณ", "๐", "๐", "๐ฝ",
"๐ฟ", "๐", "๐งด", "๐งผ",
"๐งฝ", "๐งพ", "๐งป", "๐", "๐", "๐", "๐งฎ", "๐",
"๐", "๐", "๐", "๐", "๐
", "๐", "๐", "๐", "๐", "๐ณ",
"๐", "๐", "๐", "๐", "๐ฐ", "๐", "๐", "๐", "๐", "๐",
"๐", "๐", "๐", "๐", "๐", "๐งท", "๐", "๐", "๐", "๐",
"๐", "๐งฎ", "๐", "๐", "โ๏ธ", "๐", "๐", "โ๏ธ", "๐", "๐",
"๐", "โ๏ธ", "๐", "๐", "๐", "๐", "๐", "๐", "๐ท", "๐ผ",
"๐", "๐", "๐", "๐
", "๐", "๐", "๐", "๐", "๐", "๐",
"๐", "๐", "๐", "๐", "๐", "๐", "๐", "โ๏ธ", "๐", "๐",
"๐", "โ๏ธ", "๐", "๐", "๐", "๐", "๐", "๐", "๐ท", "๐ผ",
"๐ธ", "๐ท", "๐น", "๐ฅ", "๐ฝ", "๐", "๐", "โ๏ธ", "๐", "๐ ",
"๐", "๐", "๐ป", "๐ฅ", "๐จ", "โจ๏ธ", "๐ฑ", "๐ฒ", "๐ฝ", "๐พ",
"๐ฟ", "๐", "๐งฎ", "๐", "๐", "๐", "๐งญ", "๐", "๐", "๐",
"๐", "๐", "๐", "๐", "๐ฅ", "๐ฅ", "๐ฅ", "๐
", "๐", "๐ต",