use of snowblossom.client.SnowBlossomClient in project snowblossom by snowblossomcoin.
the class SpoonTest method startClientWithWallet.
protected SnowBlossomClient startClientWithWallet(int port) throws Exception {
String wallet_path = test_folder.newFolder().getPath();
Map<String, String> config_map = new TreeMap<>();
config_map.put("node_uri", "grpc://localhost:" + port);
config_map.put("network", "spoon");
config_map.put("wallet_path", wallet_path);
return new SnowBlossomClient(new ConfigMem(config_map));
}
use of snowblossom.client.SnowBlossomClient in project snowblossom by snowblossomcoin.
the class SpoonTestBasic method spoonTest.
/**
* More of a giant orbital space platform full of weasels
* than a unit test
*/
@Test
public void spoonTest() throws Exception {
File snow_path = setupSnow();
Random rnd = new Random();
int port = 20000 + rnd.nextInt(30000);
SnowBlossomNode node = startNode(port);
Thread.sleep(100);
KeyPair key_pair = KeyUtil.generateECCompressedKey();
AddressSpec claim = AddressUtil.getSimpleSpecForKey(key_pair.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
AddressSpecHash to_addr = AddressUtil.getHashForSpec(claim);
SnowBlossomMiner miner = startMiner(port, to_addr, snow_path);
testMinedBlocks(node);
SnowBlossomClient client = startClient(port);
testConsolidateFunds(node, client, key_pair, to_addr);
SnowBlossomNode node2 = startNode(port + 1);
node2.getPeerage().connectPeer("localhost", port);
testMinedBlocks(node2);
miner.stop();
Thread.sleep(500);
node.stop();
node2.stop();
}
use of snowblossom.client.SnowBlossomClient in project snowblossom by snowblossomcoin.
the class SpoonTestPool method spoonPoolTest.
@Test
public void spoonPoolTest() throws Exception {
File snow_path = setupSnow();
Random rnd = new Random();
int port = 20000 + rnd.nextInt(30000);
SnowBlossomNode node = startNode(port);
Thread.sleep(2000);
KeyPair key_pair = KeyUtil.generateECCompressedKey();
AddressSpec claim = AddressUtil.getSimpleSpecForKey(key_pair.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
AddressSpecHash to_addr = AddressUtil.getHashForSpec(claim);
KeyPair key_pair2 = KeyUtil.generateECCompressedKey();
AddressSpec claim2 = AddressUtil.getSimpleSpecForKey(key_pair2.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
AddressSpecHash to_addr2 = AddressUtil.getHashForSpec(claim2);
KeyPair key_pair3 = KeyUtil.generateECCompressedKey();
AddressSpec claim3 = AddressUtil.getSimpleSpecForKey(key_pair3.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
AddressSpecHash to_addr3 = AddressUtil.getHashForSpec(claim3);
SnowBlossomClient client = startClient(port);
MrPlow plow = startMrPlow(port, to_addr2);
Thread.sleep(4000);
PoolMiner miner = startPoolMiner(plow.getGrpcPort(), to_addr, snow_path);
Thread.sleep(25000);
waitForMoreBlocks(node, 10);
System.out.println("ShareMap: " + plow.getShareManager().getShareMap());
System.out.println("ShareMap pay: " + plow.getShareManager().getPayRatios());
// Pool getting paid
waitForFunds(client, to_addr2, 10);
// Miner getting paid
waitForFunds(client, to_addr, 30);
PoolMiner miner2 = startPoolMiner(plow.getGrpcPort(), to_addr3, snow_path);
// Second miner getting paid
waitForFunds(client, to_addr3, 30);
miner.stop();
miner2.stop();
Thread.sleep(500);
plow.stop();
node.stop();
}
use of snowblossom.client.SnowBlossomClient in project snowblossom by snowblossomcoin.
the class SpoonTestPoolTls method spoonPoolTest.
@Test
public void spoonPoolTest() throws Exception {
File snow_path = setupSnow();
Random rnd = new Random();
int port = 20000 + rnd.nextInt(30000);
SnowBlossomNode node = startNode(port);
Thread.sleep(2000);
KeyPair key_pair = KeyUtil.generateECCompressedKey();
AddressSpec claim = AddressUtil.getSimpleSpecForKey(key_pair.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
AddressSpecHash to_addr = AddressUtil.getHashForSpec(claim);
KeyPair key_pair2 = KeyUtil.generateECCompressedKey();
AddressSpec claim2 = AddressUtil.getSimpleSpecForKey(key_pair2.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
AddressSpecHash to_addr2 = AddressUtil.getHashForSpec(claim2);
KeyPair key_pair3 = KeyUtil.generateECCompressedKey();
AddressSpec claim3 = AddressUtil.getSimpleSpecForKey(key_pair3.getPublic(), SignatureUtil.SIG_TYPE_ECDSA_COMPRESSED);
AddressSpecHash to_addr3 = AddressUtil.getHashForSpec(claim3);
SnowBlossomClient client = startClient(port);
MrPlow plow = startMrPlow(port, to_addr2);
Thread.sleep(4000);
String uri = "grpc+tls://localhost:" + plow.getGrpcTlsPort();
PoolMiner miner = startPoolMinerUri(uri, to_addr, snow_path, "spoon");
Thread.sleep(25000);
waitForMoreBlocks(node, 10);
System.out.println("ShareMap: " + plow.getShareManager().getShareMap());
System.out.println("ShareMap pay: " + plow.getShareManager().getPayRatios());
// Pool getting paid
waitForFunds(client, to_addr2, 10);
// Miner getting paid
waitForFunds(client, to_addr, 30);
String uri_key = uri + "/?key=" + plow.getTlsKeyId();
PoolMiner miner2 = startPoolMinerUri(uri_key, to_addr3, snow_path, "spoon");
// Second miner getting paid
waitForFunds(client, to_addr3, 30);
miner.stop();
miner2.stop();
Thread.sleep(500);
plow.stop();
node.stop();
}
use of snowblossom.client.SnowBlossomClient in project snowblossom by snowblossomcoin.
the class SendPanel method setupTx.
private void setupTx() throws Exception {
setStatusBox("Creating transaction");
setMessageBox("");
TransactionFactoryConfig.Builder config = TransactionFactoryConfig.newBuilder();
config.setSign(true);
config.setChangeFreshAddress(true);
config.setInputConfirmedThenPending(true);
config.setFeeUseEstimate(true);
config.setExtra(convertExtra(saved_extra));
AddressSpecHash dest_addr = new AddressSpecHash(saved_dest.trim(), ice_leaf.getParams());
long output_val = 0;
if (saved_amount.toLowerCase().equals("all")) {
config.setSendAll(true);
} else {
output_val = (long) (Double.parseDouble(saved_amount) * Globals.SNOW_VALUE);
}
config.addOutputs(TransactionOutput.newBuilder().setValue(output_val).setRecipientSpecHash(dest_addr.getBytes()).build());
SnowBlossomClient client = ice_leaf.getWalletPanel().getWallet(saved_wallet);
if (client == null) {
throw new Exception("Must specify source wallet");
}
tx_result = TransactionFactory.createTransaction(config.build(), client.getPurse().getDB(), client);
StringBuilder tx_sb = new StringBuilder();
for (Transaction tx : tx_result.getTxsList()) {
tx_sb.append(TransactionUtil.prettyDisplayTx(tx, ice_leaf.getParams()));
tx_sb.append("\n");
}
setMessageBox(String.format("Press Send again to when progress bar is full to send:\n%s", tx_sb.toString()));
}
Aggregations