Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions app/lib/verify-address.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,6 @@ describe('verifyXpub', () => {
expect(verifyXpub(invalid)).toBe(false);
});

test('Testnet Segwit', () => {
const valid = 'tpubDDmYUCp38iSBdNXvGvNuPSpKCRZp8Qs2MNchdr6rAkwA36KjZDkveF5pZ3gU5CJGuYvcuj2CwveKgQDBRJh9vH784hSpvubS9zw2wCoDtzn';
expect(verifyXpub(valid)).toBe(true);
});

test('Testnet P2PKH', () => {
const valid = 'tpubDDCnvgBWxj9Ybh6zg6c1atUtpfFWbqnrEcWWrtXmWSMuqsWrhSzPc73fE7cYiJjVtsY9JE9JBwZyFbdPQ9SqbW6YLymzx5j1WS3wVz4vN46';
expect(verifyXpub(valid)).toBe(true);
});

test('Testnet P2TR', () => {
const valid = 'tpubDCdJV3Q5vPhUmKiSCiS68w43yKZKEZsd8wxa3t8q4DsPjfejaPDT76SDcf6iscyvLnpz4UXFMzVXxZmH5U6XEQfQYGit5NQCH1McwNSHQhq';
expect(verifyXpub(valid)).toBe(true);
});

test('Testnet garbage', () => {
const invalid = 'tpubDCdJV3Q5vPhUmKiSCiS68w43yKZKEZsd8wxa3t8q4DsPjfejaPDT76SDcf6iscyvLnpz4UXFMzVXxZmH5U6XEQfQYGit';
expect(verifyXpub(invalid)).toBe(false);
});

test('ypub', () => {});

test('zpub', () => {});
Expand Down
9 changes: 2 additions & 7 deletions app/lib/verify-address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,8 @@ export function getAllAddresses(wallet: Wallet, i: number): Address[] {
}
}


function getNetwork(wallet: Wallet) {
return (wallet.keys[0].value.startsWith('tpub')) ? bitcoin.networks.testnet : bitcoin.networks.bitcoin;
}

function getSingleSigAddress(wallet: Wallet, account: number, i: number, type: AddressType, bip32: any): string {
const network = getNetwork(wallet);
const network = bitcoin.networks.bitcoin;

const pubkey = toHex(wallet.keys[0], account, i, bip32);

Expand All @@ -74,7 +69,7 @@ function getSingleSigAddress(wallet: Wallet, account: number, i: number, type: A
}

function getMultiSigAddress(wallet: Wallet, account: number, i: number, type: AddressType, bip32: any): string {
const network = getNetwork(wallet);
const network = bitcoin.networks.bitcoin;

var pubkeys = wallet.keys
.map((key) => toHex(key, account, i, bip32))
Expand Down
2 changes: 1 addition & 1 deletion app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function createWindow() {

const contextMenu = Menu.buildFromTemplate([
{ label: 'Open', type: 'normal', click: () => mainWindow.show() },
{ label: 'Help', type: 'normal', click: () => openUrl('https://developer.branta.pro/core') },
{ label: 'Help', type: 'normal', click: () => openUrl('https://developer.branta.pro/branta-core') },
{ label: '', type: 'separator' },
{ label: 'Quit', type: 'normal', click: forceQuit },
{ label: `Version ${packageJson.version}`, type: 'normal', enabled: false }
Expand Down
2 changes: 1 addition & 1 deletion installers/windows/Branta.Wix/Package.wxs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Package Name="Branta"
Manufacturer="Branta LLC"
Version="0.7.0"
Version="0.10.0"
UpgradeCode="4df52912-9d80-4a14-b98b-33a114a4f5ac">
<MajorUpgrade DowngradeErrorMessage="!(loc.DowngradeError)" />

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "branta",
"productName": "Branta",
"version": "0.9.0",
"version": "0.10.0",
"main": "build/app/main.js",
"author": "Branta LLC",
"description": "Verify your bitcoin payments.",
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export class AppComponent {
}

onHelp(): void {
window.electron.openUrl('https://developer.branta.pro/core');
window.electron.openUrl('https://developer.branta.pro/branta-core');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
<div class="title">Derivation Path:</div>
<div class="value">{{ clipboardItem.derivationPath }}</div>
</div>
<div class="unexpected">
<button mat-button color="accent" (click)="onShareFeedback()">Unexpected?</button>
</div>
} @else if (isPaymentClipboardItem(clipboardItem)) {
<div class="item">
<div class="title">Value:</div>
Expand All @@ -50,9 +47,6 @@
<div class="value">{{ clipboardItem.description }}</div>
</div>
}
<div class="unexpected">
<button mat-button color="accent" (click)="onShareFeedback()">Unexpected?</button>
</div>
} @else if (isBolt11ClipboardItem(clipboardItem)) {
<div class="item">
<div class="title">Value:</div>
Expand All @@ -79,4 +73,10 @@
<div class="default">No Bitcoin/Nostr content detected.</div>
}
</div>
@if (clipboardItem && !isPaymentClipboardItem(clipboardItem)) {
<div class="verify-container">
<button mat-button color="primary" (click)="onVerify()">Verify with Branta Guardrail</button>
<mat-icon class="icon material-symbols-outlined" color="primary" [matTooltip]="verifyTooltip">info</mat-icon>
</div>
}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,17 @@
justify-content: center;
color: $text-gray;
}

.unexpected {
display: flex;
flex-direction: row;
justify-content: center;
margin-bottom: -15px;
}
}
}

.value {
word-break: break-all;
}

.verify-container {
display: flex;
flex-direction: row;
align-items: center;
gap: 10px;
padding-top: 10px;
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,56 @@
import { CommonModule } from '@angular/common';
import { Component, Input } from '@angular/core';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { MatButtonModule } from '@angular/material/button';
import { ExpandableTextComponent } from '../../../shared/components/expandable-text/expandable-text.component';
import { ClipboardItem } from '../../../shared/models/clipboard-item';
import { ClipboardItem, PaymentClipboardItem } from '../../../shared/models/clipboard-item';
import { BaseClipboardComponent } from '../base-clipboard';
import { BitcoinAmountComponent } from '../../../shared/components/bitcoin-amount/bitcoin-amount.component';
import { MatIconModule } from '@angular/material/icon';
import { MatTooltipModule } from '@angular/material/tooltip';
import { lastValueFrom } from 'rxjs';
import { ServerService } from '../../../shared/services/server.service';
import { ToastrService } from 'ngx-toastr';

@Component({
selector: 'app-clipboard-details',
imports: [CommonModule, MatButtonModule, ExpandableTextComponent, BitcoinAmountComponent],
imports: [CommonModule, MatButtonModule, ExpandableTextComponent, BitcoinAmountComponent, MatIconModule, MatTooltipModule],
templateUrl: './clipboard-details.component.html',
styleUrl: './clipboard-details.component.scss'
})
export class ClipboardDetailsComponent extends BaseClipboardComponent {
@Input() clipboardItem: ClipboardItem | null;
@Output() clipboardItemChange = new EventEmitter<ClipboardItem>();

onShareFeedback(): void {
window.electron.openUrl('https://branta.pro');
verifyTooltip = "Verify clipboard content against Branta's server.";

constructor(private serverService: ServerService, private toastrService: ToastrService) {
super();
}

onVerify(): void {
(async () => {
var result = await this.queryPayments(this.clipboardItem?.value ?? "")

if (result) {
this.clipboardItemChange.emit(result as PaymentClipboardItem);
} else {
this.toastrService.error(`Payment not found.`);
}
})();
}

private async queryPayments(value: string): Promise<PaymentClipboardItem | null> {
try {
const paymentClipboardItems = await lastValueFrom(this.serverService.getPayment(value));

const paymentClipboardItem = paymentClipboardItems[0];

paymentClipboardItem.name = paymentClipboardItem.platform;
paymentClipboardItem.value = value;

return paymentClipboardItem;
} catch (error) {
return null;
}
}
}
2 changes: 1 addition & 1 deletion src/app/features/clipboard/clipboard.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="container">
<app-clipboard-details [clipboardItem]="clipboardItem"></app-clipboard-details>
<app-clipboard-details [(clipboardItem)]="clipboardItem"></app-clipboard-details>
@if (showHistory) {
<app-clipboard-history [history]="history" [clipboardContent]="clipboardItem?.value"></app-clipboard-history>
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/clipboard/clipboard.component.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
:host {
height: 100%;
width: 100%;
max-width: 640px;
max-width: 900px;
display: flex;
}

Expand Down
5 changes: 1 addition & 4 deletions src/app/features/settings/settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
<div class="settings">
<div class="section">
<div class="title">General</div>
<div class="option">
<mat-slide-toggle formControlName="checkoutMode">Checkout Mode</mat-slide-toggle>
<mat-icon class="icon material-symbols-outlined" [matTooltip]="checkoutModeTooltip" matTooltipPosition="right">help</mat-icon>
</div>
<div class="option">
<mat-form-field>
<mat-label>Bitcoin Unit</mat-label>
Expand Down Expand Up @@ -54,6 +50,7 @@
<button mat-button color="warn" (click)="onClearHistory()">Clear History</button>
</div>
<div class="section">
<div class="title">Extras</div>
<div class="option">
<mat-slide-toggle formControlName="developerMode">Developer Mode</mat-slide-toggle>
<mat-icon class="icon material-symbols-outlined" [matTooltip]="developerModeTooltip" matTooltipPosition="right">help</mat-icon>
Expand Down
4 changes: 3 additions & 1 deletion src/app/features/settings/settings.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:host {
height: 100%;
width: 100%;
max-width: 600px;
max-width: 900px;
display: flex;
}

Expand All @@ -29,6 +29,8 @@
.title {
font-size: 18px;
margin-bottom: 15px;
padding-bottom: 5px;
border-bottom: 1px solid $border-color;
}

.option {
Expand Down
43 changes: 0 additions & 43 deletions src/app/features/settings/settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@ import { SettingsService } from '../../shared/services/settings.service';
export class SettingsComponent {
formGroup: FormGroup;

checkoutModeTooltip = 'Verify addresses by querying Branta with clipboard content. Requires internet.';
developerModeTooltip = "Only check this if you're a developer. Enables staging environment.";

BitcoinUnitTypes = Object.values(BitcoinUnitType);

ClipboardHistoryRolloffTypes = Object.values(ClipboardHistoryRolloffType);

private isCheckoutModeChange = false;

constructor(
private settingsService: SettingsService,
private historyService: HistoryService,
Expand All @@ -40,7 +37,6 @@ export class SettingsComponent {
const settings = settingsService.settings();

this.formGroup = new FormGroup({
checkoutMode: new FormControl(settings.checkoutMode),
bitcoinUnitType: new FormControl(settings.bitcoinUnitType),
generalNotifications: new FormGroup({
bitcoinAddress: new FormControl(settings.generalNotifications.bitcoinAddress),
Expand All @@ -56,19 +52,6 @@ export class SettingsComponent {
developerMode: new FormControl(settings.developerMode)
});

this.formGroup.valueChanges.subscribe((settings) => {
if (!this.isCheckoutModeChange) {
this.settingsService.save(settings);
}

this.isCheckoutModeChange = false;
});

this.formGroup.get('checkoutMode')?.valueChanges.subscribe((value) => {
this.handleCheckoutModeChange(value);
this.clipboardService.rerunGetClipboardItem();
});

this.formGroup.get('developerMode')?.valueChanges.subscribe(() => {
this.clipboardService.rerunGetClipboardItem();
});
Expand All @@ -89,30 +72,4 @@ export class SettingsComponent {
}
});
}

private handleCheckoutModeChange(newValue: boolean): void {
if (!newValue) {
this.settingsService.save(this.formGroup.value);
return;
}

this.isCheckoutModeChange = true;

const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
data: {
title: 'Turn Checkout Mode on?',
message: 'Are you sure you want to turn Checkout Mode on? This will query Branta with bitcoin addresses you copy.',
submitText: 'Confirm'
}
});

dialogRef.afterClosed().subscribe((confirmed) => {
if (confirmed) {
this.settingsService.save(this.formGroup.value);
this.clipboardService.rerunGetClipboardItem();
} else {
this.formGroup.get('checkoutMode')?.setValue(false, { emitEvent: false });
}
});
}
}
2 changes: 1 addition & 1 deletion src/app/features/vaults/vaults.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:host {
height: 100%;
width: 100%;
max-width: 600px;
max-width: 900px;
display: flex;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:host {
height: 100%;
width: 100%;
max-width: 600px;
max-width: 900px;
display: flex;
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/features/wallets/wallets.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
:host {
height: 100%;
width: 100%;
max-width: 600px;
max-width: 900px;
display: flex;
}

Expand Down
1 change: 0 additions & 1 deletion src/app/shared/models/settings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export interface Settings {
checkoutMode: boolean;
developerMode: boolean;
generalNotifications: GeneralNotifications;
clipboardHistory: ClipboardHistory;
Expand Down
Loading
Loading