0
Since I'm using the wonderful accounts feature which is soon to be deprecated (shame on me, i know - but i simply didn't have resources and time as a single person to do an internal accounting system in a few weeks alongside everything else the project contains, this is a school project and will not be deployed), i was wondering how to handle sending transactions & change addresses, without using raw transactions.
Would the following work
SendMany(fromacc, toaddress: amount, 1, "comment", subtractfee)
(I'm planning to use SendMany for single transactions, because it has the subtractfee parameter compared to SendFrom).
Use the resulting TXID to query Blockcypher API (https://api.blockcypher.com/v1/btc/main/txs/b7bf53a74a4e4cb61ab523cc002fc4cea83fb359471d02b212d947cf86fe6077) and "grab" the change address from there (Since Bitcoin Core doesn't allow this wihout using rawtransactions?)
VerifyAddress(changeaddress)
SetAccount(account, changeaddress)
Which means that GetBalance(account) should show the correct balance of the account and not 0?
Or should i really not do that and use rawtransactions instead? :-)
edit:
So i just realised that i confused the subtractfee parameter in SendMany from the one in SendToAddress (which is what i need), so i suppose i need to use that instead.
would using:
$balance = getBalance($myaccount)
move("", $myaccount, $sendingamount, "", "comment")
SendToAddress($receiveaddr, $sendingamount, "comment", "commentto", 1, 0, 6)
do the the blockcypher grab TX id, verifyaddress and set account here
OR
$newBalance = getBalance($myaccount)
$change = $balance - $sendingamount
move("", $myaccount, $change, "", "comment")
Work in this case and would listunspent show the amount under the right account (not "")?
Also here is what I'm trying to do from a user perspective: https://imgur.com/a/IHrF4vI
Why do you need to know the change address? – Andrew Chow – 2018-05-16T16:24:19.837
Instead of asking about the approach that you want to do, you should ask about what it is that you want to accomplish. Otherwise this is an XY problem (http://xyproblem.info/) and it doesn't really make sense to people who can provide you an answer. As it is right now, I don't understand what you are trying to do and what the problem actually is so I cannot provide you a good answer.
– Andrew Chow – 2018-05-16T16:28:27.907Yeah, i apologize. I've been quiet confused about sending transactions and the heat has gotten to me today. I would like for a user with an account to be able to transfer what is available in their balance, that they have received from a generated address. The fee should be deducted from what they're sending, so the receiver gets less. The change address which receives the change should be accessable by the account and should somehow be able to be shown in their balance. So if i send 1BTC of a balance of 2BTC, i would like for my balance to show 1BTC, not 0BTC. – Peter Dalby – 2018-05-16T17:01:52.293
I suppose i have to use raw transactions to accomplish this and directly specify which inputs to use for the transaction? i just heard that it's very likely to make mistakes when using this, and it's for advanced use only. I'd like to keep it as simple as if at all possible... :-) – Peter Dalby – 2018-05-16T17:07:10.037
Also in the example the 2BTC balance should be considered one input which would mean that the entire balance would be empitied for the user when trying to send some of it. I need to show the expected balance :-) – Peter Dalby – 2018-05-16T17:38:22.837