# AirWallet's installer for Windows, in PowerShell: # # irm https://airwallet.tech/install | iex # irm https://airwallet.tech/install-offline | iex (AirWallet Offline, the hardened build) # # (Mac and Linux: curl -fsSL https://airwallet.tech/install | sh -- the same address, its shell script.) # It takes the newest release from airwallet.tech/download, checks it against the release's checksum list -- signed # with AirWallet's release key, written into this script below (the key VERIFY.txt names) -- and puts it in place: # the app in your user's Programs folder (%LOCALAPPDATA%\Programs), a Start menu entry, then starts it. A browser marks # what it downloads as "from the internet", and Windows' SmartScreen stops an app with that mark that isn't signed # yet; this download has no mark, so nothing is asked. The checks catch a damaged or swapped file on the download # server. They can't vouch for this script, which comes from the same place: read it first if you like # (irm https://airwallet.tech/install). # Written for Windows PowerShell 5.1 (what every Windows 10 and 11 has) as well as PowerShell 7. & { $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' # (PowerShell 5.1 downloads crawl while it draws a progress bar) $Base = 'https://airwallet.tech/download' if ($env:AIRWALLET_BASE) { $Base = $env:AIRWALLET_BASE } $Key = 'airwallet-release namespaces="airwallet-release" ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIusKIKFk8gLDQgFNpxjjo7BRsy05sG11P42Dl0UGP8Y' $Fpr = 'SHA256:SV031wxY3OKk8aYTY4a6b7UYa80onuXiDi0tFobgOFE' $offline = $false # (install-offline.ps1: $true -- stage.py) $isWin = $env:OS -eq 'Windows_NT' $tmp = $null try { if (-not $isWin -and -not $env:AIRWALLET_TEST) { throw 'this is the Windows installer. Mac and Linux: curl -fsSL https://airwallet.tech/install | sh' } [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 $ssh = Get-Command ssh-keygen -ErrorAction SilentlyContinue if (-not $ssh) { throw "it needs ssh-keygen to check the release's signature: Settings > System > Optional features > Add a feature > OpenSSH Client." } $app = 'AirWallet' if ($offline) { $app = 'AirWallet Offline' } $pat = 'AirWallet-Windows-*.exe' if ($offline) { $pat = 'AirWallet-Offline-Windows-*.exe' } $tmp = Join-Path ([IO.Path]::GetTempPath()) ('airwallet-' + [guid]::NewGuid().ToString('N')) New-Item -ItemType Directory -Path $tmp | Out-Null $list = Join-Path $tmp 'SHA256SUMS.txt' $sig = Join-Path $tmp 'SHA256SUMS.txt.sig' $keyFile = Join-Path $tmp 'key' # the release's list, signed with the key above: anything else stops here, nothing installed Write-Host 'Checking the newest AirWallet release...' Invoke-WebRequest -UseBasicParsing -Uri "$Base/SHA256SUMS.txt" -OutFile $list Invoke-WebRequest -UseBasicParsing -Uri "$Base/SHA256SUMS.txt.sig" -OutFile $sig [IO.File]::WriteAllText($keyFile, $Key + "`n") # (no byte-order mark: ssh-keygen reads it as it is) # (the list given to ssh-keygen byte for byte: a PowerShell pipe, or Start-Process -RedirectStandardInput, re-reads # it as text -- and the signature wouldn't match) $psi = New-Object System.Diagnostics.ProcessStartInfo $psi.FileName = $ssh.Source $psi.Arguments = '-Y verify -f "' + $keyFile + '" -I airwallet-release -n airwallet-release -s "' + $sig + '"' $psi.UseShellExecute = $false $psi.RedirectStandardInput = $true $psi.RedirectStandardOutput = $true $psi.RedirectStandardError = $true $v = [Diagnostics.Process]::Start($psi) $bytes = [IO.File]::ReadAllBytes($list) $v.StandardInput.BaseStream.Write($bytes, 0, $bytes.Length) $v.StandardInput.Close() $null = $v.StandardOutput.ReadToEnd() $null = $v.StandardError.ReadToEnd() $v.WaitForExit() if ($v.ExitCode -ne 0) { throw "the release's checksum list isn't signed with AirWallet's release key ($Fpr). Stopped: nothing was installed." } $file = $null $want = $null foreach ($line in [IO.File]::ReadAllLines($list)) { $parts = $line.Trim() -split '\s+', 2 if ($parts.Count -eq 2) { $n = $parts[1].TrimStart('*') if ($n -like $pat) { $file = $n; $want = $parts[0].ToLower() } } } if (-not $file) { throw "this release has no $pat." } $got = Join-Path $tmp $file Write-Host "Downloading $file..." Invoke-WebRequest -UseBasicParsing -Uri "$Base/$file" -OutFile $got if ((Get-FileHash -Algorithm SHA256 -Path $got).Hash.ToLower() -ne $want) { throw "$file doesn't match the signed list (a damaged or swapped download). Stopped: nothing was installed." } Write-Host "Checked: it's the signed release." $dest = $env:AIRWALLET_DEST if (-not $dest) { $dest = Join-Path (Join-Path $env:LOCALAPPDATA 'Programs') $app } New-Item -ItemType Directory -Force -Path $dest | Out-Null $exe = Join-Path $dest "$app.exe" if (Get-Process -ErrorAction SilentlyContinue | Where-Object { $_.Path -eq $exe }) { throw "$app is open: quit it, then run this again. Your wallets stay where they are." } Copy-Item -Force -Path $got -Destination $exe if ($isWin) { Unblock-File -Path $exe # (no mark from this download: to be sure) $menu = Join-Path $env:APPDATA 'Microsoft\Windows\Start Menu\Programs' $lnk = (New-Object -ComObject WScript.Shell).CreateShortcut((Join-Path $menu "$app.lnk")) $lnk.TargetPath = $exe $lnk.WorkingDirectory = $dest $lnk.Description = 'Wallet for Bitcoin, Ethereum, Solana, Monero and Zcash' $lnk.Save() } Write-Host "Done: $app is in $dest, and in the Start menu." -ForegroundColor Green if ($isWin -and -not $env:AIRWALLET_NO_OPEN) { Start-Process -FilePath $exe -WorkingDirectory $dest } } catch { Write-Host ('AirWallet installer: ' + $_.Exception.Message) -ForegroundColor Red } finally { if ($tmp -and (Test-Path $tmp)) { Remove-Item -Recurse -Force -Path $tmp -ErrorAction SilentlyContinue } } }