Search in sources :

Example 1 with MainNetParams

use of org.bitcoinj.params.MainNetParams in project balzac by balzac-lang.

the class ScriptBuilder2Test method test_signature.

@Test
public void test_signature() throws KeyStoreException {
    ScriptBuilder2 sb = new ScriptBuilder2();
    assertEquals(0, sb.size());
    assertEquals(0, sb.getFreeVariables().size());
    assertEquals(0, sb.signatureSize());
    ECKey k1 = new ECKey();
    ECKey k2 = new ECKey();
    ecks.addKey(k1);
    ecks.addKey(k2);
    sb.signaturePlaceholder(k1, SigHash.ALL, false);
    sb.signaturePlaceholder(k2, SigHash.ALL, false);
    System.out.println(sb);
    assertEquals(2, sb.size());
    assertEquals(0, sb.getFreeVariables().size());
    assertEquals(2, sb.signatureSize());
    Transaction tx = new Transaction(new MainNetParams());
    tx.addInput(new TransactionInput(new MainNetParams(), null, new byte[] { 42, 42 }));
    sb.setAllSignatures(ecks, tx, 0, new byte[] {});
    System.out.println(sb);
    assertEquals(2, sb.size());
    assertEquals(0, sb.getFreeVariables().size());
    assertEquals(0, sb.signatureSize());
}
Also used : Transaction(org.bitcoinj.core.Transaction) ScriptBuilder2(it.unica.tcs.lib.script.ScriptBuilder2) ECKey(org.bitcoinj.core.ECKey) MainNetParams(org.bitcoinj.params.MainNetParams) TransactionInput(org.bitcoinj.core.TransactionInput) Test(org.junit.Test)

Aggregations

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