Skip to content

Commit e08294c

Browse files
committed
2 parents 30158d2 + 6a5aa32 commit e08294c

File tree

870 files changed

+24788
-5616
lines changed

Some content is hidden

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

870 files changed

+24788
-5616
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
git checkout -b ${{ env.preid }}-$(git rev-parse --short HEAD)
4747
echo "email=${{ secrets.BETA_EMAIL }}" > .npmrc
4848
echo "@bitgo-beta:registry=https://registry.npmjs.org" >> .npmrc
49-
echo "//registry.npmjs.org/:_authToken=${{ secrets.BETA_TOKEN }}" >> .npmrc
49+
echo "//registry.npmjs.org/:_authToken=${{ secrets.BITGO_BETA_PUBLISH_TOKEN }}" >> .npmrc
5050
echo "//registry.npmjs.org/:always-auth=true" >> .npmrc
5151
5252
- name: Prepare Release

CLAUDE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ yarn compile-dbg
7070
### Commits
7171
BitGoJS uses conventional commits. All commits MUST pass the spec described in `commitlint.config.js`.
7272

73+
### TypeScript Guidelines
74+
- **Avoid `any` type**: Use specific types, interfaces, or union types instead of `any`. If absolutely necessary, prefer `unknown` and use type guards for safety.
75+
7376
## Code Architecture
7477

7578
BitGoJS is a monorepo composed of multiple modules, each implementing specific functionality:

Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ COPY --from=builder /tmp/bitgo/modules/abstract-utxo /var/modules/abstract-utxo/
5555
COPY --from=builder /tmp/bitgo/modules/blockapis /var/modules/blockapis/
5656
COPY --from=builder /tmp/bitgo/modules/sdk-api /var/modules/sdk-api/
5757
COPY --from=builder /tmp/bitgo/modules/sdk-hmac /var/modules/sdk-hmac/
58+
COPY --from=builder /tmp/bitgo/modules/utxo-ord /var/modules/utxo-ord/
5859
COPY --from=builder /tmp/bitgo/modules/account-lib /var/modules/account-lib/
5960
COPY --from=builder /tmp/bitgo/modules/sdk-coin-ada /var/modules/sdk-coin-ada/
6061
COPY --from=builder /tmp/bitgo/modules/sdk-coin-algo /var/modules/sdk-coin-algo/
@@ -122,13 +123,13 @@ COPY --from=builder /tmp/bitgo/modules/sdk-coin-bch /var/modules/sdk-coin-bch/
122123
COPY --from=builder /tmp/bitgo/modules/sdk-coin-bcha /var/modules/sdk-coin-bcha/
123124
COPY --from=builder /tmp/bitgo/modules/sdk-coin-bsv /var/modules/sdk-coin-bsv/
124125
COPY --from=builder /tmp/bitgo/modules/sdk-coin-btc /var/modules/sdk-coin-btc/
125-
COPY --from=builder /tmp/bitgo/modules/utxo-ord /var/modules/utxo-ord/
126126
COPY --from=builder /tmp/bitgo/modules/sdk-coin-btg /var/modules/sdk-coin-btg/
127127
COPY --from=builder /tmp/bitgo/modules/sdk-coin-dash /var/modules/sdk-coin-dash/
128128
COPY --from=builder /tmp/bitgo/modules/sdk-coin-doge /var/modules/sdk-coin-doge/
129129
COPY --from=builder /tmp/bitgo/modules/sdk-coin-eos /var/modules/sdk-coin-eos/
130130
COPY --from=builder /tmp/bitgo/modules/sdk-coin-ethlike /var/modules/sdk-coin-ethlike/
131131
COPY --from=builder /tmp/bitgo/modules/sdk-coin-ethw /var/modules/sdk-coin-ethw/
132+
COPY --from=builder /tmp/bitgo/modules/sdk-coin-flrp /var/modules/sdk-coin-flrp/
132133
COPY --from=builder /tmp/bitgo/modules/sdk-coin-iota /var/modules/sdk-coin-iota/
133134
COPY --from=builder /tmp/bitgo/modules/sdk-coin-lnbtc /var/modules/sdk-coin-lnbtc/
134135
COPY --from=builder /tmp/bitgo/modules/sdk-coin-ltc /var/modules/sdk-coin-ltc/
@@ -152,6 +153,7 @@ cd /var/modules/abstract-utxo && yarn link && \
152153
cd /var/modules/blockapis && yarn link && \
153154
cd /var/modules/sdk-api && yarn link && \
154155
cd /var/modules/sdk-hmac && yarn link && \
156+
cd /var/modules/utxo-ord && yarn link && \
155157
cd /var/modules/account-lib && yarn link && \
156158
cd /var/modules/sdk-coin-ada && yarn link && \
157159
cd /var/modules/sdk-coin-algo && yarn link && \
@@ -219,13 +221,13 @@ cd /var/modules/sdk-coin-bch && yarn link && \
219221
cd /var/modules/sdk-coin-bcha && yarn link && \
220222
cd /var/modules/sdk-coin-bsv && yarn link && \
221223
cd /var/modules/sdk-coin-btc && yarn link && \
222-
cd /var/modules/utxo-ord && yarn link && \
223224
cd /var/modules/sdk-coin-btg && yarn link && \
224225
cd /var/modules/sdk-coin-dash && yarn link && \
225226
cd /var/modules/sdk-coin-doge && yarn link && \
226227
cd /var/modules/sdk-coin-eos && yarn link && \
227228
cd /var/modules/sdk-coin-ethlike && yarn link && \
228229
cd /var/modules/sdk-coin-ethw && yarn link && \
230+
cd /var/modules/sdk-coin-flrp && yarn link && \
229231
cd /var/modules/sdk-coin-iota && yarn link && \
230232
cd /var/modules/sdk-coin-lnbtc && yarn link && \
231233
cd /var/modules/sdk-coin-ltc && yarn link && \
@@ -252,6 +254,7 @@ RUN cd /var/bitgo-express && \
252254
yarn link @bitgo/blockapis && \
253255
yarn link @bitgo/sdk-api && \
254256
yarn link @bitgo/sdk-hmac && \
257+
yarn link @bitgo/utxo-ord && \
255258
yarn link @bitgo/account-lib && \
256259
yarn link @bitgo/sdk-coin-ada && \
257260
yarn link @bitgo/sdk-coin-algo && \
@@ -319,13 +322,13 @@ RUN cd /var/bitgo-express && \
319322
yarn link @bitgo/sdk-coin-bcha && \
320323
yarn link @bitgo/sdk-coin-bsv && \
321324
yarn link @bitgo/sdk-coin-btc && \
322-
yarn link @bitgo/utxo-ord && \
323325
yarn link @bitgo/sdk-coin-btg && \
324326
yarn link @bitgo/sdk-coin-dash && \
325327
yarn link @bitgo/sdk-coin-doge && \
326328
yarn link @bitgo/sdk-coin-eos && \
327329
yarn link @bitgo/sdk-coin-ethlike && \
328330
yarn link @bitgo/sdk-coin-ethw && \
331+
yarn link @bitgo/sdk-coin-flrp && \
329332
yarn link @bitgo/sdk-coin-iota && \
330333
yarn link @bitgo/sdk-coin-lnbtc && \
331334
yarn link @bitgo/sdk-coin-ltc && \

commitlint.config.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ module.exports = {
55
ignores: [
66
(commit) => /^Merge commit '[a-f0-9]{40}'$/m.test(commit),
77
(commit) => /^chore\(root\): publish modules/m.test(commit),
8-
(commit) => commit.includes('Signed-off-by: dependabot[bot] <support@github.com>'),
8+
(commit) =>
9+
commit.includes('Signed-off-by: dependabot[bot] <support@github.com>'),
910
],
1011
rules: {
11-
'scope-enum': async () => [2, 'always', (await readdir('modules')).concat('root', 'deps', 'scripts')],
12+
'scope-enum': async () => [
13+
2,
14+
'always',
15+
(await readdir('modules')).concat('root', 'deps', 'scripts', 'examples'),
16+
],
1217
'footer-max-line-length': [0, 'always', Infinity],
1318
'references-empty': [2, 'never'],
1419
},

examples/js/trx/consolidate-account-balances.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Tron wallet can't send funds from their receive addresses.
33
* Account balance consolidation is used to sweep funds from the
44
* receive addresses into the wallet's base address for sending.
5-
* @see {@link https://app.bitgo.com/docs/#operation/v2.wallet.consolidateaccount.build}
5+
* @see {@link https://developers.bitgo.com/reference/v2walletconsolidateaccountbuild#/}
66
*/
77
const BitGoJS = require('bitgo');
88

examples/js/xtz/consolidate-account-balances.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Tezos wallet can't send funds from their receive addresses.
33
* Account balance consolidation is used to sweep funds from the
44
* receive addresses into the wallet's base address for sending.
5-
* @see {@link https://app.bitgo.com/docs/#operation/v2.wallet.consolidateaccount.build}
5+
* @see {@link https://developers.bitgo.com/reference/v2walletconsolidateaccountbuild#/}
66
*/
77
const BitGoJS = require('bitgo');
88
const Promise = require('bluebird');

examples/ts/apt/stake-apt.ts

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/**
2+
* Performs delegated staking with Aptos.
3+
*
4+
* Copyright 2025, BitGo, Inc. All Rights Reserved.
5+
*/
6+
import { BitGoAPI } from '@bitgo/sdk-api';
7+
import { coins } from '@bitgo/statics';
8+
import { Tapt, TransactionBuilderFactory, Utils } from '@bitgo/sdk-coin-apt';
9+
import { Network, Aptos, AptosConfig, Account, Ed25519PrivateKey, SimpleTransaction } from '@aptos-labs/ts-sdk';
10+
11+
require('dotenv').config({ path: '../../.env' });
12+
13+
const AMOUNT_OCTAS = 11 * 100_000_000;
14+
const NETWORK = Network.TESTNET;
15+
16+
const aptosConfig = new AptosConfig({ network: NETWORK });
17+
const aptos = new Aptos(aptosConfig);
18+
19+
const bitgo = new BitGoAPI({
20+
accessToken: process.env.TESTNET_ACCESS_TOKEN,
21+
env: 'test',
22+
});
23+
const coin = coins.get('tapt');
24+
bitgo.register(coin.name, Tapt.createInstance);
25+
26+
const broadcastToSimple = (serializedTx: string) =>
27+
new SimpleTransaction(Utils.default.deserializeSignedTransaction(serializedTx).raw_txn);
28+
29+
async function main() {
30+
const account = getAccount();
31+
const delegationPoolAddress = getDelegationPoolAddress();
32+
33+
// Account should have sufficient balance
34+
const accountBalance = await aptos.getAccountAPTAmount({ accountAddress: account.accountAddress });
35+
if (accountBalance < AMOUNT_OCTAS) {
36+
console.info(`Balance of ${account.accountAddress} is ${accountBalance} octas, requesting funds.`);
37+
const txn = await aptos.fundAccount({ accountAddress: account.accountAddress, amount: AMOUNT_OCTAS });
38+
await aptos.waitForTransaction({ transactionHash: txn.hash });
39+
console.info(`Funding successful: ${txn.hash}`);
40+
}
41+
const { sequence_number } = await aptos.getAccountInfo({ accountAddress: account.accountAddress });
42+
43+
// Use BitGoAPI to build instruction
44+
const txBuilder = new TransactionBuilderFactory(coin).getDelegationPoolAddStakeTransactionBuilder();
45+
txBuilder
46+
.sender(account.accountAddress.toString())
47+
.recipients([{ address: delegationPoolAddress, amount: `${AMOUNT_OCTAS}` }])
48+
.sequenceNumber(Number(sequence_number));
49+
const unsignedTx = await txBuilder.build();
50+
const serializedUnsignedTx = unsignedTx.toBroadcastFormat();
51+
52+
// Sign transaction. Signing is flexible, let's use Aptos libs
53+
const authenticator = aptos.sign({
54+
signer: account,
55+
transaction: broadcastToSimple(serializedUnsignedTx),
56+
});
57+
if (!authenticator.isEd25519()) {
58+
throw new Error('Example only supports Ed25519');
59+
}
60+
txBuilder.addSenderSignature(
61+
{ pub: account.publicKey.toString() },
62+
Buffer.from(authenticator.signature.toUint8Array())
63+
);
64+
const tx = await txBuilder.build();
65+
const serializedTx = tx.toBroadcastFormat();
66+
console.info(`Transaction ${serializedTx} and JSON:\n${JSON.stringify(tx.toJson(), undefined, 2)}`);
67+
68+
// Submit transaction
69+
const submittedTxn = await aptos.transaction.submit.simple({
70+
transaction: broadcastToSimple(serializedTx),
71+
senderAuthenticator: authenticator,
72+
});
73+
console.log(`Success: ${submittedTxn.hash}`);
74+
}
75+
76+
const getAccount = () => {
77+
const privateKey = process.env.APTOS_PRIVATE_KEY;
78+
if (privateKey === undefined) {
79+
const { privateKey } = Account.generate();
80+
console.log('# Here is a new account to save into your .env file.');
81+
console.log(`APTOS_PRIVATE_KEY=${privateKey.toAIP80String()}`);
82+
throw new Error('Missing account information');
83+
}
84+
return Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey(privateKey) });
85+
};
86+
87+
const getDelegationPoolAddress = () => {
88+
const address = process.env.APTOS_DELEGATION_POOL_ADDRESS;
89+
if (!address) {
90+
console.log('# Provide a delegation pool.');
91+
console.log(`APTOS_DELEGATION_POOL_ADDRESS=`);
92+
throw new Error('Missing delegation pool address');
93+
}
94+
return address;
95+
};
96+
97+
main().catch((e) => console.error(e));
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Wallet Passphrase Recovery Script
4+
*
5+
* This script takes box D information in the keycard and recovers the wallet passphrase.
6+
*
7+
* The script will prompt for:
8+
* - Environment (test/prod)
9+
* - Activation code
10+
* - Encrypted wallet passphrase from Box D of keycard
11+
*
12+
* You need to install node and BitGoJS SDK to run this script.
13+
*
14+
* To install node, you can follow the instructions here: https://nodejs.org/en/download
15+
*
16+
* To install BitGoJS SDK, you can use the following command:
17+
* npm install @bitgo/sdk-api
18+
*
19+
* Usage:
20+
* tsx wallet-passphrase-recovery.ts
21+
* OR
22+
* npx ts-node wallet-passphrase-recovery.ts
23+
*/
24+
25+
import { BitGoAPI } from '@bitgo/sdk-api';
26+
import * as readline from 'readline';
27+
28+
// Create readline interface for user input
29+
const rl = readline.createInterface({
30+
input: process.stdin,
31+
output: process.stdout,
32+
});
33+
34+
// Function to ask questions in the terminal
35+
function askQuestion(query: string): Promise<string> {
36+
return new Promise((resolve) => {
37+
rl.question(query, (answer) => {
38+
resolve(answer);
39+
});
40+
});
41+
}
42+
43+
async function main(): Promise<void> {
44+
try {
45+
console.log('BitGo V1 Wallet Password Recovery Tool');
46+
console.log('====================================\n');
47+
48+
// Get environment setting
49+
const envInput = await askQuestion(
50+
'Enter environment (test/prod) [default: test]: ',
51+
);
52+
const env = envInput.toLowerCase() === 'prod' ? 'prod' : 'test';
53+
54+
// Initialize BitGo
55+
const bitgo = new BitGoAPI({
56+
env: env,
57+
});
58+
59+
// Get activation code
60+
const activationCode = await askQuestion('Enter activation code: ');
61+
62+
// Get encrypted wallet passphrase from Box D
63+
const encryptedWalletPassphrase = await askQuestion(
64+
'Enter encrypted wallet passphrase from Box D: ',
65+
);
66+
67+
// Decrypt the wallet passphrase
68+
const walletPassphrase = bitgo.decrypt({
69+
input: encryptedWalletPassphrase,
70+
password: activationCode,
71+
});
72+
73+
console.log(`\n✅ SUCCESS: the decrypted passphrase is: ${walletPassphrase}`);
74+
} catch (error) {
75+
console.error(`\nError: ${error.message}`);
76+
if (error.status) {
77+
console.error(`Status code: ${error.status}`);
78+
}
79+
console.error('Please check your credentials and try again.');
80+
} finally {
81+
rl.close();
82+
}
83+
}
84+
85+
main().catch((error) => {
86+
console.error(`Fatal error: ${error.message}`);
87+
process.exit(1);
88+
});

examples/ts/trx/consolidate-hot-account-balances.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Tron wallets can't send funds from their receive addresses.
33
* Account balance consolidation is used to sweep funds from the
44
* receive addresses into the wallet's base address for sending.
5-
* @see {@link https://app.bitgo.com/docs/#operation/v2.wallet.consolidateaccount.build}
5+
* @see {@link https://developers.bitgo.com/reference/v2walletconsolidateaccountbuild#/}
66
*/
77
import { BitGo, WalletCoinSpecific } from 'bitgo';
88

examples/ts/xtz/consolidate-account-balances.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Tezos wallet can't send funds from their receive addresses.
33
* Account balance consolidation is used to sweep funds from the
44
* receive addresses into the wallet's base address for sending.
5-
* @see {@link https://app.bitgo.com/docs/#operation/v2.wallet.consolidateaccount.build}
5+
* @see {@link https://developers.bitgo.com/reference/v2walletconsolidateaccountbuild#/}
66
*/
77
import { BitGo, WalletCoinSpecific } from 'bitgo';
88

0 commit comments

Comments
 (0)