use of co.rsk.bitcoinj.script.Script in project rskj by rsksmart.
the class PegTestUtils method createBaseInputScriptThatSpendsFromTheFederation.
public static Script createBaseInputScriptThatSpendsFromTheFederation(Federation federation) {
Script scriptPubKey = federation.getP2SHScript();
Script redeemScript = createBaseRedeemScriptThatSpendsFromTheFederation(federation);
RedeemData redeemData = RedeemData.of(federation.getBtcPublicKeys(), redeemScript);
Script inputScript = scriptPubKey.createEmptyInputScript(redeemData.keys.get(0), redeemData.redeemScript);
return inputScript;
}
use of co.rsk.bitcoinj.script.Script in project rskj by rsksmart.
the class P2shP2wpkhBtcLockSenderTest method doesnt_parse_if_transaction_witness_doesnt_have_two_pushes.
@Test
public void doesnt_parse_if_transaction_witness_doesnt_have_two_pushes() {
BtcTransaction btcTx = new BtcTransaction(networkParameters);
btcTx.addInput(PegTestUtils.createHash(1), 0, new Script(new byte[] {}));
TransactionWitness witness = new TransactionWitness(1);
witness.setPush(0, new byte[] {});
btcTx.setWitness(0, witness);
BtcLockSender btcLockSender = new P2shP2wpkhBtcLockSender();
Assert.assertFalse(btcLockSender.tryParse(btcTx));
}
use of co.rsk.bitcoinj.script.Script in project rskj by rsksmart.
the class PeginInstructionsProviderTest method extractOpReturnData_nullOpReturnData.
@Test(expected = NoOpReturnException.class)
public void extractOpReturnData_nullOpReturnData() throws PeginInstructionsException {
// Arrange
BtcTransaction btcTransaction = new BtcTransaction(params);
// Add OP_RETURN output with empty data
btcTransaction.addOutput(Coin.ZERO, new Script(new byte[] { ScriptOpCodes.OP_RETURN }));
// Act
PeginInstructionsProvider.extractOpReturnData(btcTransaction);
}
use of co.rsk.bitcoinj.script.Script in project rskj by rsksmart.
the class PeginInstructionsProviderTest method buildPeginInstructions_v1_noBtcRefundAddress.
@Test
public void buildPeginInstructions_v1_noBtcRefundAddress() throws Exception {
// Arrange
int protocolVersion = 1;
BtcECKey key = new BtcECKey();
RskAddress rskDestinationAddress = new RskAddress(ECKey.fromPublicOnly(key.getPubKey()).getAddress());
Script opReturnScript = PegTestUtils.createOpReturnScriptForRsk(protocolVersion, rskDestinationAddress, Optional.empty());
BtcTransaction btcTransaction = new BtcTransaction(params);
btcTransaction.addOutput(Coin.ZERO, opReturnScript);
// Act
PeginInstructionsProvider peginInstructionsProvider = new PeginInstructionsProvider();
Optional<PeginInstructions> peginInstructions = peginInstructionsProvider.buildPeginInstructions(btcTransaction);
// Assert
Assert.assertTrue(peginInstructions.isPresent());
Assert.assertEquals(protocolVersion, peginInstructions.get().getProtocolVersion());
Assert.assertEquals(rskDestinationAddress, peginInstructions.get().getRskDestinationAddress());
}
use of co.rsk.bitcoinj.script.Script in project rskj by rsksmart.
the class PeginInstructionsVersion1Test method parseAdditionalData_noBtcRefundAddress.
@Test
public void parseAdditionalData_noBtcRefundAddress() throws PeginInstructionsException {
// Arrange
Script opReturnScript = PegTestUtils.createOpReturnScriptForRsk(1, new RskAddress(new byte[20]), Optional.empty());
// Act
PeginInstructionsVersion1 peginInstructionsVersion1 = new PeginInstructionsVersion1(params);
peginInstructionsVersion1.parseAdditionalData(opReturnScript.getChunks().get(1).data);
// Assert
Optional<Address> obtainedBtcAddress = peginInstructionsVersion1.getBtcRefundAddress();
Assert.assertFalse(obtainedBtcAddress.isPresent());
}
Aggregations