File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -87,8 +87,9 @@ The below examples are implemented as integration tests, they should be very eas
8787
8888- [ Generate a random address] ( https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/basic.js#L8 )
8989- [ Generate a address from a SHA256 hash] ( https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/basic.js#L20 )
90- - [ Import an address via WIF] ( https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/basic.js#L29 )
91- - [ Create a Transaction] ( https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/basic.js#L36 )
90+ - [ Generate a address and WIF for Litecoin] ( https://github.com/bitcoin/bitcoinjs-lib/blob/master/test/integration/basic.js#L29 )
91+ - [ Import an address via WIF] ( https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/basic.js#L43 )
92+ - [ Create a Transaction] ( https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/basic.js#L50 )
9293- [ Sign a Bitcoin message] ( https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/advanced.js#L9 )
9394- [ Verify a Bitcoin message] ( https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/advanced.js#L17 )
9495- [ Create an OP RETURN transaction] ( https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/integration/advanced.js#L24 )
Original file line number Diff line number Diff line change @@ -26,6 +26,20 @@ describe('bitcoinjs-lib (basic)', function () {
2626 assert . equal ( address , '1C7zdTfnkzmr13HfA2vNm5SJYRK6nEKyq8' )
2727 } )
2828
29+ it ( 'can generate a random keypair for alternative networks' , function ( ) {
30+ // for testing only
31+ function rng ( ) { return new Buffer ( 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz' ) }
32+
33+ var litecoin = bitcoin . networks . litecoin
34+
35+ var keyPair = bitcoin . ECPair . makeRandom ( { network : litecoin , rng : rng } )
36+ var wif = keyPair . toWIF ( )
37+ var address = keyPair . getAddress ( ) . toString ( )
38+
39+ assert . equal ( address , 'LZJSxZbjqJ2XVEquqfqHg1RQTDdfST5PTn' )
40+ assert . equal ( wif , 'T7A4PUSgTDHecBxW1ZiYFrDNRih2o7M8Gf9xpoCgudPF9gDiNvuS' )
41+ } )
42+
2943 it ( 'can import an address via WIF' , function ( ) {
3044 var keyPair = bitcoin . ECPair . fromWIF ( 'Kxr9tQED9H44gCmp6HAdmemAzU3n84H3dGkuWTKvE23JgHMW8gct' )
3145 var address = keyPair . getAddress ( ) . toString ( )
You can’t perform that action at this time.
0 commit comments