当前位置: 首页>>代码示例>>Java>>正文


Java DeterministicSeed类代码示例

本文整理汇总了Java中org.bitcoinj.wallet.DeterministicSeed的典型用法代码示例。如果您正苦于以下问题:Java DeterministicSeed类的具体用法?Java DeterministicSeed怎么用?Java DeterministicSeed使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DeterministicSeed类属于org.bitcoinj.wallet包,在下文中一共展示了DeterministicSeed类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.bitcoinj.wallet.DeterministicSeed; //导入依赖的package包/类
/**
 *
 * @param callbacks
 */
@Override
public void execute(CoinActionCallback<CurrencyCoin>... callbacks) {
    _callbacks = callbacks;
   // reinitWallet();

    final DeterministicSeed seed = createDeterministicSeed();

    _bitcoinManager.getCurrencyCoin().getWalletManager().addListener(new Service.Listener() {
        @Override
        public void terminated(Service.State from) {
            super.terminated(from);
            WalletAppKit appKit = setupWallet();

            appKit.setDownloadListener(BitcoinRecoverAction.this)
                    .setBlockingStartup(false)
                    .setUserAgent(ServiceConsts.SERVICE_APP_NAME, "0.1")
                    .restoreWalletFromSeed(seed);

            _bitcoinManager.getCurrencyCoin().setWalletManager(appKit);
            _bitcoinManager.getCurrencyCoin().getWalletManager().startAsync();
        }
    }, Executors.newSingleThreadExecutor());

    _bitcoinManager.getCurrencyCoin().getWalletManager().stopAsync();
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:30,代码来源:BitcoinRecoverAction.java

示例2: Bitcoin

import org.bitcoinj.wallet.DeterministicSeed; //导入依赖的package包/类
private Bitcoin() {
    BriefLogFormatter.initWithSilentBitcoinJ();
    ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger)LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
    rootLogger.setLevel(Level.toLevel("info"));

    // Context.enableStrictMode();
    final NetworkParameters params = TestNet3Params.get();
    context = new Context(params);
    Context.propagate(context);

    // read system property to check if broken wallet shall be recovered from backup automatically
    automaticallyRecoverBrokenWallet = System.getProperty("automaticallyRecoverBrokenWallet").equalsIgnoreCase("true");

    // prepare (unused) random seed to save time when constructing coupon wallets for invoices
    byte[] seed = new byte[DeterministicSeed.DEFAULT_SEED_ENTROPY_BITS/8];
    List<String> mnemonic = new ArrayList<>(0);
    couponRandomSeed = new DeterministicSeed(seed, mnemonic, MnemonicCode.BIP39_STANDARDISATION_TIME_SECS);
}
 
开发者ID:IUNO-TDM,项目名称:PaymentService,代码行数:19,代码来源:Bitcoin.java

示例3: setupWalletKit

import org.bitcoinj.wallet.DeterministicSeed; //导入依赖的package包/类
public void setupWalletKit(@Nullable DeterministicSeed seed) {
    // If seed is non-null it means we are restoring from backup.
    bitcoin = new WalletAppKit(params, new File("."), WALLET_FILE_NAME) {
        @Override
        protected void onSetupCompleted() {
            // Don't make the user wait for confirmations for now, as the intention is they're sending it
            // their own money!
            bitcoin.wallet().allowSpendingUnconfirmedTransactions();
            Platform.runLater(controller::onBitcoinSetup);
        }
    };
    // Now configure and start the appkit. This will take a second or two - we could show a temporary splash screen
    // or progress widget to keep the user engaged whilst we initialise, but we don't.
    if (params == RegTestParams.get()) {
        bitcoin.connectToLocalHost();   // You should run a regtest mode bitcoind locally.
    } else if (params == TestNet3Params.get()) {
        // As an example!
        bitcoin.useTor();
        // bitcoin.setDiscovery(new HttpDiscovery(params, URI.create("http://localhost:8080/peers"), ECKey.fromPublicOnly(BaseEncoding.base16().decode("02cba68cfd0679d10b186288b75a59f9132b1b3e222f6332717cb8c4eb2040f940".toUpperCase()))));
    }
    bitcoin.setDownloadListener(controller.progressBarUpdater())
           .setBlockingStartup(false)
           .setUserAgent(APP_NAME, "1.0");
    if (seed != null)
        bitcoin.restoreWalletFromSeed(seed);
}
 
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:27,代码来源:Main.java

示例4: testSeeds

import org.bitcoinj.wallet.DeterministicSeed; //导入依赖的package包/类
@Test
public void testSeeds() throws MnemonicLengthException, MnemonicWordException, MnemonicChecksumException {
	int bits = 128;
	byte [] entropy = getEntropy(bits);
	List<String> mnemonic = MnemonicCode.INSTANCE.toMnemonic(entropy);		
	String passphrase = "";
	long creationTimeSeconds = System.currentTimeMillis() / 1000;

	DeterministicSeed ds1 = new DeterministicSeed(entropy, passphrase, creationTimeSeconds);
	DeterministicSeed ds2 = new DeterministicSeed(mnemonic, null, passphrase, creationTimeSeconds);

	byte [] ds1seed = ds1.getSeedBytes();
	byte [] ds2seed = ds2.getSeedBytes();

	Assert.assertArrayEquals(ds1seed, ds2seed);

	List<String> ds1mnemonic = ds1.getMnemonicCode();
	List<String> ds2mnemonic = ds2.getMnemonicCode();

	assertEquals(mnemonic, ds1mnemonic);
	assertEquals(ds1mnemonic, ds2mnemonic);

	printMnemonic(mnemonic);
}
 
开发者ID:matthiaszimmermann,项目名称:bitcoin-paper-wallet,代码行数:25,代码来源:BitcoinjTest.java

示例5: testHDAccountNxt

import org.bitcoinj.wallet.DeterministicSeed; //导入依赖的package包/类
@Test
public void testHDAccountNxt() throws MnemonicException, UnreadableWalletException {
    DeterministicSeed seed = new DeterministicSeed(recoveryPhrase, null, "", 0);
    DeterministicKey masterKey = HDKeyDerivation.createMasterPrivateKey(seed.getSeedBytes());
    DeterministicHierarchy hierarchy = new DeterministicHierarchy(masterKey);
    DeterministicKey entropy = hierarchy.get(NxtMain.get().getBip44Path(0), false, true);

    NxtFamilyKey nxtKey = new NxtFamilyKey(entropy, null, null);
    byte[] privateKey = nxtKey.getPrivateKey();
    byte[] publicKey = nxtKey.getPublicKey();
    NxtAddress address = new NxtAddress(NxtMain.get(), publicKey);

    assertArrayEquals(nxtPrivateKey, privateKey);
    assertArrayEquals(nxtPublicKey, publicKey);
    assertEquals(nxtRsAddress, address.toString());
    assertEquals(nxtAccountId, address.getAccountId());
}
 
开发者ID:filipnyquist,项目名称:lbry-android,代码行数:18,代码来源:NxtFamilyTest.java

示例6: setUp

import org.bitcoinj.wallet.DeterministicSeed; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    params = NetworkParameters.fromID(NetworkParameters.ID_UNITTESTNET);
    mapper = new ObjectMapper();

    DeterministicSeed seed = new DeterministicSeed("correct battery horse staple", null, "", 0);
    DeterministicKeyChain chain =
            DeterministicKeyChain.builder()
                    .seed(seed)
                    .build();
    KeyChainGroup group = new KeyChainGroup(params);
    group.addAndActivateHDChain(chain);
    wallet = new SmartWallet(params, group);
    wallet.setKeychainLookaheadSize(10);

    control = EasyMock.createStrictControl();
    client = control.createMock(StratumClient.class);
    expect(client.getConnectedAddresses()).andStubReturn(Lists.newArrayList(new InetSocketAddress(InetAddress.getLocalHost(), 0)));
    expect(client.getPeerVersion()).andStubReturn("1.0");
    store = control.createMock(HeadersStore.class);
    stratumChain = control.createMock(StratumChain.class);
    expect(stratumChain.getPeerHeight()).andStubReturn(100L);
    expect(store.get(340242)).andStubReturn(params.getGenesisBlock().cloneAsHeader());
    multiWallet = new ElectrumMultiWallet(wallet, BASE_DIRECTORY);
    multiWallet.start(client, stratumChain, store);
}
 
开发者ID:devrandom,项目名称:java-stratum,代码行数:27,代码来源:ElectrumMultiWalletTest.java

示例7: setupWalletKit

import org.bitcoinj.wallet.DeterministicSeed; //导入依赖的package包/类
public void setupWalletKit (@Nullable DeterministicSeed seed) {
    // If seed is non-null it means we are restoring from backup.
    bitcoin = new WalletAppKit(params, new File("."), APP_NAME + "-" + params.getPaymentProtocolId() + CLIENTID) {
        @Override
        protected void onSetupCompleted () {
            // Don't make the user wait for confirmations for now, as the intention is they're sending it
            // their own money!
            bitcoin.wallet().allowSpendingUnconfirmedTransactions();
            Platform.runLater(controller::onBitcoinSetup);

        }
    };

    bitcoin.setDownloadListener(controller.progressBarUpdater())
            .setBlockingStartup(false)
            .setUserAgent(APP_NAME, "1.0");
    if (seed != null) {
        bitcoin.restoreWalletFromSeed(seed);
    }

}
 
开发者ID:matsjj,项目名称:thundernetwork,代码行数:22,代码来源:Main.java

示例8: testSaveAndRetreiveMnemonic

import org.bitcoinj.wallet.DeterministicSeed; //导入依赖的package包/类
@Test
public void testSaveAndRetreiveMnemonic() {
	String mnemonicStr = "device seven always major morning present level order decline pizza order economy";
	String[] mnemonic = mnemonicStr.split(" ");
	List<String> mnemonicList = new ArrayList<String>(Arrays.asList(mnemonic));
	WalletCore wc = new WalletCore();
	MockingContext c = new MockingContext(getContext());
	
	wc.saveMnemonic(c, mnemonic);
	List<String> mnemonicListResult = null;
	String mnemonicStrResult = null;
	DeterministicSeed dsResult = null;
	try {
		mnemonicListResult = wc.getMnemonic(c);
		mnemonicStrResult = wc.getMnemonicString(c);
		dsResult = wc.getDeterministicSeed(c);
	} catch (NoSeedOrMnemonicsFound e) {
		e.printStackTrace();
		assertTrue(false);
	} 
	
	assertTrue(TestUtil.listEquals(mnemonicList, mnemonicListResult));
	assertTrue(mnemonicStrResult.equals(mnemonicStr));
	assertTrue(TestUtil.listEquals(dsResult.getMnemonicCode(), mnemonicList));
}
 
开发者ID:BitcoinAuthenticator,项目名称:BitcoinAuthenticator-Android,代码行数:26,代码来源:WalletCoreTest.java

示例9: restoreSeedWords

import org.bitcoinj.wallet.DeterministicSeed; //导入依赖的package包/类
public static void restoreSeedWords(DeterministicSeed seed, WalletsManager walletsManager, File storageDir) {
    try {
        FileUtil.renameFile(new File(storageDir, "AddressEntryList"), new File(storageDir, "AddressEntryList_wallet_restore_" + System.currentTimeMillis()));
    } catch (Throwable t) {
        new Popup<>().error(Res.get("error.deleteAddressEntryListFailed", t)).show();
    }
    walletsManager.restoreSeedWords(
            seed,
            () -> UserThread.execute(() -> {
                log.info("Wallets restored with seed words");
                new Popup<>().feedback(Res.get("seed.restore.success"))
                        .useShutDownButton()
                        .show();
            }),
            throwable -> UserThread.execute(() -> {
                log.error(throwable.toString());
                new Popup<>().error(Res.get("seed.restore.error", Res.get("shared.errorMessageInline", throwable)))
                        .show();
            }));
}
 
开发者ID:bisq-network,项目名称:exchange,代码行数:21,代码来源:GUIUtil.java

示例10: restoreSeedWords

import org.bitcoinj.wallet.DeterministicSeed; //导入依赖的package包/类
public void restoreSeedWords(@Nullable DeterministicSeed seed, ResultHandler resultHandler, ExceptionHandler exceptionHandler) {
    checkNotNull(seed, "Seed must be not be null.");

    backupWallets();

    Context ctx = Context.get();
    new Thread(() -> {
        try {
            Context.propagate(ctx);
            walletConfig.stopAsync();
            walletConfig.awaitTerminated();
            initialize(seed, resultHandler, exceptionHandler);
        } catch (Throwable t) {
            t.printStackTrace();
            log.error("Executing task failed. " + t.getMessage());
        }
    }, "RestoreBTCWallet-%d").start();
}
 
开发者ID:bisq-network,项目名称:exchange,代码行数:19,代码来源:WalletsSetup.java

示例11: setBackupMode

import org.bitcoinj.wallet.DeterministicSeed; //导入依赖的package包/类
public void setBackupMode(Wallet wallet, DeterministicSeed seed){
 backupMode = true;
 
 this.wallet= wallet;
 walletSeed = seed;
 List<String> mnemoniclst = walletSeed.getMnemonicCode();
 mnemonic = Joiner.on(" ").join(mnemoniclst);
 lblSeed.setText(mnemonic);
 
 MainPane.setVisible(false);
 SetPasswordPane.setVisible(false);
 BackupNewWalletPane.setVisible(true);
 
 btnBack2.setVisible(false);
 btnContinue2.setVisible(false);
 ckSeed.setVisible(false);
 btnSave.setDisable(false);
}
 
开发者ID:BitcoinAuthenticator,项目名称:Wallet,代码行数:19,代码来源:StartupController.java

示例12: createWallet

import org.bitcoinj.wallet.DeterministicSeed; //导入依赖的package包/类
private void createWallet(@Nullable DeterministicSeed seed) throws IOException{
 String filePath = appParams.getApplicationDataFolderAbsolutePath() + appParams.getAppName() + ".wallet";
 File f = new File(filePath);
 assert(f.exists() == false);
 if(seed == null){
	//Generate a new Seed
	 SecureRandom secureRandom = null;
	 try {secureRandom = SecureRandom.getInstance("SHA1PRNG");} 
	 catch (NoSuchAlgorithmException e) {e.printStackTrace();}
	 //byte[] bytes = new byte[16];
	 //secureRandom.nextBytes(bytes);
	 walletSeed = new DeterministicSeed(secureRandom, 8 * 16, "", Utils.currentTimeSeconds());
 }
 else
	 walletSeed = seed;
  
 // set wallet
 wallet = Wallet.fromSeed(params,walletSeed);
 wallet.setKeychainLookaheadSize(0);
 wallet.autosaveToFile(f, 200, TimeUnit.MILLISECONDS, null);
}
 
开发者ID:BitcoinAuthenticator,项目名称:Wallet,代码行数:22,代码来源:StartupController.java

示例13: createPaperWallet

import org.bitcoinj.wallet.DeterministicSeed; //导入依赖的package包/类
@SuppressWarnings("restriction")
public static void createPaperWallet(String mnemonic, DeterministicSeed seed, long creationTime) throws IOException{
	PaperWalletQR maker = new PaperWalletQR();
	BufferedImage bi = maker.generatePaperWallet(mnemonic, seed, creationTime);
		
       // save
       String filepath = new java.io.File( "." ).getCanonicalPath() + "/" + "paperwallet" + ".png";
	File wallet = new File(filepath);
	FileChooser fileChooser = new FileChooser();
	fileChooser.setTitle("Save Paper Wallet");
	fileChooser.setInitialFileName("paperwallet.png");
	File outputfile = fileChooser.showSaveDialog(Main.startup);   
	if(outputfile != null)
		ImageIO.write(bi, "png", outputfile);        
      
}
 
开发者ID:BitcoinAuthenticator,项目名称:Wallet,代码行数:17,代码来源:PaperWalletController.java

示例14: testSaveWalletSeedShouldSaveWalletToDiskAndReloadItFromMSeed

import org.bitcoinj.wallet.DeterministicSeed; //导入依赖的package包/类
public void testSaveWalletSeedShouldSaveWalletToDiskAndReloadItFromMSeed() throws IOException, UnreadableWalletException {
	controller = new WalletController(params, testDirectory, 1);
	controller.setupWalletKit(null);
	
       assertNotNull(controller.getRecieveAddress(false));
       //then save a new wallet file. this one is unencrypted!
       System.out.println("Saving Wallet");
       String seedcode = controller.saveWalletSeed(testWalletDirectory+"testWallet1");
       assertNotNull(seedcode);
       System.out.println(seedcode);
       
       //Load from file 
       String passphrase = "";
       Long creationtime = System.currentTimeMillis();
       
       DeterministicSeed seed = new DeterministicSeed(seedcode, null, passphrase, creationtime);

	WalletController loadedController = new WalletController(params, testDirectory, 1);
	loadedController.setupWalletKit(seed);
	loadedController.getWallet().toString();
       
	assertEquals(controller.getWallet().getWatchingKey(), loadedController.getWallet().getWatchingKey());
       controller.shutdown();
       loadedController.shutdown();
       cleanup();
}
 
开发者ID:JohnnyCryptoCoin,项目名称:speciebox,代码行数:27,代码来源:WalletControllerTest.java

示例15: setupWalletKit

import org.bitcoinj.wallet.DeterministicSeed; //导入依赖的package包/类
public void setupWalletKit(@Nullable DeterministicSeed seed) {
    // If seed is non-null it means we are restoring from backup.
    bitcoin = new WalletAppKit(params, new File("."), WALLET_FILE_NAME) {
        @Override
        protected void onSetupCompleted() {
            // Don't make the user wait for confirmations for now, as the intention is they're sending it
            // their own money!
            bitcoin.wallet().allowSpendingUnconfirmedTransactions();
            Platform.runLater(controller::onBitcoinSetup);
        }
    };
    // Now configure and start the appkit. This will take a second or two - we could show a temporary splash screen
    // or progress widget to keep the user engaged whilst we initialise, but we don't.
    if (params == RegTestParams.get()) {
        bitcoin.connectToLocalHost();   // You should run a regtest mode bitcoind locally.
    }
    bitcoin.setDownloadListener(controller.progressBarUpdater())
           .setBlockingStartup(false)
           .setUserAgent(APP_NAME, "1.0");
    if (seed != null)
        bitcoin.restoreWalletFromSeed(seed);
}
 
开发者ID:bitcoinj,项目名称:bitcoinj,代码行数:23,代码来源:Main.java


注:本文中的org.bitcoinj.wallet.DeterministicSeed类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。