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
4 changes: 2 additions & 2 deletions .github/workflows/apidocs-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
# This follows semver recommendations, with release candidates having a dash and a dot
# @see https://semver.org/spec/v2.0.0-rc.2.html
check-version:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
outputs:
release_status_output: ${{ steps.release_version.outputs.version_status_output }}

Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:

# Initiate upload only if the version is valid
upload-apidocs:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
permissions:
id-token: write # This is required for requesting the JWT
needs: check-version
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/apidocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- release
jobs:
lint:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
timeout-minutes: 10

strategy:
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,23 @@ jobs:
username: ${{ secrets.AWS_ACCESS_KEY_ID }}
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Build and push
# https://github.com/docker/build-push-action/releases/tag/v6.7.0
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85
# https://github.com/docker/build-push-action/releases/tag/v6.15.0
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4
with:
push: true
tags: ${{ steps.tags.outputs.tags }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push RabbitMQ image
# https://github.com/docker/build-push-action/releases/tag/v6.15.0
uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4
if: steps.tags.outputs.rabbitmq_tags != ''
with:
build-args:
ENABLE_RABBITMQ=true
push: true
tags: ${{ steps.tags.outputs.rabbitmq_tags }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
4 changes: 2 additions & 2 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ env:

jobs:
itest:
runs-on: ubuntu-20.04
timeout-minutes: 40
runs-on: ubuntu-latest
timeout-minutes: 80

strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:

jobs:
test:
runs-on: "ubuntu-latest"
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
- release
jobs:
test:
runs-on: "ubuntu-latest"
runs-on: ubuntu-latest
timeout-minutes: 40 # default is 360
strategy:
matrix:
Expand Down
14 changes: 10 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG IMG=node:22.11-alpine3.19

FROM $IMG as builder
FROM $IMG AS builder

WORKDIR /usr/src/app/

Expand All @@ -17,7 +17,7 @@ COPY config.js.docker ./src/config.js

RUN npm run build && npm run build-scripts

FROM $IMG as deps
FROM $IMG AS deps

WORKDIR /usr/src/app/
ENV NODE_ENV=production
Expand All @@ -27,8 +27,14 @@ ENV NODE_ENV=production

COPY package.json package-lock.json ./
RUN apk add --no-cache --virtual .gyp python3 make g++ &&\
npm ci --only=production &&\
apk del .gyp &&\
npm ci --only=production

# Install amqp library if RabbitMQ is enabled
ARG ENABLE_RABBITMQ=false
ENV ENABLE_RABBITMQ=${ENABLE_RABBITMQ}
RUN if [ "$ENABLE_RABBITMQ" = "true" ]; then npm install amqplib@0.10.5; fi

RUN apk del .gyp &&\
npm cache clean --force &&\
rm -rf /tmp/* /var/cache/apk/*

Expand Down
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ else
node dist-scripts/get_xpub_from_seed.js $(seed)
endif

# Internal target to run multisig_xpub_from_seed command.
.PHONY: .run_multisig_xpub_from_seed
.run_multisig_xpub_from_seed:
ifeq ($(seed),)
@echo "Usage: make multisig_xpub_from_seed seed=YOUR_SEED"
else
node dist-scripts/get_multisig_xpub_from_seed.js $(seed)
endif

# Command: generate words
.PHONY: words
words: .script-build-dirs .run_words .script-clean-dirs
Expand All @@ -76,3 +85,7 @@ create_hsm_key: .script-build-dirs .run_create_hsm_key .script-clean-dirs
# Command: Derive xPub from seed
.PHONY: xpub_from_seed
xpub_from_seed: .script-build-dirs .run_xpub_from_seed .script-clean-dirs

# Command: Derive multisig xPub from seed
.PHONY: multisig_xpub_from_seed
multisig_xpub_from_seed: .script-build-dirs .run_multisig_xpub_from_seed .script-clean-dirs
2 changes: 2 additions & 0 deletions __tests__/__fixtures__/http-fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,7 @@ export default {
address: 'WewDeXWyvHP7jJTs7tjLoQfoB72LLxJQqN',
timelock: null,
value: 6400,
token_data: 0,
},
token: '00',
spent_by: null,
Expand All @@ -1052,6 +1053,7 @@ export default {
address: 'wgyUgNjqZ18uYr4YfE2ALW6tP5hd8MumH5',
timelock: null,
value: 6400,
token_data: 0,
},
token: '00',
spent_by: null,
Expand Down
1 change: 1 addition & 0 deletions __tests__/__fixtures__/settings-fixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const defaultConfig = {
tokenUid: '',
gapLimit: null,
confirmFirstAddress: null,
history_sync_mode: 'polling_http_api',
};

let config = cloneDeep(defaultConfig);
Expand Down
1 change: 1 addition & 0 deletions __tests__/decode.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ describe('decode api', () => {
type: 'MultiSig',
timelock: null,
value: 6400,
token_data: 0,
},
script: expect.any(String),
token: '00',
Expand Down
15 changes: 9 additions & 6 deletions __tests__/history-sync.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@ describe('history sync', () => {
});

afterEach(async () => {
await TestUtils.stopWallet({ walletId });
await TestUtils.stopWallet({ walletId, pollInterval: 2000 });
});

it('should start a wallet with default http polling if not configured', async () => {
it('should start a wallet with default xpub streaming if not configured', async () => {
const config = settings._getDefaultConfig();
delete config.history_sync_mode;
settings._setConfig(config);
const response = await TestUtils.request
.post('/start')
.send({ seedKey: TestUtils.seedKey, 'wallet-id': walletId });
expect(response.status).toBe(200);
expect(response.body.success).toBe(true);
const wallet = initializedWallets.get(walletId);
expect(wallet.historySyncMode).toEqual(hathorLib.HistorySyncMode.POLLING_HTTP_API);
expect(wallet.historySyncMode).toEqual(hathorLib.HistorySyncMode.XPUB_STREAM_WS);
});

it('should start a wallet with configured history sync', async () => {
Expand All @@ -40,18 +43,18 @@ describe('history sync', () => {

it('should use the history sync from the request when provided', async () => {
const config = settings._getDefaultConfig();
config.history_sync_mode = 'manual_stream_ws';
config.history_sync_mode = 'polling_http_api';
settings._setConfig(config);
const response = await TestUtils.request
.post('/start')
.send({
seedKey: TestUtils.seedKey,
'wallet-id': walletId,
history_sync_mode: 'xpub_stream_ws',
history_sync_mode: 'manual_stream_ws',
});
expect(response.status).toBe(200);
expect(response.body.success).toBe(true);
const wallet = initializedWallets.get(walletId);
expect(wallet.historySyncMode).toEqual(hathorLib.HistorySyncMode.XPUB_STREAM_WS);
expect(wallet.historySyncMode).toEqual(hathorLib.HistorySyncMode.MANUAL_STREAM_WS);
});
});
Loading
Loading