How to send amount that is divided proportionally


I have address t1aaa. On this address I have for example 100 bitcoins. I want to send 10 bitcoins to address t1bbb. When I will send them rest of the funds, 90 bitcoins will be send to the new address t1ccc, because that bitcoins works. So I can set that in z_sendmany I will send 10 bitcoins to t1bbb and 90 bitcoins back to the address t1aaa:
z_sendmany "t1aaa" '[{"address":"t1bbb","amount":10},{"address":"t1aaa","amount":90}]'
But I need do a couple of payments. But I cannot to them in one payment. I need to call a couple of z_sendmany method:
z_sendmany “t1aaa” ‘[{“address”:“t1bbb”,“amount”:10},{“address”:“t1aaa”,“amount”:xx}]’
z_sendmany “t1aaa” ‘[{“address”:“t1ddd”,“amount”:10},{“address”:“t1aaa”,“amount”:xx}]’
z_sendmany “t1aaa” ‘[{“address”:“t1eee”,“amount”:10},{“address”:“t1aaa”,“amount”:xx}]’
And the problem is how to calculate amount that have to be send back to my address t1aaa to avoid creating additional address. All payment have to be send in one transaction. I’m not able to calculate amount xxx in every payment because all payments are doing in different requests.

To completely clear an addresses you can send exactly the amount in the address, minus the 0.0001 ZEC fee. This will bring the balance to zero and not send change to a new address.

Ok, I forgot about fee. So it should be xxx - 0.0001. But still the problem exists how to calculate the xxx amount. First payment will be 90-10-0.0001. But how to calculate second payment when we don’t know the amount that is sent in the first payment ?

I don’t understand how you expect to send funds if you don’t know the starting balance?

If you have a first balance, you will need to subtract each balance (minus the fee) from the previous.

Or better yet, start using Z-addresses where the change is always sent back to the same address. That way you don’t have to worry about change addresses at all :grin:

I know the starting balance. On address t1aaa I have 100 bitcons. When I will made payment like this: z_sendmany “t1aaa” ‘[{“address”:“t1bbb”,“amount”:10}]’
on address t1bbb will be send 10 bitcoins, fee will be 0.0001 bitcoin and 89.9999 will be send to new address, generated by bitcoin, for example t1zzz. On address t1aaa will be zero bitcoins.
I won’t to send rest of my bitcoins to address t1zzz, so I can set two payments, and amount 89.9999 I can send back on address t1aaa. Am I right ?

This will generate the code but only a single payment amount, just change the amounts for the subsequent addresses (also note it is designed for Z addresses)


zcash-cli z_sendmany “Taaa” “[{“address”: “Tbbb”,“amount”: 10, “memo”:”"},{“address”: " Tzzz",“amount”: 89.999, “memo”:""}]"