Skip to content

Commit

Permalink
Fix Private Messaging between traders
Browse files Browse the repository at this point in the history
  • Loading branch information
alvasw committed Nov 15, 2023
1 parent c009a13 commit 37cda03
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
22 changes: 22 additions & 0 deletions identity/src/main/java/bisq/identity/IdentityService.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,28 @@ public Identity getOrCreateDefaultIdentity() {
});
}

/**
* Creates new identity based on given parameters.
*/
public CompletableFuture<Identity> createNewActiveIdentity(String tag,
String keyId,
KeyPair keyPair) {
keyPairService.persistKeyPair(keyId, keyPair);
PubKey pubKey = new PubKey(keyPair.getPublic(), keyId);

TorIdentity torIdentity = createTorIdentity(false);
NetworkId networkId = createNetworkId(false, pubKey, torIdentity);
Identity identity = new Identity(tag, networkId, torIdentity, keyPair);

synchronized (lock) {
getActiveIdentityByTag().put(tag, identity);
}
persist();

return networkService.getNetworkIdOfInitializedNode(networkId, torIdentity)
.thenApply(nodes -> identity);
}

public Identity createAndInitializeNewActiveIdentity(String tag) {
Identity identity = createAndInitializeNewIdentity(tag);

Expand Down
10 changes: 6 additions & 4 deletions user/src/main/java/bisq/user/identity/UserIdentityService.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,12 @@ public CompletableFuture<UserIdentity> createAndPublishNewUserProfile(String nic
String terms,
String statement) {
String tag = getTag(nickName, proofOfWork);
Identity identity = identityService.getOrCreateIdentity(tag, keyId, keyPair);
UserIdentity userIdentity = createUserIdentity(nickName, proofOfWork, terms, statement, identity);
return publishPublicUserProfile(userIdentity.getUserProfile(), userIdentity.getIdentity().getNodeIdAndKeyPair().getKeyPair())
.thenApply(broadcastResult -> userIdentity);
return identityService.createNewActiveIdentity(tag, keyId, keyPair)
.thenApply(identity -> createUserIdentity(nickName, proofOfWork, terms, statement, identity))
.thenApply(userIdentity -> {
publishPublicUserProfile(userIdentity.getUserProfile(), userIdentity.getIdentity().getNodeIdAndKeyPair().getKeyPair());
return userIdentity;
});
}

public void selectChatUserIdentity(UserIdentity userIdentity) {
Expand Down

0 comments on commit 37cda03

Please sign in to comment.