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


Java UnreadableWalletException类代码示例

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


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

示例1: extensions

import org.bitcoinj.wallet.UnreadableWalletException; //导入依赖的package包/类
@Test
public void extensions() throws Exception {
    myWallet.addExtension(new FooWalletExtension("com.whatever.required", true));
    Protos.Wallet proto = new WalletProtobufSerializer().walletToProto(myWallet);
    // Initial extension is mandatory: try to read it back into a wallet that doesn't know about it.
    try {
        new WalletProtobufSerializer().readWallet(PARAMS, null, proto);
        fail();
    } catch (UnreadableWalletException e) {
        assertTrue(e.getMessage().contains("mandatory"));
    }
    Wallet wallet = new WalletProtobufSerializer().readWallet(PARAMS,
            new WalletExtension[]{ new FooWalletExtension("com.whatever.required", true) },
            proto);
    assertTrue(wallet.getExtensions().containsKey("com.whatever.required"));

    // Non-mandatory extensions are ignored if the wallet doesn't know how to read them.
    Wallet wallet2 = new Wallet(PARAMS);
    wallet2.addExtension(new FooWalletExtension("com.whatever.optional", false));
    Protos.Wallet proto2 = new WalletProtobufSerializer().walletToProto(wallet2);
    Wallet wallet5 = new WalletProtobufSerializer().readWallet(PARAMS, null, proto2);
    assertEquals(0, wallet5.getExtensions().size());
}
 
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:24,代码来源:WalletProtobufSerializerTest.java

示例2: before

import org.bitcoinj.wallet.UnreadableWalletException; //导入依赖的package包/类
@Before
public void before() throws IOException, UnreadableWalletException, BlockStoreException, InterruptedException,
	InvalidLockTimeException, UserNotFoundException {
	System.setProperty("coinblesk.config.dir", "/tmp/lib/coinblesk" + (counter++));
	if (counter > 0) {
		walletService.init();
	}

	UserAccount userAccount = new UserAccount();
	userAccount.setBalance(BigDecimal.ONE).setCreationDate(new Date(1)).setDeleted(false).setEmail("[email protected]" +
		"" + ".test").setActivationEmailToken(null).setPassword(passwordEncoder.encode("test"));
	userAccountRepository.save(userAccount);

	accountService.createAccount(ecKeyClient);
	accountService.createTimeLockedAddress(ecKeyClient, Instant.now().plus(Duration.ofDays(7)).getEpochSecond());
}
 
开发者ID:coinblesk,项目名称:coinblesk-server,代码行数:17,代码来源:UserAccountServiceTest.java

示例3: initFromMasterSeed

import org.bitcoinj.wallet.UnreadableWalletException; //导入依赖的package包/类
private Wallet initFromMasterSeed(final String masterSeed) {
    try {
        final DeterministicSeed seed = getSeed(masterSeed);
        seed.check();
        return constructFromSeed(seed);
    } catch (final UnreadableWalletException | MnemonicException e) {
        throw new RuntimeException("Unable to create wallet. Seed is invalid");
    }
}
 
开发者ID:toshiapp,项目名称:toshi-headless-client,代码行数:10,代码来源:HDWallet.java

示例4: deriveKeysFromWallet

import org.bitcoinj.wallet.UnreadableWalletException; //导入依赖的package包/类
private void deriveKeysFromWallet(final Wallet wallet) {
    try {
        deriveIdentityKey(wallet);
        deriveReceivingKey(wallet);
    } catch (final UnreadableWalletException | IOException ex) {
        throw new RuntimeException("Error deriving keys: " + ex);
    }
}
 
开发者ID:toshiapp,项目名称:toshi-headless-client,代码行数:9,代码来源:HDWallet.java

示例5: deriveKeyFromWallet

import org.bitcoinj.wallet.UnreadableWalletException; //导入依赖的package包/类
private ECKey deriveKeyFromWallet(final Wallet wallet, final int iteration, final KeyChain.KeyPurpose keyPurpose) throws UnreadableWalletException, IOException {
    DeterministicKey key = null;
    for (int i = 0; i <= iteration; i++) {
        key = wallet.freshKey(keyPurpose);
    }

    if (key == null) {
        throw new IOException("Unable to derive key");
    }

    return ECKey.fromPrivate(key.getPrivKey());
}
 
开发者ID:toshiapp,项目名称:toshi-headless-client,代码行数:13,代码来源:HDWallet.java

示例6: tryLoadWalletFromFile

import org.bitcoinj.wallet.UnreadableWalletException; //导入依赖的package包/类
/***
 * This method tries to load a wallet from a file.
 * @param walletFile
 * @return null if loading failed, Wallet if it succeeded
 */
private Wallet tryLoadWalletFromFile(File walletFile) {
    Wallet w = null;
    try {
        w = Wallet.loadFromFile(walletFile);
    } catch (UnreadableWalletException e) {
        logger.warn(String.format("wallet file %s could not be read: %s", walletFile.toString(), e.getMessage()));
        e.printStackTrace();
    }
    return w;
}
 
开发者ID:IUNO-TDM,项目名称:PaymentService,代码行数:16,代码来源:Bitcoin.java

示例7: restoreWalletFromProtobuf

import org.bitcoinj.wallet.UnreadableWalletException; //导入依赖的package包/类
public static Wallet restoreWalletFromProtobuf(final InputStream is,
                                               final NetworkParameters expectedNetworkParameters) throws IOException {
    try {
        final Wallet wallet = new WalletProtobufSerializer().readWallet(is, true, null);

        if (!wallet.getParams().equals(expectedNetworkParameters))
            throw new IOException("bad wallet backup network parameters: " + wallet.getParams().getId());
        if (!wallet.isConsistent())
            throw new IOException("inconsistent wallet backup");

        return wallet;
    } catch (final UnreadableWalletException x) {
        throw new IOException("unreadable wallet", x);
    }
}
 
开发者ID:ehanoc,项目名称:xwallet,代码行数:16,代码来源:WalletUtils.java

示例8: testWallet

import org.bitcoinj.wallet.UnreadableWalletException; //导入依赖的package包/类
@Test
public void testWallet() throws UnreadableWalletException {
	long creationTimeSeconds = System.currentTimeMillis() / 1000;
	NetworkParameters params = MainNetParams.get();
	String [] MNEMONIC = new String [] {"sword","acquire","little","despair","wave","swear","during","expect","target","science","banana","eyebrow"};
	String RECEIVE_ADDRESS = "13w74gmmSjb2DWit5iRQbCKPZj89FkCidH";
	String CHANGE_ADDRESS = "1hF37FtrcSyEFkyxo2Q3541aGfWRqsuLV";
	
	List<String> fixedMnemonic = toMnemonic(MNEMONIC);
	printMnemonic(fixedMnemonic);
	
	DeterministicSeed ds2 = new DeterministicSeed(fixedMnemonic, null, "", creationTimeSeconds);
	
	KeyChainGroup fixedKeyChainFromSeed = new KeyChainGroup(params, ds2);
	Wallet fixedWallet = new Wallet(params, fixedKeyChainFromSeed);
	
	String fixedReceiveAddress = fixedWallet.currentReceiveAddress().toString();
	String fixedChangeAddress = fixedWallet.currentChangeAddress().toString();

	Assert.assertEquals(RECEIVE_ADDRESS, fixedReceiveAddress);
	Assert.assertEquals(CHANGE_ADDRESS, fixedChangeAddress);
	
	printAddress(fixedKeyChainFromSeed.currentAddress(KeyPurpose.AUTHENTICATION), "current auth address");
	printAddress(fixedKeyChainFromSeed.currentAddress(KeyPurpose.CHANGE), "current change address");
	printAddress(fixedKeyChainFromSeed.currentAddress(KeyPurpose.RECEIVE_FUNDS), "current receive address");
	printAddress(fixedKeyChainFromSeed.currentAddress(KeyPurpose.REFUND), "current refund address");
	
	for(int i = 0; i < 10; i++) {
		System.out.println("address[" + i + "]: "+ fixedKeyChainFromSeed.freshAddress(KeyPurpose.RECEIVE_FUNDS).toString());
	}
	
	System.out.println("---------------");
	
	String MNEMONIC_STRING = "sword acquire little despair wave swear during expect target science banana eyebrow";
	DeterministicSeed seed = new DeterministicSeed(MNEMONIC_STRING, null, "", creationTimeSeconds);
	Wallet wallet = Wallet.fromSeed(params, seed);
	
	System.out.println("wallet receive address: " + wallet.currentReceiveAddress().toString());
}
 
开发者ID:matthiaszimmermann,项目名称:bitcoin-paper-wallet,代码行数:40,代码来源:BitcoinjTest.java

示例9: restoreWalletFromProtobuf

import org.bitcoinj.wallet.UnreadableWalletException; //导入依赖的package包/类
public static Wallet restoreWalletFromProtobuf(final InputStream is,
        final NetworkParameters expectedNetworkParameters) throws IOException {
    try {
        final Wallet wallet = new WalletProtobufSerializer().readWallet(is, true, null);

        if (!wallet.getParams().equals(expectedNetworkParameters))
            throw new IOException("bad wallet backup network parameters: " + wallet.getParams().getId());
        if (!wallet.isConsistent())
            throw new IOException("inconsistent wallet backup");

        return wallet;
    } catch (final UnreadableWalletException x) {
        throw new IOException("unreadable wallet", x);
    }
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:16,代码来源:WalletUtils.java

示例10: createFromMasterSeed

import org.bitcoinj.wallet.UnreadableWalletException; //导入依赖的package包/类
public Single<HDWallet> createFromMasterSeed(final String masterSeed) {
    return Single.fromCallable(() -> {
        try {
            final DeterministicSeed seed = getSeed(masterSeed);
            seed.check();
            final Wallet wallet = constructFromSeed(seed);
            deriveKeysFromWallet(wallet);
            saveMasterSeedToStorage(masterSeed);
            return this;
        } catch (final UnreadableWalletException | MnemonicException e) {
            throw new InvalidMasterSeedException(e);
        }
    });
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:15,代码来源:HDWallet.java

示例11: deriveKeysFromWallet

import org.bitcoinj.wallet.UnreadableWalletException; //导入依赖的package包/类
private void deriveKeysFromWallet(final Wallet wallet) {
    try {
        deriveIdentityKey(wallet);
        derivePaymentKey(wallet);
    } catch (final UnreadableWalletException | IOException ex) {
        throw new RuntimeException("Error deriving keys: " + ex);
    }
}
 
开发者ID:toshiapp,项目名称:toshi-android-client,代码行数:9,代码来源:HDWallet.java

示例12: getSeed

import org.bitcoinj.wallet.UnreadableWalletException; //导入依赖的package包/类
private DeterministicSeed getSeed(final String masterSeed) throws UnreadableWalletException {
    return new DeterministicSeed(masterSeed, null, "", 0);
}
 
开发者ID:toshiapp,项目名称:toshi-headless-client,代码行数:4,代码来源:HDWallet.java

示例13: deriveIdentityKey

import org.bitcoinj.wallet.UnreadableWalletException; //导入依赖的package包/类
private void deriveIdentityKey(final Wallet wallet) throws IOException, UnreadableWalletException {
    this.identityKey = deriveKeyFromWallet(wallet, 0, KeyChain.KeyPurpose.AUTHENTICATION);
}
 
开发者ID:toshiapp,项目名称:toshi-headless-client,代码行数:4,代码来源:HDWallet.java

示例14: deriveReceivingKey

import org.bitcoinj.wallet.UnreadableWalletException; //导入依赖的package包/类
private void deriveReceivingKey(final Wallet wallet) throws IOException, UnreadableWalletException {
    this.paymentKey = deriveKeyFromWallet(wallet, 0, KeyChain.KeyPurpose.RECEIVE_FUNDS);
}
 
开发者ID:toshiapp,项目名称:toshi-headless-client,代码行数:4,代码来源:HDWallet.java

示例15: versions

import org.bitcoinj.wallet.UnreadableWalletException; //导入依赖的package包/类
@Test(expected = UnreadableWalletException.FutureVersion.class)
public void versions() throws Exception {
    Protos.Wallet.Builder proto = Protos.Wallet.newBuilder(new WalletProtobufSerializer().walletToProto(myWallet));
    proto.setVersion(2);
    new WalletProtobufSerializer().readWallet(PARAMS, null, proto.build());
}
 
开发者ID:Grant-Redmond,项目名称:cryptwallet,代码行数:7,代码来源:WalletProtobufSerializerTest.java


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