Last active
April 30, 2018 14:46
-
-
Save cgcardona/295c4b2a05df9fe3a23e98990afbf9ac to your computer and use it in GitHub Desktop.
P2PKH script for sending from 1 to 999 addresses
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let mnemonic = ''; | |
| let seed = BITBOX.Mnemonic.mnemonicToSeedBuffer(mnemonic); | |
| let master = BITBOX.HDNode.fromSeedBuffer(seed, 'bitcoincash'); | |
| let byteCount = BITBOX.BitcoinCash.getByteCount({ P2PKH: 1 }, { P2PKH: 1000 }); | |
| let node = master.derivePath(`m/44'/145'/0'/0/0`); | |
| let keyPair = node.keyPair; | |
| let originalAmount = 4178855; | |
| let amount = originalAmount - byteCount; | |
| let txid = ''; | |
| let txb = new BITBOX.TransactionBuilder('bitcoincash'); | |
| txb.addInput(txid, 1, keyPair); | |
| for(let i = 0; i < 999; i++) { | |
| let childNode = master.derivePath(`m/44'/145'/0'/0/${i+1}`); | |
| txb.addOutput(BITBOX.HDNode.toLegacyAddress(childNode), Math.floor(amount / 1000)); | |
| } | |
| txb.sign(0, originalAmount); | |
| let tx = txb.build(); | |
| let hex = tx.toHex(); | |
| BITBOX.RawTransactions.sendRawTransaction(hex).then((result) => { console.log(result); }, (err) => { console.log(err); }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment