Send from Simple Wallet throw IllegalStateException: doesn't support deterministic chains

169 views
Skip to first unread message

Juan Ibarra

unread,
Mar 23, 2019, 3:03:42 PM3/23/19
to bitcoinj
Hello, I try to send from Wallet.createBasic and importKey, this work good to sync, but when try to send the logs throw this:

java.lang.IllegalStateException: doesn't support deterministic chains
    at com.google.common.base.Preconditions.checkState(Preconditions.java:510)
    at org.bitcoinj.wallet.KeyChainGroup.getActiveKeyChain(KeyChainGroup.java:426)
    at org.bitcoinj.wallet.KeyChainGroup.currentAddress(KeyChainGroup.java:308)
    at org.bitcoinj.wallet.Wallet.currentAddress(Wallet.java:607)
    at org.bitcoinj.wallet.Wallet.currentChangeAddress(Wallet.java:861)
    at org.bitcoinj.wallet.Wallet.calculateFee(Wallet.java:5062)
    at org.bitcoinj.wallet.Wallet.completeTx(Wallet.java:4151)
    at org.bitcoinj.wallet.Wallet.sendCoinsOffline(Wallet.java:3948)
    at org.bitcoinj.wallet.Wallet.sendCoins(Wallet.java:4015)
    at org.bitcoinj.wallet.Wallet.sendCoins(Wallet.java:3984)

the dependency its the branch master (0.16-SNAPSHOT)

the Wif
cVYU7EDwyHdzhtz26v5REiLmq3zHpveb83LyWSpSYhf7BoaKY6mp

The unit test

@Test
public void TransferWallet0151() throws Exception {
Context.propagate(new Context(netParams));

File chainFileSeed = new File("seed.spvchain");
File chainFile = new File(System.currentTimeMillis() + ".spvchain");
byte[] allBytes = Files.readAllBytes(chainFileSeed.toPath());
Files.write(chainFile.toPath(), allBytes);

Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -1);
Date time = calendar.getTime();

ECKey ecKey = DumpedPrivateKey.fromBase58(netParams, privateKeyAsWiF).getKey();
ecKey.setCreationTimeSeconds(time.getTime() / 1000);
Wallet wallet = Wallet.createBasic(netParams);
wallet.importKey(ecKey);

BlockStore blockStore = new SPVBlockStore(netParams, chainFile);
BlockChain chain = new BlockChain(netParams, blockStore);
final PeerGroup peerGroup = new PeerGroup(netParams, chain);

peerGroup.addPeerDiscovery(new DnsDiscovery(netParams));
peerGroup.setFastCatchupTimeSecs(time.getTime());

peerGroup.addWallet(wallet);
chain.addWallet(wallet);

peerGroup.start();
peerGroup.downloadBlockChain();

Address to = LegacyAddress.fromBase58(netParams, "mtGedFZpWkN5JHHMuG2q4JPtUneypAUAd2");

Coin coin = wallet.getBalance();
Wallet.SendResult sendResult = null;

while (true) try {
sendResult = wallet.sendCoins(peerGroup, to, coin);
break;
} catch (InsufficientMoneyException e) {
assert e.missing != null;
coin = coin.minus(e.missing);
} catch (Exception e) {
e.printStackTrace();
break;
}

peerGroup.stop();

chainFile.delete();
System.out.println("-------->");
System.out.println(LegacyAddress.fromKey(netParams, ecKey));
System.out.println("-------->");
System.out.println(sendResult);
System.out.println("-------->");
System.out.println(wallet);
wallet.cleanup();
}
BitcoinJ0151.java

Andreas Schildbach

unread,
Mar 24, 2019, 7:53:38 AM3/24/19
to bitc...@googlegroups.com
I filed this as an issue at:

https://github.com/bitcoinj/bitcoinj/issues/1747
> --
> You received this message because you are subscribed to the Google
> Groups "bitcoinj" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to bitcoinj+u...@googlegroups.com
> <mailto:bitcoinj+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.


Reply all
Reply to author
Forward
0 new messages