Skip to content

Commit

Permalink
initial cleanup & repo update
Browse files Browse the repository at this point in the history
  • Loading branch information
olamigokayphils committed Feb 6, 2023
1 parent 30ea763 commit f96542b
Show file tree
Hide file tree
Showing 9 changed files with 510 additions and 419 deletions.
4 changes: 2 additions & 2 deletions .env.dist → .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PRIVATE_KEY1_BIP32=
PRIVATE_KEY2=
DESTINATION_ADDR=
N=
NETWORK=
DERIVATION_PATH=
DERIVATION_PATH=
N=
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Address
addresses.json
# Logs
logs
*.log
Expand Down
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
* **THIS IS BETA SOFTWARE. BE CAREFUL!**
* Reference sweep script for Basic (2-of-2) MultiSig wallets. NodeJS.
* Uses [SoChain's Free API](https://sochain.com/api) by default for blockchain data and for broadcasting transactions. You can implement your own backends yourself.
* NEVER SHARE YOUR PRIVATE KEYS. NEVER USE PRIVATE KEYS ON INSECURE SYSTEMS.
- Reference sweep script for Basic (2-of-2) MultiSig wallets. NodeJS.
- This repository was originally cloned from [BlockIo Sweep](https://github.com/BlockIo/blockio-basic-multisig-sweep) Using [SoChain API](https://sochain.com/api) by default. It became imperative to move on from their Sochain API after more customers started complaining about account getting frozen for no clear reason on BlockIo and the Sochain Became a paid service.

- This project now leverages [Blockchain.com Free Service](https://blockchain.com) and [Blockcypher](https://blockcypher.com/) for data and for broadcasting transactions. You can certainly implement your own backends yourself.

- Ensure you've backed up your Keys from BlockIo

- NEVER SHARE YOUR PRIVATE KEYS. NEVER USE PRIVATE KEYS ON INSECURE SYSTEMS.

#### HOW TO RUN

Command-line Usage:
```
$ git clone <repository URL>
$ cd <dir> && npm install
$ N= PRIVATE_KEY1_BIP32= PRIVATE_KEY2= DESTINATION_ADDR= NETWORK= DERIVATION_PATH= node example.js
```

Create your `.env` file in the root directory using the `.env.example` format.

- N is the number of addresses you've generated on the given network
- PRIVATE_KEY1_BIP32 is the BIP32 extended private key you backed up
- PRIVATE_KEY2 is the second private key you backed up
- DESTINATION_ADDR is where you want the swept coins to go
- NETWORK is the network for which you're sweeping coins
- DERIVATION_PATH is the derivation path shown when you back up your private keys

```
$ node index.js
```
* N is the number of addresses you've generated on the given network
* PRIVATE_KEY1_BIP32 is the BIP32 extended private key you backed up
* PRIVATE_KEY2 is the second private key you backed up
* DESTINATION_ADDR is where you want the swept coins to go
* NETWORK is the network for which you're sweeping coins
* DERIVATION_PATH is the derivation path shown when you back up your private keys
25 changes: 0 additions & 25 deletions example.js

This file was deleted.

28 changes: 28 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const Sweeper = require("./src/sweeper");

require("dotenv").config({ debug: true });
const n = process.env.N;
const bip32 = process.env.PRIVATE_KEY1_BIP32;
const privkey2 = process.env.PRIVATE_KEY2;
const toAddr = process.env.DESTINATION_ADDR;
const network = process.env.NETWORK;
const derivationPath = process.env.DERIVATION_PATH;

console.log({ n });

if (!n || !bip32 || !privkey2 || !toAddr || !network || !derivationPath) {
console.log("One or more required arguments are missing");
process.exit(0);
}

const sweep = new Sweeper(network, bip32, privkey2, toAddr, n, derivationPath);

Sweep();

async function Sweep() {
try {
await sweep.begin();
} catch (err) {
console.log(err);
}
}
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
},
"homepage": "https://github.com/BlockIo/blockio-basic-multisig-sweep#readme",
"dependencies": {
"bitcoinjs-lib": "^6.0.0",
"ecpair": "^1.0.1",
"bip32": "^3.0.1",
"tiny-secp256k1": "^2.1.1",
"bitcoinjs-lib": "^6.0.0",
"chai": "^4.3.4",
"dotenv": "^16.0.3",
"ecpair": "^1.0.1",
"mocha": "^8.4.0",
"node-fetch": "^2.6.6"
"node-fetch": "^2.6.6",
"tiny-secp256k1": "^2.1.1"
},
"engines": {
"node": "^17 || ^16 || ^15 || ^14 || ^13 || ^12"
Expand Down
73 changes: 39 additions & 34 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -1,64 +1,69 @@
module.exports = {
P2WSH_P2SH: 'P2WSH-P2SH',
P2SH: 'P2SH',
P2WSH: 'WITNESS_V0',
COIN: '100000000',
P2WSH_P2SH: "P2WSH-P2SH",
P2SH: "P2SH",
P2WSH: "WITNESS_V0",
COIN: "100000000",
N: 100,
MAX_TX_INPUTS: 500,
BLOCKCHAIN_PROVIDER_DEFAULT: 'sochain',
BLOCKCHAIN_PROVIDER_URL_DEFAULT: 'https://sochain.com/api/v2/',
BLOCKCHAIN_PROVIDER_DEFAULT: "blockchaincom",
BLOCKCHAIN_PROVIDER_URL_DEFAULT: "https://blockchain.info",
// the order of provider names matters in PROVIDERS and PROVIDER_URLS
// the order needs to be the same
PROVIDERS: {
SOCHAIN: 'sochain',
MEMPOOLSPACE: 'mempoolspace',
BLOCKCHAINCOM: 'blockchaincom'
MEMPOOLSPACE: "mempoolspace",
BLOCKCHAINCOM: "blockchaincom",
BLOCKCYPHER: "blockcypher",
SOCHAIN: "sochain",
},
PROVIDER_URLS: {
SOCHAIN: {
URL: 'https://sochain.com/api/v2',
SUPPORT: ['BTC', 'LTC', 'DOGE', 'BTCTEST', 'DOGETEST', 'LTCTEST']
},
MEMPOOLSPACE: {
URL: 'https://mempool.space',
SUPPORT: ['BTC', 'BTCTEST']
URL: "https://mempool.space",
SUPPORT: ["BTC", "BTCTEST"],
},
BLOCKCHAINCOM: {
URL: 'https://blockchain.info',
SUPPORT: ['BTC']
}
URL: "https://blockchain.info",
SUPPORT: ["BTC"],
},
BLOCKCYPHER: {
URL: "https://api.blockcypher.com/v1/btc/main",
SUPPORT: ["BTC"],
},
SOCHAIN: {
URL: "https://sochain.com/api/v2",
SUPPORT: ["BTC", "LTC", "DOGE", "BTCTEST", "DOGETEST", "LTCTEST"],
},
},
NETWORKS: {
BTC: 'BTC',
BTCTEST: 'BTCTEST',
LTC: 'LTC',
LTCTEST: 'LTCTEST',
DOGE: 'DOGE',
DOGETEST: 'DOGETEST'
BTC: "BTC",
BTCTEST: "BTCTEST",
LTC: "LTC",
LTCTEST: "LTCTEST",
DOGE: "DOGE",
DOGETEST: "DOGETEST",
},
FEE_RATE: {
BTC: 20,
LTC: 20,
DOGE: 2000,
BTCTEST: 20,
LTCTEST: 20,
DOGETEST: 2000
DOGETEST: 2000,
},
DUST: {
BTC: 546,
LTC: 1000,
DOGE: 1000000, // https://github.com/dogecoin/dogecoin/blob/v1.14.5/doc/fee-recommendation.md
BTCTEST: 546,
LTCTEST: 1000,
DOGETEST: 1000000 // https://github.com/dogecoin/dogecoin/blob/v1.14.5/doc/fee-recommendation.md
DOGETEST: 1000000, // https://github.com/dogecoin/dogecoin/blob/v1.14.5/doc/fee-recommendation.md
},
NETWORK_FEE_MAX: {
BTC: (250 * 100000), // 0.25 BTC
BTCTEST: (250 * 100000), // 0.25 BTCTEST
LTC: (50 * 100000), // 0.05 LTC
LTCTEST: (50 * 100000), // 0.05 LTCTEST
DOGE: (2 * 100000000), // 2.00 DOGE
DOGETEST: (2 * 100000000) // 2.00 DOGETEST
BTC: 250 * 100000, // 0.25 BTC
BTCTEST: 250 * 100000, // 0.25 BTCTEST
LTC: 50 * 100000, // 0.05 LTC
LTCTEST: 50 * 100000, // 0.05 LTCTEST
DOGE: 2 * 100000000, // 2.00 DOGE
DOGETEST: 2 * 100000000, // 2.00 DOGETEST
},
TX_BROADCAST_APPROVAL_TEXT: 'I have verified this transaction, and I want to broadcast it now'
}
TX_BROADCAST_APPROVAL_TEXT: "I have verified this transaction, and I want to broadcast it now",
};
Loading

0 comments on commit f96542b

Please sign in to comment.