org.bitcoinj.wallet.UnreadableWalletException Java Examples
The following examples show how to use
org.bitcoinj.wallet.UnreadableWalletException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WalletProtobufSerializerTest.java From bcm-android with GNU General Public License v3.0 | 6 votes |
@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(UNITTEST, null, proto); fail(); } catch (UnreadableWalletException e) { assertTrue(e.getMessage().contains("mandatory")); } Wallet wallet = new WalletProtobufSerializer().readWallet(UNITTEST, 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(UNITTEST); wallet2.addExtension(new FooWalletExtension("com.whatever.optional", false)); Protos.Wallet proto2 = new WalletProtobufSerializer().walletToProto(wallet2); Wallet wallet5 = new WalletProtobufSerializer().readWallet(UNITTEST, null, proto2); assertEquals(0, wallet5.getExtensions().size()); }
Example #2
Source File: WalletProtobufSerializerTest.java From green_android with GNU General Public License v3.0 | 6 votes |
@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()); }
Example #3
Source File: WalletProtobufSerializerTest.java From GreenBits with GNU General Public License v3.0 | 6 votes |
@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()); }
Example #4
Source File: BisqKeyChainFactory.java From bisq-core with GNU Affero General Public License v3.0 | 5 votes |
@Override public DeterministicKeyChain makeWatchingKeyChain(Protos.Key key, Protos.Key firstSubKey, DeterministicKey accountKey, boolean isFollowingKey, boolean isMarried) throws UnreadableWalletException { ImmutableList<ChildNumber> accountPath = useBitcoinDeterministicKeyChain ? BtcDeterministicKeyChain.BIP44_BTC_ACCOUNT_PATH : BisqDeterministicKeyChain.BIP44_BSQ_ACCOUNT_PATH; if (!accountKey.getPath().equals(accountPath)) throw new UnreadableWalletException("Expecting account key but found key with path: " + HDUtils.formatPath(accountKey.getPath())); return useBitcoinDeterministicKeyChain ? new BtcDeterministicKeyChain(accountKey, isFollowingKey) : new BisqDeterministicKeyChain(accountKey, isFollowingKey); }
Example #5
Source File: GetCredentials.java From Android-Wallet-Token-ERC20 with Apache License 2.0 | 5 votes |
public Credentials FromSeed(String seedCode, String passwordWallet) throws UnreadableWalletException { DeterministicSeed seed = new DeterministicSeed(seedCode, null, passwordWallet, 1409478661L); DeterministicKeyChain chain = DeterministicKeyChain.builder().seed(seed).build(); List<ChildNumber> keyPath = HDUtils.parsePath("M/44H/60H/0H/0/0"); DeterministicKey key = chain.getKeyByPath(keyPath, true); BigInteger privKey = key.getPrivKey(); return Credentials.create(ECKeyPair.create(privKey)); }
Example #6
Source File: BisqKeyChainFactory.java From bisq with GNU Affero General Public License v3.0 | 5 votes |
@Override public DeterministicKeyChain makeWatchingKeyChain(Protos.Key key, Protos.Key firstSubKey, DeterministicKey accountKey, boolean isFollowingKey, boolean isMarried) throws UnreadableWalletException { ImmutableList<ChildNumber> accountPath = useBitcoinDeterministicKeyChain ? BtcDeterministicKeyChain.BIP44_BTC_ACCOUNT_PATH : BisqDeterministicKeyChain.BIP44_BSQ_ACCOUNT_PATH; if (!accountKey.getPath().equals(accountPath)) throw new UnreadableWalletException("Expecting account key but found key with path: " + HDUtils.formatPath(accountKey.getPath())); return useBitcoinDeterministicKeyChain ? new BtcDeterministicKeyChain(accountKey, isFollowingKey) : new BisqDeterministicKeyChain(accountKey, isFollowingKey); }
Example #7
Source File: WalletProtobufSerializerTest.java From bcm-android with GNU General Public License v3.0 | 4 votes |
@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(UNITTEST, null, proto.build()); }
Example #8
Source File: WalletProtobufSerializerTest.java From green_android with GNU General Public License v3.0 | 4 votes |
@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()); }
Example #9
Source File: WalletProtobufSerializerTest.java From GreenBits with GNU General Public License v3.0 | 4 votes |
@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()); }