Search in sources :

Example 1 with DumpedPrivateKey

use of com.sparrowwallet.drongo.crypto.DumpedPrivateKey in project sparrow by sparrowwallet.

the class PrivateKeySweepDialog method createTransaction.

private void createTransaction() {
    try {
        DumpedPrivateKey privateKey = getPrivateKey();
        ScriptType scriptType = keyScriptType.getValue();
        Address fromAddress = scriptType.getAddress(privateKey.getKey());
        Address destAddress = getToAddress();
        ElectrumServer.AddressUtxosService addressUtxosService = new ElectrumServer.AddressUtxosService(fromAddress);
        addressUtxosService.setOnSucceeded(successEvent -> {
            createTransaction(privateKey.getKey(), scriptType, addressUtxosService.getValue(), destAddress);
        });
        addressUtxosService.setOnFailed(failedEvent -> {
            log.error("Error retrieving outputs for address " + fromAddress, failedEvent.getSource().getException());
            AppServices.showErrorDialog("Error retrieving outputs for address", failedEvent.getSource().getException().getMessage());
        });
        addressUtxosService.start();
    } catch (Exception e) {
        log.error("Error creating sweep transaction", e);
    }
}
Also used : ElectrumServer(com.sparrowwallet.sparrow.net.ElectrumServer) Address(com.sparrowwallet.drongo.address.Address) DumpedPrivateKey(com.sparrowwallet.drongo.crypto.DumpedPrivateKey) InvalidAddressException(com.sparrowwallet.drongo.address.InvalidAddressException) IOException(java.io.IOException)

Example 2 with DumpedPrivateKey

use of com.sparrowwallet.drongo.crypto.DumpedPrivateKey in project sparrow by sparrowwallet.

the class PrivateKeySweepDialog method setFromAddress.

private void setFromAddress() {
    DumpedPrivateKey privateKey = getPrivateKey();
    ScriptType scriptType = keyScriptType.getValue();
    Address address = scriptType.getAddress(privateKey.getKey());
    keyAddress.setText(address.toString());
}
Also used : Address(com.sparrowwallet.drongo.address.Address) DumpedPrivateKey(com.sparrowwallet.drongo.crypto.DumpedPrivateKey)

Aggregations

Address (com.sparrowwallet.drongo.address.Address)2 DumpedPrivateKey (com.sparrowwallet.drongo.crypto.DumpedPrivateKey)2 InvalidAddressException (com.sparrowwallet.drongo.address.InvalidAddressException)1 ElectrumServer (com.sparrowwallet.sparrow.net.ElectrumServer)1 IOException (java.io.IOException)1