Search in sources :

Example 11 with ScriptBuilder2

use of it.unica.tcs.lib.script.ScriptBuilder2 in project balzac by balzac-lang.

the class ScriptBuilder2Test method test_derialize_signature.

@Test
public void test_derialize_signature() throws KeyStoreException {
    ECKey key = new ECKey();
    String keyID = ECKeyStore.getUniqueID(key);
    String serialScript = "15 [sig," + keyID + ",**]";
    ScriptBuilder2 res = new ScriptBuilder2(serialScript);
    assertEquals(1, res.signatureSize());
    assertEquals(2, res.size());
    assertEquals(serialScript, res.serialize());
    serialScript = "15 [sig," + keyID + ",1*]";
    res = new ScriptBuilder2(serialScript);
    assertEquals(1, res.signatureSize());
    assertEquals(2, res.size());
    assertEquals(serialScript, res.serialize());
    serialScript = "15 [sig," + keyID + ",*0]";
    res = new ScriptBuilder2(serialScript);
    assertEquals(1, res.signatureSize());
    assertEquals(2, res.size());
    assertEquals(serialScript, res.serialize());
    serialScript = "15 [sig," + keyID + ",10]";
    res = new ScriptBuilder2(serialScript);
    assertEquals(1, res.signatureSize());
    assertEquals(2, res.size());
    assertEquals(serialScript, res.serialize());
    serialScript = "15 [sig," + keyID + ",*1]";
    res = new ScriptBuilder2(serialScript);
    assertEquals(1, res.signatureSize());
    assertEquals(2, res.size());
    assertEquals(serialScript, res.serialize());
    serialScript = "15 [sig," + keyID + ",11]";
    res = new ScriptBuilder2(serialScript);
    assertEquals(1, res.signatureSize());
    assertEquals(2, res.size());
    assertEquals(serialScript, res.serialize());
}
Also used : ScriptBuilder2(it.unica.tcs.lib.script.ScriptBuilder2) ECKey(org.bitcoinj.core.ECKey) Test(org.junit.Test)

Example 12 with ScriptBuilder2

use of it.unica.tcs.lib.script.ScriptBuilder2 in project balzac by balzac-lang.

the class ScriptBuilder2Test method test_serialize_signature2.

@Test
public void test_serialize_signature2() {
    ECKey key = new ECKey();
    SigHash hashType = SigHash.ALL;
    ScriptBuilder2 sb = new ScriptBuilder2();
    sb.number(15);
    sb.signaturePlaceholder(key, hashType, true);
    String expected = "15 [sig," + ECKeyStore.getUniqueID(key) + ",1*]";
    String actual = sb.serialize();
    assertEquals(expected, actual);
}
Also used : SigHash(org.bitcoinj.core.Transaction.SigHash) ScriptBuilder2(it.unica.tcs.lib.script.ScriptBuilder2) ECKey(org.bitcoinj.core.ECKey) Test(org.junit.Test)

Example 13 with ScriptBuilder2

use of it.unica.tcs.lib.script.ScriptBuilder2 in project balzac by balzac-lang.

the class ScriptBuilder2Test method test_serialize_signature6.

@Test
public void test_serialize_signature6() {
    ECKey key = new ECKey();
    SigHash hashType = SigHash.NONE;
    ScriptBuilder2 sb = new ScriptBuilder2();
    sb.number(15);
    sb.signaturePlaceholder(key, hashType, true);
    String expected = "15 [sig," + ECKeyStore.getUniqueID(key) + ",10]";
    String actual = sb.serialize();
    assertEquals(expected, actual);
}
Also used : SigHash(org.bitcoinj.core.Transaction.SigHash) ScriptBuilder2(it.unica.tcs.lib.script.ScriptBuilder2) ECKey(org.bitcoinj.core.ECKey) Test(org.junit.Test)

Example 14 with ScriptBuilder2

use of it.unica.tcs.lib.script.ScriptBuilder2 in project balzac by balzac-lang.

the class ScriptBuilder2Test method test_serialize_signature4.

@Test
public void test_serialize_signature4() {
    ECKey key = new ECKey();
    SigHash hashType = SigHash.SINGLE;
    ScriptBuilder2 sb = new ScriptBuilder2();
    sb.number(15);
    sb.signaturePlaceholder(key, hashType, true);
    String expected = "15 [sig," + ECKeyStore.getUniqueID(key) + ",11]";
    String actual = sb.serialize();
    assertEquals(expected, actual);
}
Also used : SigHash(org.bitcoinj.core.Transaction.SigHash) ScriptBuilder2(it.unica.tcs.lib.script.ScriptBuilder2) ECKey(org.bitcoinj.core.ECKey) Test(org.junit.Test)

Example 15 with ScriptBuilder2

use of it.unica.tcs.lib.script.ScriptBuilder2 in project balzac by balzac-lang.

the class ScriptBuilder2Test method test_serialize_signature3.

@Test
public void test_serialize_signature3() {
    ECKey key = new ECKey();
    SigHash hashType = SigHash.SINGLE;
    ScriptBuilder2 sb = new ScriptBuilder2();
    sb.number(15);
    sb.signaturePlaceholder(key, hashType, false);
    String expected = "15 [sig," + ECKeyStore.getUniqueID(key) + ",*1]";
    String actual = sb.serialize();
    assertEquals(expected, actual);
}
Also used : SigHash(org.bitcoinj.core.Transaction.SigHash) ScriptBuilder2(it.unica.tcs.lib.script.ScriptBuilder2) ECKey(org.bitcoinj.core.ECKey) Test(org.junit.Test)

Aggregations

ScriptBuilder2 (it.unica.tcs.lib.script.ScriptBuilder2)17 Test (org.junit.Test)17 ECKey (org.bitcoinj.core.ECKey)8 SigHash (org.bitcoinj.core.Transaction.SigHash)6 Script (org.bitcoinj.script.Script)6 Transaction (org.bitcoinj.core.Transaction)1 TransactionInput (org.bitcoinj.core.TransactionInput)1 MainNetParams (org.bitcoinj.params.MainNetParams)1