org.bitcoinj.wallet.MarriedKeyChain Java Examples

The following examples show how to use org.bitcoinj.wallet.MarriedKeyChain. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WalletProtobufSerializerTest.java    From bcm-android with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testRoundTripMarriedWallet() throws Exception {
    // create 2-of-2 married wallet
    myWallet = new Wallet(UNITTEST);
    final DeterministicKeyChain partnerChain = new DeterministicKeyChain(new SecureRandom());
    DeterministicKey partnerKey = DeterministicKey.deserializeB58(null, partnerChain.getWatchingKey().serializePubB58(UNITTEST), UNITTEST);
    MarriedKeyChain chain = MarriedKeyChain.builder()
            .random(new SecureRandom())
            .followingKeys(partnerKey)
            .threshold(2).build();
    myWallet.addAndActivateHDChain(chain);

    myAddress = myWallet.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);

    Wallet wallet1 = roundTrip(myWallet);
    assertEquals(0, wallet1.getTransactions(true).size());
    assertEquals(Coin.ZERO, wallet1.getBalance());
    assertEquals(2, wallet1.getActiveKeyChain().getSigsRequiredToSpend());
    assertEquals(myAddress, wallet1.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS));
}
 
Example #2
Source File: WalletTool.java    From green_android with GNU General Public License v3.0 6 votes vote down vote up
private static void marry() {
    if (!options.has(xpubkeysFlag)) {
        throw new IllegalStateException();
    }

    String[] xpubkeys = options.valueOf(xpubkeysFlag).split(",");
    ImmutableList.Builder<DeterministicKey> keys = ImmutableList.builder();
    for (String xpubkey : xpubkeys) {
        keys.add(DeterministicKey.deserializeB58(null, xpubkey.trim(), params));
    }
    MarriedKeyChain chain = MarriedKeyChain.builder()
            .random(new SecureRandom())
            .followingKeys(keys.build())
            .build();
    wallet.addAndActivateHDChain(chain);
}
 
Example #3
Source File: WalletProtobufSerializerTest.java    From green_android with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testRoundTripMarriedWallet() throws Exception {
    // create 2-of-2 married wallet
    myWallet = new Wallet(PARAMS);
    final DeterministicKeyChain partnerChain = new DeterministicKeyChain(new SecureRandom());
    DeterministicKey partnerKey = DeterministicKey.deserializeB58(null, partnerChain.getWatchingKey().serializePubB58(PARAMS), PARAMS);
    MarriedKeyChain chain = MarriedKeyChain.builder()
            .random(new SecureRandom())
            .followingKeys(partnerKey)
            .threshold(2).build();
    myWallet.addAndActivateHDChain(chain);

    myAddress = myWallet.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);

    Wallet wallet1 = roundTrip(myWallet);
    assertEquals(0, wallet1.getTransactions(true).size());
    assertEquals(Coin.ZERO, wallet1.getBalance());
    assertEquals(2, wallet1.getActiveKeyChain().getSigsRequiredToSpend());
    assertEquals(myAddress, wallet1.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS));
}
 
Example #4
Source File: WalletTool.java    From GreenBits with GNU General Public License v3.0 6 votes vote down vote up
private static void marry() {
    if (!options.has(xpubkeysFlag)) {
        throw new IllegalStateException();
    }

    String[] xpubkeys = options.valueOf(xpubkeysFlag).split(",");
    ImmutableList.Builder<DeterministicKey> keys = ImmutableList.builder();
    for (String xpubkey : xpubkeys) {
        keys.add(DeterministicKey.deserializeB58(null, xpubkey.trim(), params));
    }
    MarriedKeyChain chain = MarriedKeyChain.builder()
            .random(new SecureRandom())
            .followingKeys(keys.build())
            .build();
    wallet.addAndActivateHDChain(chain);
}
 
Example #5
Source File: WalletProtobufSerializerTest.java    From GreenBits with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testRoundTripMarriedWallet() throws Exception {
    // create 2-of-2 married wallet
    myWallet = new Wallet(PARAMS);
    final DeterministicKeyChain partnerChain = new DeterministicKeyChain(new SecureRandom());
    DeterministicKey partnerKey = DeterministicKey.deserializeB58(null, partnerChain.getWatchingKey().serializePubB58(PARAMS), PARAMS);
    MarriedKeyChain chain = MarriedKeyChain.builder()
            .random(new SecureRandom())
            .followingKeys(partnerKey)
            .threshold(2).build();
    myWallet.addAndActivateHDChain(chain);

    myAddress = myWallet.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS);

    Wallet wallet1 = roundTrip(myWallet);
    assertEquals(0, wallet1.getTransactions(true).size());
    assertEquals(Coin.ZERO, wallet1.getBalance());
    assertEquals(2, wallet1.getActiveKeyChain().getSigsRequiredToSpend());
    assertEquals(myAddress, wallet1.currentAddress(KeyChain.KeyPurpose.RECEIVE_FUNDS));
}