Skip to content

Commit 4fff95c

Browse files
committed
2 parents 3c11abd + 6fb6595 commit 4fff95c

File tree

79 files changed

+8235
-594
lines changed

Some content is hidden

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

79 files changed

+8235
-594
lines changed

.github/renovate.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
{
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3-
"extends": ["github>BitGo/gha-renovate-bot//presets/onboarding#v1.15.1"],
3+
"extends": ["github>BitGo/gha-renovate-bot//presets/default"],
44
"baseBranches": ["master"],
5-
"enabledManagers": ["github-actions", "regex"],
5+
"enabledManagers": ["github-actions", "regex", "npm"],
6+
"packageRules": [
7+
{
8+
"description": "Disable all npm dependencies by default",
9+
"matchManagers": ["npm"],
10+
"enabled": false
11+
},
12+
{
13+
"description": "Enable updates only for @bitgo/public-types",
14+
"matchPackageNames": ["@bitgo/public-types"],
15+
"enabled": true
16+
}
17+
]
618
}

.iyarc

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
1-
GHSA-3h5v-q93c-6h6q
2-
GHSA-8hc4-vh64-cxmj
3-
GHSA-9wv6-86v2-598j
41
GHSA-3gc7-fjrx-p6mg
5-
GHSA-cpj6-fhp6-mr6j
6-
GHSA-f46r-rw29-r322

CODEOWNERS

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
/modules/sdk-coin-eos/ @BitGo/ethalt-team
6969
/modules/sdk-coin-evm/ @BitGo/ethalt-team
7070
/modules/sdk-coin-flr/ @BitGo/ethalt-team
71+
/modules/sdk-coin-flrp/ @BitGo/ethalt-team
7172
/modules/sdk-coin-ethlike/ @BitGo/ethalt-team
7273
/modules/sdk-coin-hbar/ @BitGo/ethalt-team
7374
/modules/sdk-coin-icp/ @BitGo/ethalt-team
@@ -148,11 +149,11 @@
148149
/commitlint.config.js @BitGo/coins @BitGo/web-experience @BitGo/wallet-platform
149150
/Dockerfile @BitGo/coins @BitGo/web-experience @BitGo/wallet-platform
150151
/lerna.json @BitGo/coins @BitGo/web-experience @BitGo/wallet-platform @BitGo/developer-experience @BitGo/devops
151-
/package.json @BitGo/coins @BitGo/web-experience @BitGo/wallet-platform @BitGo/developer-experience @BitGo/devops
152-
**/package.json @BitGo/coins @BitGo/web-experience @BitGo/wallet-platform @BitGo/developer-experience @BitGo/devops
152+
/package.json @BitGo/sdk-reviewers
153+
**/package.json @BitGo/sdk-reviewers
153154
/tsconfig.json @BitGo/coins @BitGo/web-experience @BitGo/wallet-platform @BitGo/developer-experience @BitGo/devops
154155
/tsconfig.packages.json @BitGo/coins @BitGo/web-experience @BitGo/wallet-platform
155-
/yarn.lock @BitGo/coins @BitGo/web-experience @BitGo/wallet-platform @BitGo/developer-experience @BitGo/devops
156+
/yarn.lock @BitGo/sdk-reviewers
156157
/.iyarc @BitGo/wallet-platform @BitGo/hsm @BitGo/velocity
157158
flake.nix @BitGo/wallet-platform @BitGo/hsm @BitGo/developer-experience
158159
flake.lock @BitGo/wallet-platform @BitGo/hsm @BitGo/developer-experience

examples/ts/sol/stake-jito.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require('dotenv').config({ path: '../../.env' });
1616

1717
const AMOUNT_LAMPORTS = 1000;
1818
const JITO_STAKE_POOL_ADDRESS = 'Jito4APyf642JPZPx3hGc6WWJ8zPKtRbRs4P815Awbb';
19-
const NETWORK = 'devnet';
19+
const NETWORK = 'testnet';
2020

2121
const bitgo = new BitGoAPI({
2222
accessToken: process.env.TESTNET_ACCESS_TOKEN,

examples/ts/sol/unstake-jito.ts

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/**
2+
* Unstakes JitoSOL tokens on Solana devnet.
3+
*
4+
* Copyright 2025, BitGo, Inc. All Rights Reserved.
5+
*/
6+
import { SolStakingTypeEnum } from '@bitgo/public-types';
7+
import { BitGoAPI } from '@bitgo/sdk-api';
8+
import { TransactionBuilderFactory, Tsol } from '@bitgo/sdk-coin-sol';
9+
import { coins } from '@bitgo/statics';
10+
import { Connection, PublicKey, clusterApiUrl, Keypair } from '@solana/web3.js';
11+
import { getStakePoolAccount } from '@solana/spl-stake-pool';
12+
import * as bs58 from 'bs58';
13+
14+
require('dotenv').config({ path: '../../.env' });
15+
16+
const AMOUNT_TOKENS = 100;
17+
const JITO_STAKE_POOL_ADDRESS = 'Jito4APyf642JPZPx3hGc6WWJ8zPKtRbRs4P815Awbb';
18+
const NETWORK = 'testnet';
19+
// You must find a validator. Try prepareWithdrawAccounts.
20+
21+
const bitgo = new BitGoAPI({
22+
accessToken: process.env.TESTNET_ACCESS_TOKEN,
23+
env: 'test',
24+
});
25+
const coin = coins.get('tsol');
26+
bitgo.register(coin.name, Tsol.createInstance);
27+
28+
async function main() {
29+
const account = getAccount();
30+
const { validatorAddress } = getValidator();
31+
const connection = new Connection(clusterApiUrl(NETWORK), 'confirmed');
32+
const recentBlockhash = await connection.getLatestBlockhash();
33+
const stakePoolAddress = new PublicKey(JITO_STAKE_POOL_ADDRESS);
34+
const stakePoolAccount = await getStakePoolAccount(connection, stakePoolAddress);
35+
console.info('Validator list account', stakePoolAccount.account.data.validatorList.toBase58());
36+
37+
const transferAuthority = Keypair.generate();
38+
const stakeAccount = Keypair.generate();
39+
console.info('Transfer authority public key:', transferAuthority.publicKey.toBase58());
40+
console.info('Stake account public key:', stakeAccount.publicKey.toBase58());
41+
42+
// Use BitGoAPI to build withdrawStake instruction
43+
const txBuilder = new TransactionBuilderFactory(coin).getStakingDeactivateBuilder();
44+
txBuilder
45+
.amount(`${AMOUNT_TOKENS}`)
46+
.sender(account.publicKey.toBase58())
47+
.stakingAddress(JITO_STAKE_POOL_ADDRESS)
48+
.unstakingAddress(stakeAccount.publicKey.toBase58())
49+
.stakingType(SolStakingTypeEnum.JITO)
50+
.extraParams({
51+
stakePoolData: {
52+
managerFeeAccount: stakePoolAccount.account.data.managerFeeAccount.toBase58(),
53+
poolMint: stakePoolAccount.account.data.poolMint.toBase58(),
54+
validatorListAccount: stakePoolAccount.account.data.validatorList.toBase58(),
55+
},
56+
validatorAddress,
57+
transferAuthorityAddress: transferAuthority.publicKey.toBase58(),
58+
})
59+
.nonce(recentBlockhash.blockhash);
60+
61+
txBuilder.sign({ key: account.secretKey });
62+
txBuilder.sign({ key: bs58.encode(stakeAccount.secretKey) });
63+
txBuilder.sign({ key: bs58.encode(transferAuthority.secretKey) });
64+
65+
const tx = await txBuilder.build();
66+
const serializedTx = tx.toBroadcastFormat();
67+
console.info(serializedTx);
68+
console.info(`Transaction JSON:\n${JSON.stringify(tx.toJson(), undefined, 2)}`);
69+
70+
// Send transaction
71+
try {
72+
const sig = await connection.sendRawTransaction(Buffer.from(serializedTx, 'base64'));
73+
await connection.confirmTransaction(sig);
74+
console.log(`${AMOUNT_TOKENS} tokens withdrawn`, sig);
75+
} catch (e) {
76+
console.log('Error sending transaction');
77+
console.error(e);
78+
}
79+
}
80+
81+
const getAccount = () => {
82+
const publicKey = process.env.ACCOUNT_PUBLIC_KEY;
83+
const secretKey = process.env.ACCOUNT_SECRET_KEY;
84+
if (publicKey === undefined || secretKey === undefined) {
85+
const { publicKey, secretKey } = Keypair.generate();
86+
console.log('# Here is a new account to save into your .env file.');
87+
console.log(`ACCOUNT_PUBLIC_KEY=${publicKey.toBase58()}`);
88+
console.log(`ACCOUNT_SECRET_KEY=${bs58.encode(secretKey)}`);
89+
throw new Error('Missing account information');
90+
}
91+
92+
return {
93+
publicKey: new PublicKey(publicKey),
94+
secretKey,
95+
secretKeyArray: new Uint8Array(bs58.decode(secretKey)),
96+
};
97+
};
98+
99+
const getValidator = () => {
100+
const validatorAddress = process.env.VALIDATOR_PUBLIC_KEY;
101+
if (validatorAddress === undefined) {
102+
console.log('# You must select a validator, then define the entry below');
103+
console.log('VALIDATOR_PUBLIC_KEY=');
104+
throw new Error('Missing validator address');
105+
}
106+
return { validatorAddress };
107+
};
108+
109+
main().catch((e) => console.error(e));

modules/abstract-lightning/src/codecs/api/wallet.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,15 @@ export const WatchOnlyAccount = t.type({
5252

5353
export type WatchOnlyAccount = t.TypeOf<typeof WatchOnlyAccount>;
5454

55-
export const WatchOnly = t.type({
56-
master_key_birthday_timestamp: t.string,
57-
master_key_fingerprint: t.string,
58-
accounts: t.array(WatchOnlyAccount),
59-
});
55+
export const WatchOnly = t.intersection([
56+
t.type({
57+
accounts: t.array(WatchOnlyAccount),
58+
}),
59+
t.partial({
60+
master_key_birthday_timestamp: t.string,
61+
master_key_fingerprint: t.string,
62+
}),
63+
]);
6064

6165
export type WatchOnly = t.TypeOf<typeof WatchOnly>;
6266

modules/abstract-lightning/src/lightning/lightningUtils.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,18 @@ function convertXpubPrefix(xpub: string, purpose: ExtendedKeyPurpose, isMainnet:
154154
/**
155155
* Derives watch-only accounts from the master HD node for the given purposes and network.
156156
*/
157-
function deriveWatchOnlyAccounts(masterHDNode: utxolib.BIP32Interface, isMainnet: boolean): WatchOnlyAccount[] {
157+
export function deriveWatchOnlyAccounts(
158+
masterHDNode: utxolib.BIP32Interface,
159+
isMainnet: boolean,
160+
params: { onlyAddressCreationAccounts?: boolean } = { onlyAddressCreationAccounts: false }
161+
): WatchOnlyAccount[] {
158162
// https://github.com/lightningnetwork/lnd/blob/master/docs/remote-signing.md#required-accounts
159163
if (masterHDNode.isNeutered()) {
160164
throw new Error('masterHDNode must not be neutered');
161165
}
162-
163-
const purposes = [PURPOSE_WRAPPED_P2WKH, PURPOSE_P2WKH, PURPOSE_P2TR, PURPOSE_ALL_OTHERS] as const;
164-
166+
const purposes = params.onlyAddressCreationAccounts
167+
? ([PURPOSE_WRAPPED_P2WKH, PURPOSE_P2WKH, PURPOSE_P2TR] as const)
168+
: ([PURPOSE_WRAPPED_P2WKH, PURPOSE_P2WKH, PURPOSE_P2TR, PURPOSE_ALL_OTHERS] as const);
165169
return purposes.flatMap((purpose) => {
166170
const maxAccount = purpose === PURPOSE_ALL_OTHERS ? 255 : 0;
167171
const coinType = purpose !== PURPOSE_ALL_OTHERS || isMainnet ? 0 : 1;

modules/bitgo/src/v2/coinFactory.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,10 @@ export function getTokenConstructor(tokenConfig: TokenConfig): CoinConstructor |
929929
case 'bera':
930930
case 'tbera':
931931
return BeraToken.createTokenConstructor(tokenConfig as EthLikeTokenConfig);
932+
case 'baseeth':
933+
case 'tbaseeth':
934+
const coinNames = { Mainnet: 'baseeth', Testnet: 'tbaseeth' };
935+
return EthLikeErc20Token.createTokenConstructor(tokenConfig as EthLikeTokenConfig, coinNames);
932936
case 'coredao':
933937
case 'tcoredao':
934938
return CoredaoToken.createTokenConstructor(tokenConfig as EthLikeTokenConfig);

modules/bitgo/test/v2/fixtures/staking/stakingWallet.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,42 @@ export default {
7777
},
7878
senderWalletId: 'btcDescriptorWalletId',
7979
},
80+
81+
matchingDataBuildParams: {
82+
memo: 'matching-memo',
83+
gasLimit: 200000,
84+
type: 'pay',
85+
solInstructions: [{ programId: 'Stake111', keys: [], data: 'delegate' }],
86+
aptosCustomTransactionParams: { moduleName: '0x1::staking', functionName: 'stake' },
87+
},
88+
89+
mismatchMemoBuildParams: {
90+
memo: 'user-memo',
91+
},
92+
93+
mismatchGasLimitBuildParams: {
94+
gasLimit: 100000,
95+
},
96+
97+
mismatchTypeBuildParams: {
98+
type: 'stake',
99+
},
100+
101+
mismatchSolInstructionsBuildParams: {
102+
solInstructions: [
103+
{
104+
programId: 'UserStakeProgram1111111111111111111111111111',
105+
keys: [{ pubkey: 'user-key', isSigner: true, isWritable: true }],
106+
data: 'user-delegate-data',
107+
},
108+
],
109+
},
110+
111+
mismatchAptosParamsBuildParams: {
112+
aptosCustomTransactionParams: {
113+
moduleName: '0x1::staking',
114+
functionName: 'stake',
115+
functionArguments: ['10000'],
116+
},
117+
},
80118
};

modules/express/src/clientRoutes.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,7 @@ export function setupAPIRoutes(app: express.Application, config: Config): void {
15581558
router.post('express.decrypt', [prepareBitGo(config), typedPromiseWrapper(handleDecrypt)]);
15591559
router.post('express.encrypt', [prepareBitGo(config), typedPromiseWrapper(handleEncrypt)]);
15601560
router.post('express.verifyaddress', [prepareBitGo(config), typedPromiseWrapper(handleVerifyAddress)]);
1561+
router.post('express.lightning.initWallet', [prepareBitGo(config), typedPromiseWrapper(handleInitLightningWallet)]);
15611562
router.post('express.lightning.unlockWallet', [
15621563
prepareBitGo(config),
15631564
typedPromiseWrapper(handleUnlockLightningWallet),
@@ -1786,12 +1787,6 @@ export function setupEnclavedExpressRoutes(app: express.Application, config: Con
17861787
}
17871788

17881789
export function setupLightningSignerNodeRoutes(app: express.Application, config: Config): void {
1789-
app.post(
1790-
'/api/v2/:coin/wallet/:id/initwallet',
1791-
parseBody,
1792-
prepareBitGo(config),
1793-
promiseWrapper(handleInitLightningWallet)
1794-
);
17951790
app.post(
17961791
'/api/v2/:coin/wallet/:id/signermacaroon',
17971792
parseBody,

0 commit comments

Comments
 (0)