import javax.xml.bind.annotation.adapters.HexBinaryAdapter; public byte[] hexToBytes(String hexString) { HexBinaryAdapter adapter = new HexBinaryAdapter(); byte[] bytes = adapter.unmarshal(hexString); return bytes; }
throw new IOException("<xattr> had no <val> or <valHex> entry."); val = new HexBinaryAdapter().unmarshal(valHex); } else { val = valStr.getBytes("UTF8");
public byte[] hexToBytes(String hexString) { HexBinaryAdapter adapter = new HexBinaryAdapter(); byte[] bytes = adapter.unmarshal(hexString); return bytes; } }
public synchronized static byte[] hexToBytes(String hexString) { HexBinaryAdapter adapter = new HexBinaryAdapter(); byte[] bytes = adapter.unmarshal(hexString); return bytes; }
public static byte[] hexToBytes(String hexString) { HexBinaryAdapter adapter = new HexBinaryAdapter(); byte[] bytes = adapter.unmarshal(hexString); return bytes; }
"lacked a <key> field."); byte[] key = new HexBinaryAdapter().unmarshal(keyHex); dkey.verifyNoRemainingKeys(SECRET_MANAGER_SECTION_DELEGATION_KEY); dbld.setKey(ByteString.copyFrom(key));
/** * Gets the value of the xorPattern property. * * @return * possible object is * {@link String } * */ public byte[] getXorPattern() { if (xorPattern == null) { return new HexBinaryAdapter().unmarshal("55AA55AA55AA55BB"); } else { return xorPattern; } }
byte[] serializedBytes = hexAdapter.unmarshal(v); ByteArrayInputStream bais = new ByteArrayInputStream(serializedBytes); ObjectInputStream ois = new ObjectInputStream(bais);
String hexTx = (String) json.get("result"); HexBinaryAdapter adapter = new HexBinaryAdapter(); byte[] bytearray = adapter.unmarshal(hexTx); Context context = Context.getOrCreate(netParams); tx = new org.bitcoinj.core.Transaction(netParams, bytearray);
String txid = currentJson.get("txid").toString(); HexBinaryAdapter adapter = new HexBinaryAdapter(); byte[] bytearray = adapter.unmarshal(currentJson.get("hex").toString()); Context context = Context.getOrCreate(netParams); int confirmations;
return new HexBinaryAdapter().unmarshal(obj); } else if (part != null && u.getSchema() != null && !(part.getXmlSchema() instanceof XmlSchemaElement)) {
byte[] bytex2 = adapter.unmarshal("01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0d03491c030155062f503253482fffffffff0100f2052a010000002321020cf3600b55a8782a2ef594d8c4b1d5cdf5d29f826ae72fb8b0ceb43a1200fabeac00000000"); org.bitcoinj.core.Transaction btx2 = new org.bitcoinj.core.Transaction(this.netParams, bytex2); Transaction tx2 = new Transaction("77b291dcbf6483719ca4287045ee8faef19f03b3728fc8b0f697296b9da9978e",btx2,false,true); byte[] bytex3 = adapter.unmarshal("01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0e03d01c0302fa21062f503253482fffffffff011019062a01000000232102a525e0acc35f97b9b742f3d881910951c4e5303fe5e295ad723d08893aa86942ac00000000"); org.bitcoinj.core.Transaction btx3 = new org.bitcoinj.core.Transaction(this.netParams, bytex3); Transaction tx3 = new Transaction("f4a4a742ef159e93e1133f85079536f7f7c0ff467a7b7fbf47cdeb72d30fcbb3",btx3,false,true); byte[] bytex4 = adapter.unmarshal("01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2503ca7b04184b6e434d696e657242510cb670ab1c4b086d542ee8d32b8d01000000d4040000ffffffff0100f90295000000001976a9149e8985f82bc4e0f753d0492aa8d11cc39925774088ac00000000"); org.bitcoinj.core.Transaction btx4 = new org.bitcoinj.core.Transaction(this.netParams, bytex4); Transaction tx4 = new Transaction("47d37f362f400cec3e9366b0701b2c54a8a85aba0ceda48c8d27343031e7f2ae",btx4,false,true); byte[] bytex5 = adapter.unmarshal("01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0d03ca9504015c062f503253482fffffffff0110fd0295000000002321030fff984dad779eb2804c73ae41038b3db2402dd33e64753f2eab5ad37784792eac00000000"); org.bitcoinj.core.Transaction btx5 = new org.bitcoinj.core.Transaction(this.netParams, bytex5); Transaction tx5 = new Transaction("635635211f84e5e89bb197ccf514c531e51f5ca2ba8ce4da720250b4a29f3478",btx5,false,true); byte[] bytex6 = adapter.unmarshal("0100000001d7b3d434fad5961b5a1ca8083b9c83f8bc7ba283c027dc34cbea7a42fefc7ebe010000006b483045022100ee44af88e7295dfe6ab0f556c84bb722fea7271626f79dc914f5a1b4991f51a102204fd79b0a062cadad1682aed8094bf639f957f0e43d9337145f48521c8509ba92012102230d12de280ef92660c166054b194d09000e8328dbb33ef2667d1dd1ccf52369feffffff02c0fc9b01000000001976a91423e077ffac6f109795a82021dc1698bd9ce4011988ac1a52641a000000001976a9140c878fdf88351cc9f4ced15df3aea8183b604f0688acd5cb0800"); org.bitcoinj.core.Transaction btx6 = new org.bitcoinj.core.Transaction(this.netParams, bytex6); Transaction tx6 = new Transaction("20b2ec5e7d8127241230104d6c776f3bb87d5a20c2ba9e9d92f4658017181201",btx6,false,true); byte[] bytex7 = adapter.unmarshal("0100000001d38c06624d53f0ed48d05046d485d739f3076ce701655bb9ce2157fe412cf118000000006a47304402202c0e654149820ca5e95bfda24a9ef26cc3956560f0569c7157707d0c3f784c0402204337fcd8c6f86c23416bbecb2509ad897f8576e15c47b6456645d03bb4c6af7a012102bfa469ffb4404523987c018d7ba52d3929c75fc41e7a6f635640f506d715ed84ffffffff0210339041000000001976a9140b353d33f64efb36576cd4fcf0261b1aeb5ba96688ac0046c323000000001976a9143567de06aa57a188a8e9c47b3bc9778151f1a6e888ac00000000"); org.bitcoinj.core.Transaction btx7 = new org.bitcoinj.core.Transaction(this.netParams, bytex7); Transaction tx7 = new Transaction("a8d1cd860df2c345fd83764413f7809fe42344a8715b03a597751f22b7a1b33d",btx7,false,true); byte[] bytex8 = adapter.unmarshal("01000000013db3a1b7221f7597a5035b71a84423e49f80f713447683fd45c3f20d86cdd1a8000000006a4730440220382af068eaae9d39861ca811a7d57cbe5291f3704adad248df683a7756446d7302200dc487a00944b36b8a77bb55297813da3f0982bfe2584cf24d0197286ecc8819012102b42731c4b6ec382d6889878072cd342067976eafa49e32465e44dabea3c1865affffffff020046c323000000001976a91480f6016d03ca2198d2bc74a6c887f0d1501ca8d588ac95e3cc1d000000001976a914bfb1f67bcaaa7b49979377e027ea1e693b4cac0088ac00000000"); org.bitcoinj.core.Transaction btx8 = new org.bitcoinj.core.Transaction(this.netParams, bytex8); Transaction tx8 = new Transaction("a5b003f1edd4444d8de9fb86097c4790158c545c4ffcaad9a8d92fad3ff88161",btx8,false,true); byte[] bytex9 = adapter.unmarshal("0100000002dc9055a01974444eb293434d159f5ee321514f58b22336c8410b0789f4edc702000000006a473044022029653ab637be76a7673c561843d4686a3c9c2a6d11dbc2934a7264cbe7364d5a022025c34e05a78fc47efeef1f2f5e3390abf3133ed9910a16cbebf4f682f69acbb7012103eefd47852fe88d1f3391f2bbc1cf62d61327971e560819ea053c4c16b19680c3ffffffffcc38cfe25972f0be05da68581dba57c1f143b0069bdee2cf02a849ae47de861c000000006a47304402201d114868eeffa5f09bc6b1c6efe0c7c02516ad1186a54d330ce43564048a11ec02202bf19a775d1fa3b915fc085463a56bdbcfda48efece795eee35df0141d52b853012102da00dc5013cfe328b5c31a6e0c7c71bafbea4f8d7c10b2018808e0ca00e41e4cffffffff02fedcbe1d000000001976a914baf01e398ef7a41bb5a05733615db0ebbd1f0cdd88ac0046c323000000001976a91480e7a71a6b7c31d5be86b65b23a9e14b0658824d88ac00000000");
byte[] bytes = adapter.unmarshal(hexString); return bytes;
ECKey privKey1 = ECKey.fromPrivate(Hex.decode("bd28acf50b7304b098aefa12fd1bb1cbeb4975cc20e86055b3b9ea65b1c80972")); ECKey privKey2 = ECKey.fromPrivate(Hex.decode("224de2bacfba369f854e8db918540d40f45f7459c83f8b47a9501306bce29715")); byte[] parentBytes1 = adapter.unmarshal("01000000013607cf0cd0c29a6b5d6dd4d7e95c85be0577ee62bf3685c26ea6f36a55bba167000000006b483045022100c75ca43c81d9ecd0aaf1327b80512c1f386accbe2684ae8bcd302bc6e164979f02203efbc08bc5aaaaeb98cda97adf34903f67b803c364b0dde03c9284891d5fc2ee012102834755244b98488d24dd643c81403f0660abf9dff5804ce7d1a2076924e45862ffffffff01a001da60000000001976a914dea86c67b46e5d5bd89ab24d40590f871591ffae88ac00000000"); byte[] parentBytes2 = adapter.unmarshal("01000000018fff9cf295ab3545b974b4dbf87c8cf268f93b4fd88b0acfb9504ca187e1e548000000006a4730440220709d86aa33fabee055f6df16596ac3f171465edd1551856d46ce31a9a9b7bfb202204e482f8d2161322fc7665ad9184f5f0910934cf92b6b91e4176ba17982ee6948012103a3b087c39703146c561c7e9ddd9637de3176e2dfba1773307d9c6e7a5373fd25ffffffff01f0c6f601000000001976a9149c294ec749de349f114e19a32b6c3c585aa0f83588ac00000000"); Transaction parentTx1 = new Transaction(mock.netParams, parentBytes1); Transaction parentTx2 = new Transaction(mock.netParams, parentBytes2); byte[] parentBytes3 = adapter.unmarshal("01000000018ae4722cc5174589e386bf67dda5d7572636812b302b0f9abe43dd602f043517010000006a473044022016c8b29e15135271ea7ecd76d4963f69d50bf932ad8ab9e9366aa5ddb0193816022062814e4dfff12124747554e117a80e164a7eef3882f38ec7b2c965d9c95af35d01210359374b5da4105fe505d46a65d3372b3bfbf26e299473b10ae34e65313db408d4feffffff0240164000000000001976a914191697ea01d67e6a981ead0ad719aa52d62989e088ace0c86d07000000001976a9148b0adad35d2f13a6894e248fd2f1fc18a977909c88ac84120e00"); byte[] parentBytes4 = adapter.unmarshal("01000000018fff9cf295ab3545b974b4dbf87c8cf268f93b4fd88b0acfb9504ca187e1e548000000006a4730440220709d86aa33fabee055f6df16596ac3f171465edd1551856d46ce31a9a9b7bfb202204e482f8d2161322fc7665ad9184f5f0910934cf92b6b91e4176ba17982ee6948012103a3b087c39703146c561c7e9ddd9637de3176e2dfba1773307d9c6e7a5373fd25ffffffff01f0c6f601000000001976a9149c294ec749de349f114e19a32b6c3c585aa0f83588ac00000000"); Transaction parentTx3 = new Transaction(mock.netParams, parentBytes3); Transaction parentTx4 = new Transaction(mock.netParams, parentBytes4);
@Test public void testSigning() throws AddressFormatException { NetworkParameters netParams = TestNet3Params.get(); HexBinaryAdapter adapter = new HexBinaryAdapter(); Context context = Context.getOrCreate(netParams); byte[] bx = adapter.unmarshal("0100000001bd5ee90ffe5eedd67c09c3bb348dd7dc1308800eb221b1c92dda651010519ba3010000006a4730440220467868c0b2ed001a915cca5269b928698bee8aba4fe454e1d775070d9e4041cb02205d1c979dbc75e5dc656c4e9d5969d716a383797bd5ad5df79a13d0d6e3f51ccb012102403adb7674f25212bc8cf4a97797154a4980c60e9f328c90300b71a8a04389c7ffffffff024088db60000000001976a914990628d3670f439a5f9e0dfa6492b8bbf3b3fa1b88ac76cf6edd050000001976a914b679378d01ee7203a454bca2ad25698ef23a056388ac00000000"); org.bitcoinj.core.Transaction testbx = new org.bitcoinj.core.Transaction(netParams, bx); org.bitcoinj.core.Transaction tx = new org.bitcoinj.core.Transaction(netParams); tx.addOutput(org.bitcoinj.core.Coin.SATOSHI.multiply(testbx.getOutput(0).getValue().value - 50000l), new Address(netParams, "mobDb19geJ66kkQnsSYvN9PNEKNDiNBHEp")); System.out.println(testbx.getOutput(0)); tx.addInput(testbx.getOutput(0)); String seckey = "3EC95EBFEDCF77373BABA0DE345A0962E51344CD2D0C8DBDF93AEFD0B66BE240"; byte[] privkey = Hex.decode(seckey); ECKey ecPriv = ECKey.fromPrivate(privkey); Sha256Hash hash2 = tx.hashForSignature(0, testbx.getOutput(0).getScriptPubKey().getProgram(), Transaction.SigHash.ALL, false); ECKey.ECDSASignature ecSig = ecPriv.sign(hash2); TransactionSignature txSig = new TransactionSignature(ecSig, Transaction.SigHash.ALL, false); Script inputScript = ScriptBuilder.createInputScript(txSig, ECKey.fromPublicOnly(ecPriv.getPubKey())); tx.getInput(0).setScriptSig(inputScript); String hexBin = DatatypeConverter.printHexBinary(tx.bitcoinSerialize()); System.out.println(hexBin); tx.getInput(0).verify(testbx.getOutput(0)); // SUCCESSFULLY BROADCAST WOO! }