|
| 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