Currently, I did it using bitcoind's RPC interface, calling it from a shell script and checking the output with command line tools like 'cut' and 'grep'. and at the beginning it works alright for the new address, its controllable. but after some time, it is not working again. "18: bad-txns-inputs-spent"
I believe that it happens because the time when we don't try to control the transaction id, there are many addresses for change created. and next time we try to control again, its spent.
therefore , could we set up the address for change as the sending address? and how to set it up plz?
Using raw transaction api you must always take care yourself about change and change address. Everything that remains unspent in the tx, i.e. has no explicit output, is considered as a tx fee.