Skip to content

Commit ef5a1b1

Browse files
committed
feat: add bulk update functionality for wallet shares
Ticket: CSI-419
1 parent 76e75bd commit ef5a1b1

File tree

5 files changed

+785
-1
lines changed

5 files changed

+785
-1
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* Update multiple wallet shares in bulk
3+
*
4+
* This example demonstrates how to update multiple wallet shares in bulk.
5+
* You can use this to accept or reject multiple wallet shares at once.
6+
*
7+
* Copyright 2022, BitGo, Inc. All Rights Reserved.
8+
*/
9+
import { BitGoAPI } from '@bitgo/sdk-api';
10+
import { Tltc } from '@bitgo/sdk-coin-ltc';
11+
require('dotenv').config({ path: '../../.env' });
12+
13+
const bitgo = new BitGoAPI({
14+
accessToken: process.env.TESTNET_ACCESS_TOKEN,
15+
env: 'test',
16+
});
17+
18+
const coin = 'tltc';
19+
bitgo.register(coin, Tltc.createInstance);
20+
21+
// Add the wallet share IDs that need to be updated
22+
const shares: { walletShareId: string; status: 'accept' | 'reject' }[] = [
23+
{
24+
walletShareId: '', // add the first wallet share ID
25+
status: 'accept', // can be 'accept' or 'reject'
26+
},
27+
{
28+
walletShareId: '', // add the second wallet share ID
29+
status: 'reject',
30+
},
31+
];
32+
33+
// User login password is required for accepting shares
34+
const userLoginPassword = ''; // add your user login password
35+
36+
// Optional: new wallet passphrase if you want to set a new passphrase
37+
const newWalletPassphrase = ''; // leave empty if not changing passphrase
38+
39+
async function main() {
40+
try {
41+
const updateShares = await bitgo
42+
.coin(coin)
43+
.wallets()
44+
.bulkUpdateWalletShare({
45+
shares: shares,
46+
userLoginPassword: userLoginPassword,
47+
newWalletPassphrase: newWalletPassphrase || undefined,
48+
});
49+
console.dir(updateShares);
50+
} catch (e) {
51+
console.error(e);
52+
}
53+
}
54+
55+
main().catch((e) => console.error(e));

0 commit comments

Comments
 (0)