private static void deleteKey() { String pubkey = (String) options.valueOf("pubkey"); String addr = (String) options.valueOf("addr"); if (pubkey == null && addr == null) { System.err.println("One of --pubkey or --addr must be specified."); return; } ECKey key = null; if (pubkey != null) { key = wallet.findKeyFromPubKey(Hex.decode(pubkey)); } else { try { Address address = new Address(wallet.getParams(), addr); key = wallet.findKeyFromPubHash(address.getHash160()); } catch (AddressFormatException e) { System.err.println( addr + " does not parse as a Bitcoin address of the right network parameters."); return; } } if (key == null) { System.err.println("Wallet does not seem to contain that key."); return; } wallet.removeKey(key); }