Search in sources :

Example 1 with Pool

use of com.samourai.whirlpool.client.whirlpool.beans.Pool in project samourai-wallet-android by Samourai-Wallet.

the class WhirlpoolWalletTest method testTx0.

@Test
public void testTx0() throws Exception {
    Collection<UnspentOutputWithKey> spendFroms = new LinkedList<>();
    ECKey ecKey = bip84w.getAccountAt(0).getChain(0).getAddressAt(61).getECKey();
    UnspentResponse.UnspentOutput unspentOutput = newUnspentOutput("cc588cdcb368f894a41c372d1f905770b61ecb3fb8e5e01a97e7cedbf5e324ae", 1, 500000000);
    unspentOutput.addr = new SegwitAddress(ecKey, networkParameters).getBech32AsString();
    spendFroms.add(new UnspentOutputWithKey(unspentOutput, ecKey.getPrivKeyBytes()));
    Pool pool = whirlpoolWallet.findPoolById("0.01btc");
    Tx0Config tx0Config = whirlpoolWallet.getTx0Config().setMaxOutputs(1);
    Tx0Preview tx0Preview = whirlpoolWallet.tx0Preview(pool, spendFroms, tx0Config, Tx0FeeTarget.BLOCKS_2);
    Tx0 tx0 = whirlpoolWallet.tx0(pool, spendFroms, tx0Config, Tx0FeeTarget.BLOCKS_2);
    Assert.assertEquals("dc398c99cf9ce18123ea916d69bb99da44a3979a625eeaac5e17837f879a8874", tx0.getTx().getHashAsString());
    Assert.assertEquals("01000000000101ae24e3f5dbcee7971ae0e5b83fcb1eb67057901f2d371ca494f868b3dc8c58cc0100000000ffffffff040000000000000000426a408a9eb379a44ff4d4579118c64b64bbd327cd95ba826ac68f334155fd9ca4e3acd64acdfd75dd7c3cc5bc34d31af6c6e68b4db37eac62b574890f6cfc7b904d9950c300000000000016001441021632871b0f1cf61a7ac7b6a0187e88628291b44b0f00000000001600147e4a4628dd8fbd638681a728e39f7d92ada04070e954bd1d00000000160014df3a4bc83635917ad18621f3ba78cef6469c5f5902483045022100c48f02762ab9877533b5c7b0bc729479ce7809596b89cb9f62b740ea3350068f02205ef46ca67df39d35f940e33223c5ddd56669d953b6ef4948e355c1f3430f32e10121032e46baef8bcde0c3a19cadb378197fa31d69adb21535de3f84de699a1cf88b4500000000", new String(Hex.encode(tx0.getTx().bitcoinSerialize())));
}
Also used : SegwitAddress(com.samourai.wallet.segwit.SegwitAddress) ECKey(org.bitcoinj.core.ECKey) Pool(com.samourai.whirlpool.client.whirlpool.beans.Pool) Tx0Preview(com.samourai.whirlpool.client.tx0.Tx0Preview) UnspentOutputWithKey(com.samourai.whirlpool.client.tx0.UnspentOutputWithKey) Tx0(com.samourai.whirlpool.client.tx0.Tx0) LinkedList(java.util.LinkedList) UnspentResponse(com.samourai.wallet.api.backend.beans.UnspentResponse) Tx0Config(com.samourai.whirlpool.client.tx0.Tx0Config) Test(org.junit.Test)

Example 2 with Pool

use of com.samourai.whirlpool.client.whirlpool.beans.Pool in project samourai-wallet-android by Samourai-Wallet.

the class WhirlpoolWalletTest method testStart.

@Test
public void testStart() throws Exception {
    // start whirlpool wallet
    whirlpoolWallet.start();
    // list pools
    Collection<Pool> pools = whirlpoolWallet.getPools();
    Assert.assertTrue(!pools.isEmpty());
    // find pool by poolId
    Pool pool = whirlpoolWallet.findPoolById("0.01btc");
    Assert.assertNotNull(pool);
    // list premix utxos
    Collection<WhirlpoolUtxo> utxosPremix = whirlpoolWallet.getUtxosPremix();
    log.info(utxosPremix.size() + " PREMIX utxos:");
    ClientUtils.logWhirlpoolUtxos(utxosPremix, whirlpoolWallet.getConfig().getMixsTarget());
    // list postmix utxos
    Collection<WhirlpoolUtxo> utxosPostmix = whirlpoolWallet.getUtxosPremix();
    log.info(utxosPostmix.size() + " POSTMIX utxos:");
    ClientUtils.logWhirlpoolUtxos(utxosPostmix, whirlpoolWallet.getConfig().getMixsTarget());
    // keep running
    for (int i = 0; i < 50; i++) {
        MixingState mixingState = whirlpoolWallet.getMixingState();
        log.debug("WHIRLPOOL: " + mixingState.getNbQueued() + " queued, " + mixingState.getNbMixing() + " mixing: " + mixingState.getUtxosMixing());
        synchronized (this) {
            wait(10000);
        }
    }
}
Also used : Pool(com.samourai.whirlpool.client.whirlpool.beans.Pool) WhirlpoolUtxo(com.samourai.whirlpool.client.wallet.beans.WhirlpoolUtxo) MixingState(com.samourai.whirlpool.client.wallet.beans.MixingState) Test(org.junit.Test)

Aggregations

Pool (com.samourai.whirlpool.client.whirlpool.beans.Pool)2 Test (org.junit.Test)2 UnspentResponse (com.samourai.wallet.api.backend.beans.UnspentResponse)1 SegwitAddress (com.samourai.wallet.segwit.SegwitAddress)1 Tx0 (com.samourai.whirlpool.client.tx0.Tx0)1 Tx0Config (com.samourai.whirlpool.client.tx0.Tx0Config)1 Tx0Preview (com.samourai.whirlpool.client.tx0.Tx0Preview)1 UnspentOutputWithKey (com.samourai.whirlpool.client.tx0.UnspentOutputWithKey)1 MixingState (com.samourai.whirlpool.client.wallet.beans.MixingState)1 WhirlpoolUtxo (com.samourai.whirlpool.client.wallet.beans.WhirlpoolUtxo)1 LinkedList (java.util.LinkedList)1 ECKey (org.bitcoinj.core.ECKey)1