Skip to content

Commit

Permalink
Setting username
Browse files Browse the repository at this point in the history
  • Loading branch information
fireduck64 committed Oct 3, 2019
1 parent d26704a commit 964315e
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions client/src/SnowBlossomClient.java
Expand Up @@ -23,6 +23,7 @@
import snowblossom.proto.*;
import snowblossom.proto.UserServiceGrpc.UserServiceBlockingStub;
import snowblossom.util.proto.*;
import com.google.protobuf.ByteString;

public class SnowBlossomClient
{
Expand Down Expand Up @@ -128,10 +129,15 @@ else if (command.equals("sendlocked"))
String to = args[3];
String fbo = args[4];
int block = Integer.parseInt(args[5]);
String username = null;
if (args.length > 6)
{
username = args[6];
}

DecimalFormat df = new DecimalFormat("0.000000");
logger.info(String.format("Building locked send of %s to %s for %s until %d", df.format(val_snow), to, fbo, block));
client.sendLocked(value, to, fbo, block);
client.sendLocked(value, to, fbo, block, username);

}

Expand Down Expand Up @@ -479,7 +485,7 @@ public void send(long value, String to, boolean send_all)
System.out.println(stub_holder.getBlockingStub().submitTransaction(tx));

}
public void sendLocked(long value, String to, String fbo, int block)
public void sendLocked(long value, String to, String fbo, int block, String username)
throws Exception
{

Expand All @@ -488,12 +494,19 @@ public void sendLocked(long value, String to, String fbo, int block)
tx_config.setSign(true);
AddressSpecHash to_hash = AddressUtil.getHashForAddress(params.getAddressPrefix(), to);
AddressSpecHash fbo_hash = AddressUtil.getHashForAddress(params.getAddressPrefix(), fbo);
tx_config.addOutputs(TransactionOutput.newBuilder()
.setRecipientSpecHash(to_hash.getBytes())
.setValue(value)
.setForBenefitOfSpecHash(fbo_hash.getBytes())
.setRequirements( TransactionRequirements.newBuilder().setRequiredBlockHeight(block).build() )
.build());

TransactionOutput.Builder out = TransactionOutput.newBuilder();

out.setRecipientSpecHash(to_hash.getBytes());
out.setValue(value);
out.setForBenefitOfSpecHash(fbo_hash.getBytes());
out.setRequirements( TransactionRequirements.newBuilder().setRequiredBlockHeight(block).build() );
if (username != null)
{
out.setIds( ClaimedIdentifiers.newBuilder().setUsername(ByteString.copyFrom(username.getBytes())).build() );
}
tx_config.addOutputs(out.build());

tx_config.setChangeFreshAddress(true);
tx_config.setInputConfirmedThenPending(true);
tx_config.setFeeUseEstimate(true);
Expand Down

0 comments on commit 964315e

Please sign in to comment.