zcash / zcash

Zcash - Internet Money
https://z.cash/
Other
4.93k stars 2.03k forks source link

Add `z_sendfromaccount` method to supersede `z_sendmany` #6123

Open nuttycom opened 2 years ago

nuttycom commented 2 years ago

The API of z_sendmany is no longer appropriate when using unified addresses; it misleads people to think that unified addresses can represent distinct pools of funds (and perpetuates a similar problem related to spending from legacy transparent addresses, see #6113.). Adding, z_sendfromaccount will help clarify this usage.

z_sendfromaccount should take the following arguments:

fromAccount [{\"address\":... ,\"amount\":...},...] ( minconf ) ( fee ) ( privacyPolicy )

It should follow the pattern of z_sendmany, but accept an integer account ID instead of an address as the source of funds. z_sendfromaccount should perform opportunistic shielding when permitted by the privacy policy: if there are any shielded recipients, all transparent UTXOs available within the account should be spent, with change being sent to the account's internal change address.

An alternative is to overload the fromaddress field of the z_sendmany call to default to parsing its value as an account identifier if parsing an address fails, but perhaps we shouldn't have added unified address parsing (in favor of parsing as an account ID) in the first place.

nuttycom commented 2 years ago

After z_sendfromaccount is introduced, z_sendmany should be modified to deprecate unified address parsing.

gesker commented 2 years ago

Which address will be used if the account has multiple addresses? I.e. z_getaddressforaccount has been called on an account more than once?

First, last, random?

Or, an optional parameter to specify the UA within the account on the z_sendfromaccount?

Maybe a corresponding helper method (e.g. z_sendFromUaAddressOrSomething) that will just take an UA address and determine which account the address belongs to if the address belongs to your wallet -- the wallet having had z_getnewaccount called a number of times in conjunction with z_getaddressforaccount also being called a number of times for each account?

nuttycom commented 2 years ago

You can use any unified address associated with an account to send from that account.

On Sat, Aug 20, 2022 at 1:04 PM Dennis Gesker @.***> wrote:

Which address will be used if the account has multiple addresses? I.e. z_getaddressforaccount has been called on an account more than once?

First, last, random?

Or, an optional parameter to specify the UA within the account on the z_sendfromaccount?

Maybe a corresponding helper method (e.g. z_sendFromUaAddressOrSomething) that will just take an UA address and determine which account the address belongs to if the address belongs to your wallet -- the wallet having had z_getnewaccount called a number of times in conjunction with z_getaddressforaccount also being called a number of times for each account?

— Reply to this email directly, view it on GitHub https://github.com/zcash/zcash/issues/6123#issuecomment-1221388012, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAGXR74V2YEEEUH4TBAZO3V2ET5RANCNFSM57A52W5Q . You are receiving this because you authored the thread.Message ID: @.***>

--

Kris Nuttycombe

Lead Engineer

@.*** | @nuttycom https://twitter.com/nuttycom

gesker commented 2 years ago

Is an integer (account number) or string (address) passed the the new method?

Or, both?

Use this address from this account?

On Aug 20, 2022, at 16:14, Kris Nuttycombe @.***> wrote:

 You can use any unified address associated with an account to send from that account.

On Sat, Aug 20, 2022 at 1:04 PM Dennis Gesker @.***> wrote:

Which address will be used if the account has multiple addresses? I.e. z_getaddressforaccount has been called on an account more than once?

First, last, random?

Or, an optional parameter to specify the UA within the account on the z_sendfromaccount?

Maybe a corresponding helper method (e.g. z_sendFromUaAddressOrSomething) that will just take an UA address and determine which account the address belongs to if the address belongs to your wallet -- the wallet having had z_getnewaccount called a number of times in conjunction with z_getaddressforaccount also being called a number of times for each account?

— Reply to this email directly, view it on GitHub https://github.com/zcash/zcash/issues/6123#issuecomment-1221388012, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAGXR74V2YEEEUH4TBAZO3V2ET5RANCNFSM57A52W5Q . You are receiving this because you authored the thread.Message ID: @.***>

--

Kris Nuttycombe

Lead Engineer

@.*** | @nuttycom https://twitter.com/nuttycom — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.

gesker commented 2 years ago

Or, is this basically just a renaming of z_sendmany to z_sendfromaccount?

On Aug 21, 2022, at 09:57, Dennis Gesker @.***> wrote:

 Is an integer (account number) or string (address) passed the the new method?

Or, both?

Use this address from this account?

On Aug 20, 2022, at 16:14, Kris Nuttycombe @.***> wrote:

 You can use any unified address associated with an account to send from that account.

On Sat, Aug 20, 2022 at 1:04 PM Dennis Gesker @.***> wrote:

Which address will be used if the account has multiple addresses? I.e. z_getaddressforaccount has been called on an account more than once?

First, last, random?

Or, an optional parameter to specify the UA within the account on the z_sendfromaccount?

Maybe a corresponding helper method (e.g. z_sendFromUaAddressOrSomething) that will just take an UA address and determine which account the address belongs to if the address belongs to your wallet -- the wallet having had z_getnewaccount called a number of times in conjunction with z_getaddressforaccount also being called a number of times for each account?

— Reply to this email directly, view it on GitHub https://github.com/zcash/zcash/issues/6123#issuecomment-1221388012, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAGXR74V2YEEEUH4TBAZO3V2ET5RANCNFSM57A52W5Q . You are receiving this because you authored the thread.Message ID: @.***>

--

Kris Nuttycombe

Lead Engineer

@.*** | @nuttycom https://twitter.com/nuttycom — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.

nuttycom commented 2 years ago

Is an integer (account number) or string (address) passed the the new method? Or, both? Use this address from this account?

Oops, I think I got confused about what thread I was responding to. Within a single account, there is no distinction between the different addresses; the account is treated as a single source of funds, and which (diversified) address funds were received on is not tracked, so to implement z_sendfromaccount the account ID should be an integer argument.

gesker commented 1 year ago

if z_getaddressforaccount is called twice on an account which address does the recipient see when funds are sent using z_sendfromaccount?

nuttycom commented 1 year ago

if z_getaddressforaccount is called twice on an account which address does the recipient see when funds are sent using z_sendfromaccount?

@gesker The recipient never sees the sender's address under any circumstances (unless the sender manually includes their address in the memo field or something), so I'm not sure I understand this question.

gesker commented 1 year ago

Thank @nuttycom.