diff --git a/LightArionum/ApplicationEvents.vb b/LightArionum/ApplicationEvents.vb new file mode 100644 index 0000000..83eb605 --- /dev/null +++ b/LightArionum/ApplicationEvents.vb @@ -0,0 +1,10 @@ +Namespace My + ' The following events are available for MyApplication: + ' Startup: Raised when the application starts, before the startup form is created. + ' Shutdown: Raised after all application forms are closed. This event is not raised if the application terminates abnormally. + ' UnhandledException: Raised if the application encounters an unhandled exception. + ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. + ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected. + Partial Friend Class MyApplication + End Class +End Namespace diff --git a/LightArionum/LightArionum.vbproj b/LightArionum/LightArionum.vbproj index b5e158e..fb05557 100644 --- a/LightArionum/LightArionum.vbproj +++ b/LightArionum/LightArionum.vbproj @@ -13,27 +13,27 @@ WindowsForms v4.6.1 true - true + false - publish\ + publish/ true - Web - true + Disk + false Foreground 7 Days false false - true - https://www.arionum.com/LightArionumC/ - https://www.arionum.com/LightArionumC/ + false + https://www.arionum.com/LightArionumD/ + en Arionum Developers - true index.html - 37 + true + 61 1.0.0.%2a - false + true true true true @@ -126,6 +126,9 @@ false + + lightarionum.snk + ..\packages\BouncyCastle.Crypto.dll.1.8.1\lib\BouncyCastle.Crypto.dll @@ -237,6 +240,7 @@ + frmQR.vb @@ -309,7 +313,7 @@ - + Designer diff --git a/LightArionum/My Project/AssemblyInfo.vb b/LightArionum/My Project/AssemblyInfo.vb index 8b61fa6..838dc7d 100644 --- a/LightArionum/My Project/AssemblyInfo.vb +++ b/LightArionum/My Project/AssemblyInfo.vb @@ -1,4 +1,5 @@ -Imports System +Imports System.Resources +Imports System Imports System.Reflection Imports System.Runtime.InteropServices @@ -8,14 +9,14 @@ Imports System.Runtime.InteropServices ' Review the values of the assembly attributes - + - + 'The following GUID is for the ID of the typelib if this project is exposed to COM @@ -31,5 +32,6 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' - - + + + diff --git a/LightArionum/My Project/Settings.Designer.vb b/LightArionum/My Project/Settings.Designer.vb index bc39fd1..c96c302 100644 --- a/LightArionum/My Project/Settings.Designer.vb +++ b/LightArionum/My Project/Settings.Designer.vb @@ -13,42 +13,42 @@ Option Explicit On Namespace My - - _ + + _ Partial Friend NotInheritable Class MySettings Inherits Global.System.Configuration.ApplicationSettingsBase - - Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) - + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + #Region "My.Settings Auto-Save Functionality" #If _MyType = "WindowsForms" Then - Private Shared addedHandler As Boolean + Private Shared addedHandler As Boolean - Private Shared addedHandlerLockObject As New Object + Private Shared addedHandlerLockObject As New Object - _ - Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) - If My.Application.SaveMySettingsOnExit Then - My.Settings.Save() - End If - End Sub + _ + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub #End If #End Region - + Public Shared ReadOnly Property [Default]() As MySettings Get - + #If _MyType = "WindowsForms" Then - If Not addedHandler Then - SyncLock addedHandlerLockObject - If Not addedHandler Then - AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings - addedHandler = True - End If - End SyncLock - End If + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If #End If Return defaultInstance End Get @@ -57,13 +57,13 @@ Namespace My End Namespace Namespace My - - _ + + _ Friend Module MySettingsProperty - - _ + + _ Friend ReadOnly Property Settings() As Global.LightArionum.My.MySettings Get Return Global.LightArionum.My.MySettings.Default diff --git a/LightArionum/My Project/app.manifest b/LightArionum/My Project/app.manifest index f0a58bd..22556f8 100644 --- a/LightArionum/My Project/app.manifest +++ b/LightArionum/My Project/app.manifest @@ -20,7 +20,7 @@ - + diff --git a/LightArionum/Resources/imgBG3.jpg b/LightArionum/Resources/imgBG3.jpg index 6337220..3994f9b 100644 Binary files a/LightArionum/Resources/imgBG3.jpg and b/LightArionum/Resources/imgBG3.jpg differ diff --git a/LightArionum/frmMain.Designer.vb b/LightArionum/frmMain.Designer.vb index 1696d0f..0b1a2fa 100644 --- a/LightArionum/frmMain.Designer.vb +++ b/LightArionum/frmMain.Designer.vb @@ -44,6 +44,9 @@ Partial Class frmMain Me.Label9 = New System.Windows.Forms.Label() Me.sendTo = New System.Windows.Forms.TextBox() Me.TabPage1 = New System.Windows.Forms.TabPage() + Me.btnAlias = New System.Windows.Forms.Button() + Me.lblAlias = New System.Windows.Forms.Label() + Me.Label15 = New System.Windows.Forms.Label() Me.Button3 = New System.Windows.Forms.Button() Me.Panel1 = New System.Windows.Forms.Panel() Me.DataGridView1 = New System.Windows.Forms.DataGridView() @@ -104,6 +107,7 @@ Partial Class frmMain Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog() Me.pool_update = New System.Windows.Forms.Timer(Me.components) Me.Button4 = New System.Windows.Forms.Button() + Me.Label24 = New System.Windows.Forms.Label() Label2 = New System.Windows.Forms.Label() Label4 = New System.Windows.Forms.Label() Me.TabPage2.SuspendLayout() @@ -356,6 +360,9 @@ Partial Class frmMain Me.TabPage1.BackColor = System.Drawing.Color.Transparent Me.TabPage1.BackgroundImage = Global.LightArionum.My.Resources.Resources.bgfade Me.TabPage1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch + Me.TabPage1.Controls.Add(Me.btnAlias) + Me.TabPage1.Controls.Add(Me.lblAlias) + Me.TabPage1.Controls.Add(Me.Label15) Me.TabPage1.Controls.Add(Me.Button3) Me.TabPage1.Controls.Add(Me.Panel1) Me.TabPage1.Controls.Add(Me.Label5) @@ -370,6 +377,34 @@ Partial Class frmMain Me.TabPage1.Text = "Receive Funds" Me.TabPage1.UseVisualStyleBackColor = True ' + 'btnAlias + ' + Me.btnAlias.Location = New System.Drawing.Point(780, 18) + Me.btnAlias.Name = "btnAlias" + Me.btnAlias.Size = New System.Drawing.Size(125, 25) + Me.btnAlias.TabIndex = 12 + Me.btnAlias.Text = "Set Alias" + Me.btnAlias.UseVisualStyleBackColor = True + Me.btnAlias.Visible = False + ' + 'lblAlias + ' + Me.lblAlias.AutoSize = True + Me.lblAlias.Location = New System.Drawing.Point(778, 24) + Me.lblAlias.Name = "lblAlias" + Me.lblAlias.Size = New System.Drawing.Size(0, 16) + Me.lblAlias.TabIndex = 11 + ' + 'Label15 + ' + Me.Label15.AutoSize = True + Me.Label15.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label15.Location = New System.Drawing.Point(730, 20) + Me.Label15.Name = "Label15" + Me.Label15.Size = New System.Drawing.Size(47, 20) + Me.Label15.TabIndex = 10 + Me.Label15.Text = "Alias:" + ' 'Button3 ' Me.Button3.BackColor = System.Drawing.Color.SlateGray @@ -489,7 +524,7 @@ Partial Class frmMain Me.Label3.AutoSize = True Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label3.ForeColor = System.Drawing.SystemColors.ActiveCaptionText - Me.Label3.Location = New System.Drawing.Point(111, 21) + Me.Label3.Location = New System.Drawing.Point(5, 21) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(108, 20) Me.Label3.TabIndex = 1 @@ -498,7 +533,7 @@ Partial Class frmMain 'txtaddress ' Me.txtaddress.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle - Me.txtaddress.Location = New System.Drawing.Point(219, 20) + Me.txtaddress.Location = New System.Drawing.Point(113, 20) Me.txtaddress.Name = "txtaddress" Me.txtaddress.Size = New System.Drawing.Size(610, 22) Me.txtaddress.TabIndex = 0 @@ -691,7 +726,7 @@ Partial Class frmMain Me.miner_pool.Name = "miner_pool" Me.miner_pool.Size = New System.Drawing.Size(382, 22) Me.miner_pool.TabIndex = 1 - Me.miner_pool.Text = "http://aropool.com" + Me.miner_pool.Text = "http://aro.cool" ' 'miner_button ' @@ -958,11 +993,24 @@ Partial Class frmMain Me.Button4.TabIndex = 9 Me.Button4.UseVisualStyleBackColor = False ' + 'Label24 + ' + Me.Label24.AutoSize = True + Me.Label24.BackColor = System.Drawing.Color.Transparent + Me.Label24.Font = New System.Drawing.Font("Verdana", 12.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label24.ForeColor = System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer), CType(CType(192, Byte), Integer), CType(CType(255, Byte), Integer)) + Me.Label24.Location = New System.Drawing.Point(359, 15) + Me.Label24.Name = "Label24" + Me.Label24.Size = New System.Drawing.Size(156, 18) + Me.Label24.TabIndex = 10 + Me.Label24.Text = "LightWallet 0.4.0" + ' 'frmMain ' Me.BackColor = System.Drawing.SystemColors.Window Me.BackgroundImage = Global.LightArionum.My.Resources.Resources.imgBG3 Me.ClientSize = New System.Drawing.Size(956, 542) + Me.Controls.Add(Me.Label24) Me.Controls.Add(Me.Button4) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.StatusStrip1) @@ -1077,4 +1125,8 @@ Partial Class frmMain Friend WithEvents PictureBox1 As PictureBox Friend WithEvents Button3 As Button Friend WithEvents Button4 As Button + Friend WithEvents btnAlias As Button + Friend WithEvents lblAlias As Label + Friend WithEvents Label15 As Label + Friend WithEvents Label24 As Label End Class diff --git a/LightArionum/frmMain.resx b/LightArionum/frmMain.resx index c389efb..428baeb 100644 --- a/LightArionum/frmMain.resx +++ b/LightArionum/frmMain.resx @@ -292,9 +292,6 @@ True - - True - True @@ -322,42 +319,6 @@ True - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - - - True - True diff --git a/LightArionum/frmMain.vb b/LightArionum/frmMain.vb index f6f3707..66adae9 100644 --- a/LightArionum/frmMain.vb +++ b/LightArionum/frmMain.vb @@ -85,6 +85,8 @@ Public Class frmMain Me.statusNode.Text = peer + + res = get_json(peer + "/api.php?q=currentBlock") If res.ToString = "" Then @@ -92,8 +94,10 @@ Public Class frmMain End If Me.statusBlock.Text = res("height") + res = get_json(peer + "/api.php?q=getTransactions&account=" + address) + If res.ToString = "" Then Exit Function End If @@ -296,6 +300,21 @@ Public Class frmMain End End If + Dim Generator As System.Random = New System.Random() + Dim r = Generator.Next(0, total_peers - 1) + Dim peer = peers(r) + + Dim res + res = get_json(peer + "/api.php?q=getAlias&account=" + address) + + If res = False Then + btnAlias.Visible = True + End If + + + + + trd = New Thread(AddressOf sync_data) trd.IsBackground = True trd.Start() @@ -418,7 +437,7 @@ Public Class frmMain End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click - If sendTo.Text.Length < 10 Then Exit Sub + If sendTo.Text.Length < 4 Then Exit Sub If Convert.ToDecimal(sendAmt.Text) < 0.00000001 Then MsgBox("Invalid amount", vbCritical) Exit Sub @@ -432,6 +451,10 @@ Public Class frmMain Exit Sub End If + Dim version As String = 1 + If sendTo.Text.Length < 26 Then + version = 2 + End If @@ -441,7 +464,7 @@ Public Class frmMain uTime = (DateTime.UtcNow - New DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds Dim info As String - info = FormatNumber(sum, 8).Replace(",", "") + "-" + FormatNumber(f, 8).Replace(",", "") + "-" + sendTo.Text + "-" + sendMsg.Text + "-1-" + public_key + "-" + uTime.ToString + info = FormatNumber(sum, 8).Replace(",", "") + "-" + FormatNumber(f, 8).Replace(",", "") + "-" + sendTo.Text + "-" + sendMsg.Text + "-" + version + "-" + public_key + "-" + uTime.ToString ' Console.WriteLine(info) frmLog.flog("Transaction data: " & info) Dim file As System.IO.StreamWriter @@ -478,14 +501,13 @@ Public Class frmMain Dim sig As String = SimpleBase.Base58.Bitcoin.Encode(signature) - - res = get_json(peer + "/api.php?q=send&version=1&public_key=" + public_key + "&signature=" + sig + "&dst=" + sendTo.Text + "&val=" + FormatNumber(sum, 8).Replace(",", "") + "&date=" + uTime.ToString + "&message=" + sendMsg.Text) + res = get_json(peer + "/api.php?q=send&version=" + Version + "&public_key=" + public_key + "&signature=" + sig + "&dst=" + sendTo.Text + "&val=" + FormatNumber(sum, 8).Replace(",", "") + "&date=" + uTime.ToString + "&message=" + sendMsg.Text) If res.ToString = "" Then r = Generator.Next(0, total_peers - 1) peer = peers(r) - res = get_json(peer + "/api.php?q=send&version=1&public_key=" + public_key + "&signature=" + sig + "&dst=" + sendTo.Text + "&val=" + FormatNumber(sum, 8).Replace(",", "") + "&date=" + uTime.ToString + "&message=" + sendMsg.Text) + res = get_json(peer + "/api.php?q=send&version=" + Version + "&public_key=" + public_key + "&signature=" + sig + "&dst=" + sendTo.Text + "&val=" + FormatNumber(sum, 8).Replace(",", "") + "&date=" + uTime.ToString + "&message=" + sendMsg.Text) If res.ToString = "" Then MsgBox("Could not send the transaction to the peer (" & peer & ")! Please try again!", vbCritical) Exit Sub @@ -901,4 +923,68 @@ Public Class frmMain Private Sub frmMain_DoubleClick(sender As Object, e As EventArgs) Handles Me.DoubleClick End Sub + + Private Sub btnAlias_Click(sender As Object, e As EventArgs) Handles btnAlias.Click + On Error GoTo Err + If Convert.ToInt32(statusBlock.Text) < 80000 Then + MsgBox("The alias can only be set after block 80.000", vbCritical) + Exit Sub + End If + Dim als = InputBox("Please enter your new alias. Only upper case letters, 4-25 chars.") + als = als.ToUpper() + + Dim uTime As Int64 + uTime = (DateTime.UtcNow - New DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds + + Dim info As String + info = FormatNumber(0.00000001, 8).Replace(",", "") + "-" + FormatNumber(10, 8).Replace(",", "") + "-" + address + "-" + als + "-3-" + public_key + "-" + uTime.ToString + ' Console.WriteLine(info) + frmLog.flog("Transaction data: " & info) + Dim file As System.IO.StreamWriter + + + Dim res As String + Static Generator As System.Random = New System.Random() + Dim r = Generator.Next(0, total_peers - 1) + Dim peer = peers(r) + + Dim tmp_key As String = coin2pem(private_key, True) + Dim tmp_key2 As String = coin2pem(public_key, False) + + + Dim textReader As TextReader = New StringReader(tmp_key) + Dim pemReader As PemReader = New PemReader(textReader) + Dim _keyPair As AsymmetricCipherKeyPair = pemReader.ReadObject() + Dim _privateKeyParams As ECPrivateKeyParameters = _keyPair.Private + Dim _publicKeyParams As ECPublicKeyParameters = _keyPair.Public + + + + Dim signer As ISigner = SignerUtilities.GetSigner("SHA-256withECDSA") + signer.Init(True, _keyPair.Private) + Dim bytes As Byte() = System.Text.Encoding.UTF8.GetBytes(info) + signer.BlockUpdate(bytes, 0, bytes.Length) + Dim signature As Byte() = signer.GenerateSignature() + + Dim sig As String = SimpleBase.Base58.Bitcoin.Encode(signature) + Dim version As String = 3 + + res = get_json(peer + "/api.php?q=send&version=" + version + "&public_key=" + public_key + "&signature=" + sig + "&dst=" + address + "&val=" + FormatNumber(0.00000001, 8).Replace(",", "") + "&date=" + uTime.ToString + "&message=" + als) + + If res.ToString = "" Then + r = Generator.Next(0, total_peers - 1) + peer = peers(r) + + res = get_json(peer + "/api.php?q=send&version=" + version + "&public_key=" + public_key + "&signature=" + sig + "&dst=" + address + "&val=" + FormatNumber(0.00000001, 8).Replace(",", "") + "&date=" + uTime.ToString + "&message=" + als) + If res.ToString = "" Then + MsgBox("Could not send the transaction to the peer (" & peer & ")! Please try again!", vbCritical) + Exit Sub + End If + End If + btnAlias.Visible = False + lblAlias.Text = als + "(Pending)" + Exit Sub +Err: + MsgBox("Something went wrong with setting up the alias. Please try again!", vbCritical) + End Sub End Class diff --git a/LightArionum/lightarionum.snk b/LightArionum/lightarionum.snk new file mode 100644 index 0000000..a4d1d1d Binary files /dev/null and b/LightArionum/lightarionum.snk differ