How to create raw transaction

I’ve started creating my own wallet in bitcoinj and I have serious problem. I want to create raw transaction without wallet object. So I wrote this piece of code:

    //String to a private key     DumpedPrivateKey dumpedPrivateKey = DumpedPrivateKey.fromBase58(params,              privKey);     ECKey key = dumpedPrivateKey.getKey();      //String to an address     Address address2 = Address.fromBase58(params, address);      Transaction tx = new Transaction(params);     //value is a sum of all inputs, fee is 4013     tx.addOutput(Coin.valueOf(amount-4013), address2);      //utxos is an array of inputs from my wallet     for(UTXO utxo : utxos)     {         TransactionOutPoint outPoint = new TransactionOutPoint(params, utxo.getIndex(), utxo.getHash());         tx.addSignedInput(outPoint, utxo.getScript(), key);     }      tx.getConfidence().setSource(TransactionConfidence.Source.SELF);     tx.setPurpose(Transaction.Purpose.USER_PAYMENT);      System.out.println(tx.getHashAsString());     b_peerGroup.GetPeerGroup().broadcastTransaction(tx); 

But this ends with:

mandatory-script-verify-flag-failed (Script evaluated without error but finished with a false/empty top stack e

What is wrong with my code?

EDIT: I found a solution. I’ve changed only this line: tx.addSignedInput(outPoint, utxo.getScript(), key, Transaction.SigHash.ALL, true);

Recent Questions – Bitcoin Stack Exchange

Bitcoin’s Next Frontier: Television

New television series cements the digital currency in primetime. Bitcoin has made its way into the popular mind and most recently this can be seen with depictions in television, of which there have been a great many. But, perhaps most interesting, entire series are taking Bitcoin on as the main plot point, further cementing bitcoin’s […]

The post Bitcoin’s Next Frontier: Television appeared first on CCN: Financial Bitcoin & Cryptocurrency News.

News – CCN: Financial Bitcoin & Cryptocurrency News

how to convert byte array to character array in C++ on Linux

how to convert byte array to character array using C programming. I have an uint8_t array of 32 bytes and it should fill into the array of 64 characters. For example: there is a public key of 32 bytes having 64 character and it should stored in the array of 64 characters. We send this through TCP socket through c++ on Linux.

Recent Questions – Bitcoin Stack Exchange