Skip to content

Commit c029b3e

Browse files
committed
Merge branch 'master' into rel/latest
2 parents 3f7258c + 1286720 commit c029b3e

Some content is hidden

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

70 files changed

+1035
-1736
lines changed

CODEOWNERS

-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
/modules/deser-lib/ @BitGo/wallet-platform @BitGo/hsm
116116
/modules/sdk-rpc-wrapper @BitGo/ethalt-team
117117
/modules/sdk-test/ @BitGo/web-experience @BitGo/wallet-platform
118-
/modules/sdk-unified-wallet @BitGo/ethalt-team
119118
/modules/sjcl/ @BitGo/coins @BitGo/web-experience @BitGo/wallet-platform
120119
/modules/statics/ @BitGo/web-experience @BitGo/wallet-platform @BitGo/ethalt-team
121120
/modules/statics/src/utxo.ts @BitGo/btc-team

commitlint.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module.exports = {
2020
'BOS-',
2121
'BT-',
2222
'BTC-',
23+
'CAAS-',
2324
'CE-',
2425
'CEN-',
2526
'CLEX-',
@@ -55,6 +56,7 @@ module.exports = {
5556
'SC-',
5657
'ST-',
5758
'STLX-',
59+
'TMS-',
5860
'TRUST-',
5961
'USDS-',
6062
'VL-',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/**
2+
* Create a Lightning custodial wallet at BitGo.
3+
*
4+
* IMPORTANT: Your BitGo account must have the "custodyLightningWallet" license
5+
* enabled to use this functionality. Contact BitGo support if you receive a
6+
* license-related error.
7+
*
8+
* Copyright 2025, BitGo, Inc. All Rights Reserved.
9+
*/
10+
11+
import { BitGoAPI } from '@bitgo/sdk-api';
12+
import { Tlnbtc } from '@bitgo/sdk-coin-lnbtc';
13+
14+
// TODO: set access token for testnet
15+
// Get this from your BitGo account
16+
const accessToken = '';
17+
18+
// TODO: set passphrase to create a wallet
19+
const passphrase = '';
20+
21+
// TODO: set your enterprise ID
22+
const enterprise = '';
23+
24+
// Generate a passcode encryption code (required for Lightning wallets)
25+
// IMPORTANT: Store this information securely. You will need it to recover your wallet if you lose wallet password.
26+
const passcodeEncryptionCode = '';
27+
28+
// Use tlnbtc for testnet, lnbtc for mainnet
29+
const coin = 'tlnbtc';
30+
31+
/**
32+
* Create a Lightning custodial wallet
33+
* This function creates a custodial Lightning wallet on the BitGo platform
34+
* @returns {Promise<void>} Wallet object
35+
*/
36+
async function main(): Promise<void> {
37+
try {
38+
const bitgo = new BitGoAPI({
39+
accessToken,
40+
env: 'test',
41+
});
42+
43+
// Register Lightning Bitcoin coin
44+
bitgo.register(coin, Tlnbtc.createInstance);
45+
46+
// Create unique label for the wallet
47+
const label = `Lightning Wallet ${new Date().toISOString()}`;
48+
49+
// Configure wallet creation options
50+
const walletOptions = {
51+
label,
52+
passphrase,
53+
enterprise,
54+
passcodeEncryptionCode,
55+
subType: 'lightningCustody' as const,
56+
};
57+
58+
console.log('Creating Lightning wallet...');
59+
console.log('Note: This requires the custodyLightningWallet license on your BitGo account.');
60+
61+
const wallet = await bitgo.coin(coin).wallets().generateWallet(walletOptions);
62+
const walletInstance = wallet.wallet;
63+
64+
// Display wallet information
65+
console.log('\nWallet created successfully:');
66+
console.log(`Wallet ID: ${walletInstance.id()}`);
67+
console.log(`Wallet label: ${walletInstance.label()}`);
68+
console.log(`Wallet type: ${walletInstance.type()}`);
69+
console.log(`Wallet subType: ${walletInstance.subType()}`);
70+
71+
// Display backup information
72+
console.log('\nIMPORTANT - BACKUP THIS INFORMATION:');
73+
console.log(`User keychain encrypted xPrv: ${wallet.userKeychain.encryptedPrv}`);
74+
75+
if ('userAuthKeychain' in wallet) {
76+
console.log(`User Auth keychain encrypted xPrv: ${wallet.userAuthKeychain.encryptedPrv}`);
77+
}
78+
79+
console.log(`Passcode Encryption Code: ${passcodeEncryptionCode}`);
80+
console.log(
81+
'\n Store this information securely. You will need it to recover your wallet if you lose wallet password.'
82+
);
83+
} catch (e) {
84+
throw e;
85+
}
86+
}
87+
88+
// Run the example
89+
main()
90+
.then(() => {
91+
console.log('Example completed successfully.');
92+
process.exit(0);
93+
})
94+
.catch((e) => {
95+
console.error('Example failed with error:', e.message);
96+
process.exit(-1);
97+
});

examples/ts/btc/lightning/create-invoice.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
import { BitGoAPI } from '@bitgo/sdk-api';
1212
import { Tlnbtc } from '@bitgo/sdk-coin-lnbtc';
1313
import { CreateInvoiceBody, getLightningWallet, Invoice } from '@bitgo/abstract-lightning';
14-
require('dotenv').config({ path: '../../.env' });
1514

1615
// TODO: set access token for testnet
1716
// Get this from your BitGo account
18-
const accessToken = process.env.TESTNET_ACCESS_TOKEN || '';
17+
const accessToken = '';
1918

2019
// TODO: set your lightning wallet ID
21-
const walletId = process.env.LIGHTNING_WALLET_ID || '';
20+
const walletId = '';
2221

2322
// Use tlnbtc for testnet, lnbtc for mainnet
2423
const coin = 'tlnbtc';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/**
2+
* Create a Lightning self-custodial wallet at BitGo.
3+
*
4+
* IMPORTANT: Your BitGo account must have the "custodyLightningWallet" license
5+
* enabled to use this functionality. Contact BitGo support if you receive a
6+
* license-related error.
7+
*
8+
* Copyright 2025, BitGo, Inc. All Rights Reserved.
9+
*/
10+
11+
import { BitGoAPI } from '@bitgo/sdk-api';
12+
import { Tlnbtc } from '@bitgo/sdk-coin-lnbtc';
13+
import * as crypto from 'crypto';
14+
15+
// TODO: set access token for testnet
16+
// Get this from your BitGo account
17+
const accessToken = '';
18+
19+
// TODO: set passphrase to create a wallet
20+
const passphrase = '';
21+
22+
// TODO: set your enterprise ID
23+
const enterprise = '';
24+
25+
// Generate a passcode encryption code (required for Lightning wallets)
26+
// IMPORTANT: Store this information securely. You will need it to recover your wallet if you lose wallet password.
27+
const passcodeEncryptionCode = process.env.PASSCODE_ENCRYPTION_CODE || crypto.randomBytes(32).toString('hex');
28+
29+
// Use tlnbtc for testnet, lnbtc for mainnet
30+
const coin = 'tlnbtc';
31+
32+
/**
33+
* Create a Lightning self-custodial wallet
34+
* This function creates a self-custodial Lightning wallet on the BitGo platform
35+
* @returns {Promise<void>} Wallet object
36+
*/
37+
async function main(): Promise<void> {
38+
try {
39+
const bitgo = new BitGoAPI({
40+
accessToken,
41+
env: 'test',
42+
});
43+
44+
// Register Lightning Bitcoin coin
45+
bitgo.register(coin, Tlnbtc.createInstance);
46+
47+
// Create unique label for the wallet
48+
const label = `Lightning Self-Custodial Wallet ${new Date().toISOString()}`;
49+
50+
// Configure wallet creation options
51+
const walletOptions = {
52+
label,
53+
passphrase,
54+
enterprise,
55+
passcodeEncryptionCode,
56+
subType: 'lightningSelfCustody' as const,
57+
};
58+
59+
console.log('Creating Lightning self-custodial wallet...');
60+
console.log('Note: This requires the custodyLightningWallet license on your BitGo account.');
61+
62+
const wallet = await bitgo.coin(coin).wallets().generateWallet(walletOptions);
63+
const walletInstance = wallet.wallet;
64+
65+
// Display wallet information
66+
console.log('\nWallet created successfully:');
67+
console.log(`Wallet ID: ${walletInstance.id()}`);
68+
console.log(`Wallet label: ${walletInstance.label()}`);
69+
console.log(`Wallet type: ${walletInstance.type()}`);
70+
console.log(`Wallet subType: ${walletInstance.subType()}`);
71+
72+
// Display backup information
73+
console.log('\nIMPORTANT - BACKUP THIS INFORMATION:');
74+
console.log(`User keychain encrypted xPrv: ${wallet.userKeychain.encryptedPrv}`);
75+
76+
// CRITICAL: Node Auth keychain is required for self-custodial Lightning wallets
77+
console.log(`Passcode Encryption Code: ${passcodeEncryptionCode}`);
78+
console.log('\nStore this information securely. You will need it to recover your wallet.');
79+
} catch (e) {
80+
throw e;
81+
}
82+
}
83+
84+
// Run the example
85+
main()
86+
.then(() => {
87+
console.log('Example completed successfully.');
88+
process.exit(0);
89+
})
90+
.catch((e) => {
91+
console.error('Example failed with error:', e.message);
92+
process.exit(-1);
93+
});
+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/**
2+
* Get a Lightning payment by its payment hash.
3+
*
4+
* IMPORTANT: Your BitGo account must have the "custodyLightningWallet" license
5+
* enabled to use this functionality. Contact BitGo support if you receive a
6+
* license-related error.
7+
*
8+
* Copyright 2025, BitGo, Inc. All Rights Reserved.
9+
*/
10+
11+
import { BitGoAPI } from '@bitgo/sdk-api';
12+
import { Tlnbtc } from '@bitgo/sdk-coin-lnbtc';
13+
import { getLightningWallet } from '@bitgo/abstract-lightning';
14+
15+
// TODO: set access token for testnet
16+
// Get this from your BitGo account
17+
const accessToken = '';
18+
19+
// TODO: set your Lightning wallet ID here
20+
const walletId = '';
21+
22+
// TODO: set the payment hash of the payment to retrieve
23+
const paymentHash = '';
24+
25+
// Use tlnbtc for testnet, lnbtc for mainnet
26+
const coin = 'tlnbtc';
27+
28+
/**
29+
* Get a Lightning payment by its payment hash
30+
* @returns {Promise<void>} Lightning payment details
31+
*/
32+
async function main(): Promise<void> {
33+
try {
34+
const bitgo = new BitGoAPI({
35+
accessToken,
36+
env: 'test',
37+
});
38+
39+
// Register Lightning Bitcoin coin
40+
bitgo.register(coin, Tlnbtc.createInstance);
41+
42+
console.log(`Getting Lightning payment with payment hash: ${paymentHash}`);
43+
44+
if (!walletId) {
45+
throw new Error('Wallet ID is required - please set LIGHTNING_WALLET_ID environment variable');
46+
}
47+
48+
if (!paymentHash) {
49+
throw new Error('Payment hash is required - please set PAYMENT_HASH environment variable');
50+
}
51+
52+
// Get the wallet
53+
const wallet = await bitgo.coin(coin).wallets().get({ id: walletId });
54+
55+
// Get the payment from Lightning wallet
56+
const lightning = getLightningWallet(wallet);
57+
const payment = await lightning.getPayment(paymentHash);
58+
59+
// Display payment details
60+
console.log('\nPayment Details:');
61+
console.log(`Payment Hash: ${payment.paymentHash}`);
62+
console.log(`Payment Hash: ${payment.invoice}`);
63+
console.log(`Amount (msat): ${payment.amountMsat}`);
64+
65+
console.log(`Wallet ID: ${payment.walletId}`);
66+
} catch (e) {
67+
console.error('Error getting Lightning payment:', e.message);
68+
throw e;
69+
}
70+
}
71+
72+
// Run the example
73+
main()
74+
.then(() => {
75+
console.log('Example completed successfully.');
76+
process.exit(0);
77+
})
78+
.catch((e) => {
79+
console.error('Example failed with error:', e.message);
80+
process.exit(-1);
81+
});

0 commit comments

Comments
 (0)