Skip to content

Commit 20f121e

Browse files
committed
Merge branch 'staging-send-to-self-dropdown-merged' into staging-send-to-self-dropdown
2 parents f0dce1b + 3b0ad56 commit 20f121e

File tree

340 files changed

+3421
-1768
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

340 files changed

+3421
-1768
lines changed

.containerversion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
33
1+
34

.github/workflows/ci.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ jobs:
239239
- name: Build Windows app
240240
run: |
241241
make qt-windows
242-
cd frontends/qt
243-
makensis setup.nsi
244242
- name: Upload Installer
245243
id: upload
246244
uses: actions/upload-artifact@v4

.github/workflows/playwright.yml

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,66 @@ on:
1010
workflow_dispatch:
1111

1212
jobs:
13+
compute-version:
14+
name: Compute firmware container version
15+
runs-on: ubuntu-latest
16+
outputs:
17+
firmware_version: ${{ steps.get_version.outputs.firmware_version }}
18+
steps:
19+
- name: Checkout firmware repo
20+
uses: actions/checkout@v4
21+
with:
22+
repository: BitBoxSwiss/bitbox02-firmware
23+
path: bitbox02-firmware
24+
25+
- name: Read .containerversion
26+
id: get_version
27+
run: |
28+
version=$(cat bitbox02-firmware/.containerversion)
29+
echo "Firmware version: $version"
30+
echo "firmware_version=$version" >> $GITHUB_OUTPUT
31+
32+
build-simulator:
33+
name: Build simulator in container
34+
runs-on: ubuntu-latest
35+
needs: compute-version
36+
container:
37+
image: shiftcrypto/firmware_v2:${{ needs.compute-version.outputs.firmware_version }}
38+
steps:
39+
- name: Checkout firmware repo
40+
uses: actions/checkout@v4
41+
with:
42+
repository: BitBoxSwiss/bitbox02-firmware
43+
submodules: true
44+
path: bitbox02-firmware
45+
46+
- name: Fetch tags
47+
working-directory: bitbox02-firmware
48+
run: git fetch --tags
49+
50+
- name: Build simulator
51+
working-directory: bitbox02-firmware
52+
run: make simulator
53+
54+
- name: Upload simulator binary
55+
uses: actions/upload-artifact@v4
56+
with:
57+
name: simulator-binary
58+
path: bitbox02-firmware/build-build-noasan/bin/simulator
59+
1360
run-tests:
1461
runs-on: ubuntu-latest
62+
needs: build-simulator
1563
steps:
1664
- uses: actions/checkout@v3
1765

66+
- name: Download simulator artifact
67+
uses: actions/download-artifact@v4
68+
with:
69+
name: simulator-binary
70+
path: ./simulator-bin
71+
72+
1873
- name: Setup Node.js
1974
uses: actions/setup-node@v3
2075
with:
@@ -28,13 +83,19 @@ jobs:
2883
- name: Install Playwright browsers
2984
run: |
3085
cd frontends/web
31-
npx playwright install --with-deps
86+
npx playwright install --with-deps chromium webkit
87+
88+
89+
- name: Restore executable permission
90+
run: chmod +x simulator-bin/simulator
3291

3392
- name: Run Playwright tests
93+
env:
94+
SIMULATOR_PATH: ${{ github.workspace }}/simulator-bin/simulator
3495
run: make webe2etest
3596

3697
- name: Upload Playwright artifacts
37-
if: failure()
98+
if: always()
3899
uses: actions/upload-artifact@v4
39100
with:
40101
name: playwright-artifacts

APP_VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4.49.0

CHANGELOG.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Changelog
22

33
## Unreleased
4+
- Add a dropdown on the "Receiver address" input in the send screen to select an account
5+
6+
## v4.49.0
47
- macOS: fix potential USB communication issue with BitBox02 bootloaders <v1.1.2 and firmwares <v9.23.1
58
- Added BTC Direct sell option
69
- Added a banner to remind user to backup their seed phrase when an account reaches a certain threshold.
@@ -21,19 +24,23 @@
2124
- More efficient account initialization by fetching all account Bitcoin xpubs at once
2225
- Enable search transactions by note, address, or txid
2326
- Move "Export" (export transactions) to account info page
24-
- Add a dropdown on the "Receiver address" input in the send screen to select an account
27+
- Show coinfinty logo when requesting an address
28+
- Update decimal formatting for stablecoin transactions
29+
- Change block explorer to mempool.space
30+
- Integrate Bitrefill and add spending section
31+
32+
## v4.48.8
33+
- Bundle BitBox02 Nova firmware version v9.23.3
2534

2635
## v4.48.7
2736
- ios: fix Pocket user verification button
28-
- Change block explorer to mempool.space
2937

3038
## v4.48.6
3139
- Android: restore support for Android 6 and Android 5
3240

3341
## v4.48.5
3442
- Bundle BitBox02 firmware version v9.23.2
3543
- iOS: fix wrong timezone when confirming time on BitBox02 (it would always show the time in UTC)
36-
- Integrate Bitrefill and add spending section
3744

3845
## v4.48.4
3946
- macOS: fix potential USB communication issue with BitBox02 bootloaders <v1.1.2 and firmwares <v9.23.1

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ RUN --mount=target=/mnt,source=scripts DEBIAN_FRONTEND=noninteractive /mnt/docke
2424
ARG SYS_GOPATH=/opt/go
2525
ENV PATH=${SYS_GOPATH}/bin:/usr/local/go/bin:$PATH
2626

27-
RUN --mount=target=/mnt/Makefile,source=Makefile GOPATH=${SYS_GOPATH} make -C /mnt envinit
27+
RUN --mount=target=/mnt/Makefile,source=Makefile --mount=target=/mnt/version.mk.inc,source=version.mk.inc GOPATH=${SYS_GOPATH} make -C /mnt envinit
2828

2929
ENV PATH=/opt/qt6/6.8.2/gcc_64/bin:/opt/qt6/6.8.2/gcc_64/libexec:$PATH
3030

Makefile

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
SHELL := /bin/bash
1616
WEBROOT := frontends/web
1717

18+
include version.mk.inc
19+
20+
GO_LDFLAGS := $(GO_VERSION_LDFLAGS)
21+
GO_RUN := go run -mod=vendor -ldflags "$(GO_LDFLAGS)"
22+
1823
catch:
1924
@echo "Choose a make target."
2025
envinit:
@@ -28,15 +33,17 @@ gomobileinit:
2833
git clone https://github.com/BitBoxSwiss/mobile.git /tmp/mobile && cd /tmp/mobile/cmd/gomobile && go install .
2934
gomobile init
3035
servewallet:
31-
go run -mod=vendor ./cmd/servewallet
36+
$(GO_RUN) ./cmd/servewallet
3237
servewallet-mainnet:
33-
go run -mod=vendor ./cmd/servewallet -mainnet
38+
$(GO_RUN) ./cmd/servewallet -mainnet
3439
servewallet-regtest:
35-
rm -f appfolder.dev/cache/headers-rbtc.bin && rm -rf appfolder.dev/cache/account-*rbtc* && go run -mod=vendor ./cmd/servewallet -regtest
40+
rm -f appfolder.dev/cache/headers-rbtc.bin && rm -rf appfolder.dev/cache/account-*rbtc* && $(GO_RUN) ./cmd/servewallet -regtest
3641
servewallet-prodservers:
37-
go run -mod=vendor ./cmd/servewallet -devservers=false
42+
$(GO_RUN) ./cmd/servewallet -devservers=false
3843
servewallet-mainnet-prodservers:
39-
go run -mod=vendor ./cmd/servewallet -mainnet -devservers=false
44+
$(GO_RUN) ./cmd/servewallet -mainnet -devservers=false
45+
servewallet-simulator:
46+
$(GO_RUN) ./cmd/servewallet -simulator=true
4047
buildweb:
4148
node --version
4249
npm --version

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,27 @@ Run `make servewallet` and `make webdev` in seperate terminals.
8484
Before the first use of `make webdev`, you also need to run `make buildweb`, to install the dev
8585
dependencies.
8686

87+
#### Local development with BB02 simulator
88+
89+
The app can be used together with a [BB02 simulator](https://github.com/BitBoxSwiss/bitbox02-firmware/tree/master/test/simulator).
90+
91+
In order to do so:
92+
93+
* Build the simulator (checkout https://github.com/BitBoxSwiss/bitbox02-firmware/, then from the root repo run `make dockerdev` followed by `make simulator`)
94+
95+
* Execute the simulator.
96+
97+
* Use `--port` if you want it to listen to a custom port (default is 15423)
98+
99+
* Set the environment variable `FAKE_MEMORY_FILEPATH` to a filepath if you want the simulator to write to file rather than in memory. This allows to re-use the same seed across different executions.
100+
101+
* Launch the BBApp in simulator mode by providing a custom flag `--simulator`.
102+
103+
104+
If the simulator is listening on a custom port, `--simulatorPort=<port>` must also be provided.
105+
106+
Note: the simulator is currently only supported in the servewallet and in the Qt app and only when the app runs in testnet mode.
107+
87108
#### Watch and build the UI
88109

89110
Run `make webdev` to develop the UI inside a web browser (for quick development, automatic rebuilds

backend/accounts.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,20 +1722,23 @@ func (backend *Backend) checkAccountUsed(account accounts.Interface) {
17221722
return
17231723
}
17241724
}
1725+
17251726
log := backend.log.WithField("accountCode", account.Config().Config.Code)
1726-
txs, err := account.Transactions()
1727-
if err != nil {
1728-
log.WithError(err).Error("discoverAccount")
1729-
return
1730-
}
1727+
if !account.Config().Config.Used {
1728+
txs, err := account.Transactions()
1729+
if err != nil {
1730+
log.WithError(err).Error("discoverAccount")
1731+
return
1732+
}
17311733

1732-
if len(txs) == 0 {
1733-
// Invoke this here too because even if an account is unused, we scan up to 5 accounts.
1734-
backend.maybeAddHiddenUnusedAccounts()
1735-
return
1734+
if len(txs) == 0 {
1735+
// Invoke this here too because even if an account is unused, we scan up to 5 accounts.
1736+
backend.maybeAddHiddenUnusedAccounts()
1737+
return
1738+
}
17361739
}
17371740
log.Info("marking account as used")
1738-
err = backend.config.ModifyAccountsConfig(func(accountsConfig *config.AccountsConfig) error {
1741+
err := backend.config.ModifyAccountsConfig(func(accountsConfig *config.AccountsConfig) error {
17391742
acct := accountsConfig.Lookup(account.Config().Config.Code)
17401743
if acct == nil {
17411744
return errp.Newf("could not find account")

backend/accounts_test.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"time"
2323

2424
"github.com/BitBoxSwiss/bitbox-wallet-app/backend/accounts"
25+
accountsMocks "github.com/BitBoxSwiss/bitbox-wallet-app/backend/accounts/mocks"
2526
accountsTypes "github.com/BitBoxSwiss/bitbox-wallet-app/backend/accounts/types"
2627
"github.com/BitBoxSwiss/bitbox-wallet-app/backend/coins/btc"
2728
"github.com/BitBoxSwiss/bitbox-wallet-app/backend/coins/btc/addresses"
@@ -1676,3 +1677,60 @@ func TestAccountsFiatAndCoinBalance(t *testing.T) {
16761677
}
16771678

16781679
}
1680+
1681+
func TestCheckAccountUsed(t *testing.T) {
1682+
b := newBackend(t, testnetDisabled, regtestDisabled)
1683+
b.tstCheckAccountUsed = nil
1684+
defer b.Close()
1685+
accountMocks := map[accountsTypes.Code]*accountsMocks.InterfaceMock{}
1686+
// A Transactions function that always returns one transaction, so the account is always used.
1687+
txFunc := func() (accounts.OrderedTransactions, error) {
1688+
return accounts.OrderedTransactions{&accounts.TransactionData{}}, nil
1689+
}
1690+
1691+
b.makeBtcAccount = func(config *accounts.AccountConfig, coin *btc.Coin, gapLimits *types.GapLimits, getAddress func(coinpkg.Code, blockchain.ScriptHashHex) (*addresses.AccountAddress, error), log *logrus.Entry) accounts.Interface {
1692+
accountMock := MockBtcAccount(t, config, coin, gapLimits, log)
1693+
accountMock.TransactionsFunc = txFunc
1694+
accountMocks[config.Config.Code] = accountMock
1695+
return accountMock
1696+
}
1697+
1698+
b.makeEthAccount = func(config *accounts.AccountConfig, coin *eth.Coin, httpClient *http.Client, log *logrus.Entry) accounts.Interface {
1699+
accountMock := MockEthAccount(config, coin, httpClient, log)
1700+
accountMock.TransactionsFunc = txFunc
1701+
accountMocks[config.Config.Code] = accountMock
1702+
return accountMock
1703+
}
1704+
1705+
ks1 := makeBitBox02Multi()
1706+
1707+
ks1Fingerprint, err := ks1.RootFingerprint()
1708+
require.NoError(t, err)
1709+
1710+
b.registerKeystore(ks1)
1711+
require.NoError(t, b.SetWatchonly(ks1Fingerprint, true))
1712+
1713+
accountsByKestore, err := b.AccountsByKeystore()
1714+
require.NoError(t, err)
1715+
1716+
accountList, ok := accountsByKestore[hex.EncodeToString(ks1Fingerprint)]
1717+
require.True(t, ok, "Expected accounts for keystore with fingerprint %s", hex.EncodeToString(ks1Fingerprint))
1718+
1719+
// Check all accounts, make sure they are set as used.
1720+
for _, acct := range accountList {
1721+
mock, ok := accountMocks[acct.Config().Config.Code]
1722+
require.True(t, ok, "No mock for account %s", acct.Config().Config.Code)
1723+
1724+
b.checkAccountUsed(acct)
1725+
// Ensure that Transactions is called
1726+
require.Len(t, mock.TransactionsCalls(), 1)
1727+
require.True(t, acct.Config().Config.Used)
1728+
1729+
// Call checkAccountUsed again, Transactions should not be called again.
1730+
b.checkAccountUsed(acct)
1731+
require.Len(t, mock.TransactionsCalls(), 1)
1732+
// And Used should still be true.
1733+
require.True(t, acct.Config().Config.Used)
1734+
}
1735+
1736+
}

0 commit comments

Comments
 (0)