Skip to content

Commit

Permalink
Merge pull request #248 from BitGo/feat/add-sol
Browse files Browse the repository at this point in the history
feat: add solana to non-bitgo recovery dropdown
  • Loading branch information
benpreiser authored Oct 24, 2022
2 parents f9fa908 + de6ba9d commit fdd05b5
Show file tree
Hide file tree
Showing 15 changed files with 8,702 additions and 6,593 deletions.
31 changes: 31 additions & 0 deletions DURABLE_NONCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Obtain Durable Nonce Instructions

Wallet Recovery Wizard allows you to provide a durable nonce when building Solana recoveries. A durable nonce allows you to extend the 60 second broadcast window of Solana transactions. After selecting "SOL" or "TSOL" from the coin dropdown, you will see two fields: Durable Nonce: Public Key and Durable Nonce: Secret Key. You may either enter the keys for a durable nonce you already have prepared or follow the steps below to create one (Note: if you receiver an "unknown signer" error, skip to step 3 of the instructions below):

1. Open a terminal window, clone the repository, navigate to the cloned repository and install node modules:

```bash
git clone [email protected]:BitGo/wallet-recovery-wizard.git
cd wallet-recovery-wizard
npm i
```

2. Run the script to build a durable nonce with the "create" command, and save your public key and secret key:

```bash
npm run durable-nonce:build -- create
```

3. Run the script to build a durable nonce with the "import" command, and copy and paste the public key and secret key into Wallet Recovery Wizard.

i. If on Devnet, set the -n flag to "devnet":

```bash
npm run durable-nonce:build -- import -n devnet
```

ii. If on Mainnet Beta, set the -n flag to "mainnet-beta":

```bash
npm run durable-nonce:build -- import -n mainnet-beta
```
22 changes: 12 additions & 10 deletions NON_BITGO_RECOVERY.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,27 @@ Build a transaction from a hot wallet using the KeyCard in order to recover fund

7. You are asked to provide the Destination Address (The address where you want to receive your recovered funds).

8. For UTXO based coins like Bitcoin, Litecoin, Dash, Zcash, Bitcoin Gold, Tron, and Bitcoin Cash, Address Scanning Factor needs to be provided. By default, it's value is 20 and can be changed if needed. The tool scans the addresses of the wallet to find the unspents. If it doesn't find unspents in 20 consecutive addresses, then it will stop scanning and generate a recovery transaction. For eg: If your funds are stuck in addresses with indices 10, 25 and 50 and you keep scanning factor as 20. Then the tool will stop after scanning till 46th index, because it didn't find unspents for 20 consecutive addresses from 26th address onwards. So in order to recover the funds in the address with 50th index, you will have to increase the scanning factor to a higher value.
8. For Solana, you may optionally provide a Public Key and a Secret Key for a durable nonce. If provided, the broadcast 60 second broadcast window of Solana transactions will be extended.

9. For Ethereum, Ethereum Proof of Work, and ERC20 Token, Max Fee Per Gas Price and Max Priority Fee Per Gas in Gwei needs to be provided. The value should be between 1 Gwei and 2500 Gwei. The default is 20 Gwei for Max Fee Per Gas and 10 Gwei for Max Priority Fee Per Gas. If there is not enough Gwei in the backup key address gas tank, you will need to fund your backup key address. WRW will report the backup key address if there is not enough Gwei in it.
9. For Bitcoin, Litecoin, Dash, Zcash, Bitcoin Gold, Tron, Bitcoin Cash, Near, Polkadot, and Solana, Address Scanning Factor needs to be provided. By default, it's value is 20 and can be changed if needed. The tool scans the addresses of the wallet to find the unspents. If it doesn't find unspents in 20 consecutive addresses, then it will stop scanning and generate a recovery transaction. For eg: If your funds are stuck in addresses with indices 10, 25 and 50 and you keep scanning factor as 20. Then the tool will stop after scanning till 46th index, because it didn't find unspents for 20 consecutive addresses from 26th address onwards. So in order to recover the funds in the address with 50th index, you will have to increase the scanning factor to a higher value.

10. For Ethereum, Ethereum Proof of Work, ERC20 Token, and Avalanche C-Chain, Gas Limit needs to be provided. The value should be between 30,000 and 20,000,000. The default is 500,000 units of gas.
10. For Ethereum, Ethereum Proof of Work, and ERC20 Token, Max Fee Per Gas Price and Max Priority Fee Per Gas in Gwei needs to be provided. The value should be between 1 Gwei and 2500 Gwei. The default is 20 Gwei for Max Fee Per Gas and 10 Gwei for Max Priority Fee Per Gas. If there is not enough Gwei in the backup key address gas tank, you will need to fund your backup key address. WRW will report the backup key address if there is not enough Gwei in it.

11. For Avalanche C-Chain, Gas Price needs to be provided. The value should be between 1 Gwei and 2500 Gwei. The default is 30 Gwei.
11. For Ethereum, Ethereum Proof of Work, ERC20 Token, and Avalanche C-Chain, Gas Limit needs to be provided. The value should be between 30,000 and 20,000,000. The default is 500,000 units of gas.

12. An API Key token from etherscan.com needs to be provided for certain recoveries.
12. For Avalanche C-Chain, Gas Price needs to be provided. The value should be between 1 Gwei and 2500 Gwei. The default is 30 Gwei.

13. For UTXO based coins like Bitcoin, Litecoin, Dash, Zcash, Bitcoin Gold, and Bitcoin Cash, the key is from https://blockchair.com/.
13. An API Key token from etherscan.com needs to be provided for certain recoveries.

14. For Ethereum and ERC20 token, the key is from https://etherscan.io/.
14. For UTXO based coins like Bitcoin, Litecoin, Dash, Zcash, Bitcoin Gold, and Bitcoin Cash, the key is from https://blockchair.com/.

15. For Avalanche C-Chain, the key is from https://snowtrace.io/.
15. For Ethereum and ERC20 token, the key is from https://etherscan.io/.

16. The SDK determines the amount of Coin that can be recovered, and builds a fully signed transaction to send that amount to the Destination Address.
16. For Avalanche C-Chain, the key is from https://snowtrace.io/.

17. This completed transaction can be broadcasted on the network using a blockchain explorer to finish the recovery.
17. The SDK determines the amount of Coin that can be recovered, and builds a fully signed transaction to send that amount to the Destination Address.

18. This completed transaction can be broadcasted on the network using a blockchain explorer to finish the recovery.
Some blockchain explorers to broadcast the transaction are as follows:

Avalanche C-Chain transactions: https://snowtrace.io/pushTx
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ Instructions to broadcast DOT transactions: [DOT.md](DOT.md)

Instructions to broadcast NEAR transactions: [NEAR.md](NEAR.md)

Instructions to broadcast SOL transactions: [SOL.md](SOL.md)

Instructions to do Non-BitGo recovery from hot wallets: [NON_BITGO_RECOVERY.md](NON_BITGO_RECOVERY.md)

Instructions to do Non-BitGo recovery from cold wallets (Unsigned Sweep): [UNSIGNED_SWEEP.md](UNSIGNED_SWEEP.md)

Instructions to decode ETH transactions [DECODE.md](DECODE.MD)

Instructions to obtain durable nonce for SOL transactions [DURABLE_NONCE.md](DURABLE_NONCE.md)
27 changes: 27 additions & 0 deletions SOL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Version 4.5.0 of the Wallet Recovery Wizard supports building transactions to recover NEAR from your BitGo Hot and Self-Managed Cold wallets.

Below is a list full node RPC endpoints that must be called to broadcast the transaction as there are no suitable explorers available for NEAR.

Construct the API request to the full node:

Testnet Request URL: https://api.devnet.solana.com

Mainnet Request URL: https://api.mainnet-beta.solana.com

Method: POST

Request Body format (find "serializedTx" in your downloaded JSON):

```json
{
"id": 2,
"jsonrpc": "2.0",
"method": "sendTransaction",
"params": [
"serializedTx",
{
"encoding": "base64"
}
]
}
```
3 changes: 3 additions & 0 deletions electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Near, TNear } from '@bitgo/sdk-coin-near';
import { Trx, Ttrx } from '@bitgo/sdk-coin-trx';
import { Txlm, Xlm } from '@bitgo/sdk-coin-xlm';
import { Txrp, Xrp } from '@bitgo/sdk-coin-xrp';
import { Sol, Tsol } from '@bitgo/sdk-coin-sol';
import { Zec } from '@bitgo/sdk-coin-zec';
import { fromBase58 } from 'bip32';
import { app, BrowserWindow, dialog, ipcMain, shell } from 'electron';
Expand Down Expand Up @@ -77,6 +78,8 @@ sdk.register('near', Near.createInstance);
sdk.register('tnear', TNear.createInstance);
sdk.register('dot', Dot.createInstance);
sdk.register('tdot', Tdot.createInstance);
sdk.register('sol', Sol.createInstance);
sdk.register('tsol', Tsol.createInstance);
Erc20Token.createTokenConstructors().forEach(({ name, coinConstructor }) => {
sdk.register(name, coinConstructor);
});
Expand Down
4 changes: 4 additions & 0 deletions electron/preload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ type Commands = {
hardfork: `${Hardfork}`;
};
walletContractAddress?: string;
durableNonce?: {
publicKey: string;
secretKey: string;
};
tokenAddress?: string;
}
): Promise<BackupKeyRecoveryTransansaction | FormattedOfflineVaultTxInfo>;
Expand Down
Loading

0 comments on commit fdd05b5

Please sign in to comment.