Craig Raw
4 years ago
9 changed files with 236 additions and 12 deletions
@ -1 +1 @@ |
|||
Subproject commit ee49ddd94bdfec1e87d334f17833a63382958790 |
|||
Subproject commit 10ebfe463d504f39be2aacec41d48c2cf5ba4c56 |
@ -0,0 +1,39 @@ |
|||
package com.sparrowwallet.sparrow.control; |
|||
|
|||
import com.google.common.eventbus.Subscribe; |
|||
import com.sparrowwallet.drongo.KeyDerivation; |
|||
import com.sparrowwallet.drongo.wallet.Wallet; |
|||
import com.sparrowwallet.sparrow.EventManager; |
|||
import com.sparrowwallet.sparrow.event.MessageSignedEvent; |
|||
import com.sparrowwallet.sparrow.io.Device; |
|||
|
|||
import java.util.List; |
|||
|
|||
public class DeviceSignMessageDialog extends DeviceDialog<String> { |
|||
private final Wallet wallet; |
|||
private final String message; |
|||
private final KeyDerivation keyDerivation; |
|||
|
|||
public DeviceSignMessageDialog(List<String> operationFingerprints, Wallet wallet, String message, KeyDerivation keyDerivation) { |
|||
super(operationFingerprints); |
|||
this.wallet = wallet; |
|||
this.message = message; |
|||
this.keyDerivation = keyDerivation; |
|||
EventManager.get().register(this); |
|||
setOnCloseRequest(event -> { |
|||
EventManager.get().unregister(this); |
|||
}); |
|||
} |
|||
|
|||
@Override |
|||
protected DevicePane getDevicePane(Device device) { |
|||
return new DevicePane(wallet, message, keyDerivation, device); |
|||
} |
|||
|
|||
@Subscribe |
|||
public void messageSigned(MessageSignedEvent event) { |
|||
if(wallet == event.getWallet()) { |
|||
setResult(event.getSignature()); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,25 @@ |
|||
package com.sparrowwallet.sparrow.event; |
|||
|
|||
import com.sparrowwallet.drongo.wallet.Wallet; |
|||
|
|||
/** |
|||
* This event is used by the DeviceSignMessageDialog to indicate that a USB device has signed a message |
|||
* |
|||
*/ |
|||
public class MessageSignedEvent { |
|||
private final Wallet wallet; |
|||
private final String signature; |
|||
|
|||
public MessageSignedEvent(Wallet wallet, String signature) { |
|||
this.wallet = wallet; |
|||
this.signature = signature; |
|||
} |
|||
|
|||
public Wallet getWallet() { |
|||
return wallet; |
|||
} |
|||
|
|||
public String getSignature() { |
|||
return signature; |
|||
} |
|||
} |
@ -0,0 +1,19 @@ |
|||
package com.sparrowwallet.sparrow.io; |
|||
|
|||
public class SignMessageException extends Exception { |
|||
public SignMessageException() { |
|||
super(); |
|||
} |
|||
|
|||
public SignMessageException(String message) { |
|||
super(message); |
|||
} |
|||
|
|||
public SignMessageException(Throwable cause) { |
|||
super(cause); |
|||
} |
|||
|
|||
public SignMessageException(String message, Throwable cause) { |
|||
super(message, cause); |
|||
} |
|||
} |
Loading…
Reference in new issue