Java Code Examples for org.bitcoinj.core.Transaction.SigHash#SINGLE

The following examples show how to use org.bitcoinj.core.Transaction.SigHash#SINGLE . 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: AbstractScriptBuilderWithVar.java    From balzac with Apache License 2.0 6 votes vote down vote up
protected static Object[] decodeModifier(String modifier) {
    switch (modifier) {
    case "AIAO":
        return new Object[] { SigHash.ALL, Boolean.FALSE };
    case "SIAO":
        return new Object[] { SigHash.ALL, Boolean.TRUE };
    case "AINO":
        return new Object[] { SigHash.NONE, Boolean.FALSE };
    case "SINO":
        return new Object[] { SigHash.NONE, Boolean.TRUE };
    case "AISO":
        return new Object[] { SigHash.SINGLE, Boolean.FALSE };
    case "SISO":
        return new Object[] { SigHash.SINGLE, Boolean.TRUE };
    }
    throw new IllegalStateException(modifier);
}
 
Example 2
Source File: ScriptBuilderWithVarTest.java    From balzac with Apache License 2.0 5 votes vote down vote up
@Test
public void test_serialize_signature3() {
    PrivateKey key = PrivateKey.fresh(NetworkType.TESTNET);
    SigHash hashType = SigHash.SINGLE;
    ScriptBuilderWithVar sb = new ScriptBuilderWithVar();
    sb.number(15);
    sb.signaturePlaceholder(ECKeyStore.getUniqueID(key), hashType, false);

    String expected = "15 [sig," + ECKeyStore.getUniqueID(key) + ",AISO]";
    String actual = sb.serialize();
    assertEquals(expected, actual);
}
 
Example 3
Source File: ScriptBuilderWithVarTest.java    From balzac with Apache License 2.0 5 votes vote down vote up
@Test
public void test_serialize_signature4() {
    PrivateKey key = PrivateKey.fresh(NetworkType.TESTNET);
    SigHash hashType = SigHash.SINGLE;
    ScriptBuilderWithVar sb = new ScriptBuilderWithVar();
    sb.number(15);
    sb.signaturePlaceholder(ECKeyStore.getUniqueID(key), hashType, true);

    String expected = "15 [sig," + ECKeyStore.getUniqueID(key) + ",SISO]";
    String actual = sb.serialize();
    assertEquals(expected, actual);
}