Title: block.io - create new address for existing label Post by: Slater8021 on December 03, 2022, 04:02:34 PM Hi,
I use the block.io API and want to add another address to an existing label. $user = 'anyone' $getNewUserAddress = $block_io->get_new_address(array('label' => $user)); I am using PHP. How do I do that? Many thanks for your help! Title: Re: block.io - create new address for existing label Post by: n0nce on December 03, 2022, 05:11:45 PM Their docs say (https://block.io/docs/basic): 'Returns a newly generated address, and its unique(!) label generated by Block.io. You can optionally specify a custom label.' with exclamation mark.
I'm pretty sure there's no way to get 2 addresses with the same label; it's probably used internally to uniquely identify those addresses. May I ask why you're even using a 'Wallet as a Service' in the first place, though? :-\ They can run with your funds at any time (like any other such service): Quote from: https://block.io/terms We will not be responsible or liable to you for any loss and take no responsibility for damages or claims arising in whole or in part, directly or indirectly from: (a) user error such as forgotten passwords, incorrectly constructed transactions, or mistyped Virtual Currency addresses; (b) server failure or data loss; (c) corrupted or otherwise non-performing Wallets or Wallet files; (d) unauthorized access to applications; (e) any unauthorized activities, including without limitation the use of hacking, viruses, phishing, brute forcing or other means of attack against the Services. Title: Re: block.io - create new address for existing label Post by: Slater8021 on December 03, 2022, 06:23:11 PM Thanks for your answer. But why does the doc say the following?
"With Block.io, you can create wallet addresses for users inside your games, auction sites, stores, etc. To create a user's wallet on your account, create addresses for them using get_new_address. You should specify a sequence of labels for that user. For instance, if you wish to create a number of addresses for User A, you would want to call get_new_address with label=userAx{address_number} as many times as you wish to create a new address for User A. Once you have addresses for User A, you can perform relevant actions for their addresses."??? And that's exactly what I want to do in PHP. I remember that it could be realized via block.io with forwarding_addresses some time ago. But that is apparently no longer possible, for whatever reason. And yes, you are welcome to ask. I'm building some kind of asset safe for friends with some features. The user should simply be able to generate a new receiving address, which can also be clearly assigned to his wallet. Title: Re: block.io - create new address for existing label Post by: n0nce on December 04, 2022, 01:42:50 AM Quote you would want to call get_new_address with label=userAx{address_number} as many times as you wish to create a new address for User A. And that's exactly what I want to do in PHP.Code: <?php Basically, you pick a prefix that is unique per user (like userA-) and then append a number that keeps increasing. That way you can tell which addresses belong to which user, and it's easy to keep track and add new addresses (look at last one, increment number by one). And yes, you are welcome to ask. I'm building some kind of asset safe for friends with some features. The user should simply be able to generate a new receiving address, which can also be clearly assigned to his wallet. Did you read those terms? You don't want to lose your friends money, do you? Title: Re: block.io - create new address for existing label Post by: Slater8021 on December 04, 2022, 11:02:43 AM Thank you for inspiration. I will test your approach.
And no, don't worry. My somewhat stupid question does not reflect the quality of my approach. I have been handling Bitcoin for a few years, if not programmatically. But briefly on the topic: I just hope that it also performs well with the server side with increasing number of addresses. Nevertheless, I found it better with forwarding addresses. Did you still have experiences with similar services? Read me something. Title: Re: block.io - create new address for existing label Post by: Slater8021 on December 05, 2022, 09:20:38 AM Quote you would want to call get_new_address with label=userAx{address_number} as many times as you wish to create a new address for User A. And that's exactly what I want to do in PHP.Code: <?php Your approach is not really effective. You are assuming standard terms. In your approach, you randomly generate 10 addresses. It is more effective here to first find out which is the highest value after the user (user-?), for which addresses already exist. But even thinking further, it would most likely lead to problems, at the latest when it comes to allocating the accumulated credit of each address to the actual user. Programmatically, this would be a shambles. The approach of so-called forwarding addresses would be much more useful here. It's all about matching the amount deposited through different addresses for a specific user to a root wallet. Title: Re: block.io - create new address for existing label Post by: n0nce on December 05, 2022, 01:35:24 PM Did you still have experiences with similar services? Read me something. No; I don't use nor recommend any such service, because you are giving away your keys. Not your keys.. Remember?Your approach is not really effective. You are assuming standard terms. In your approach, you randomly generate 10 addresses. It is more effective here to first find out which is the highest value after the user (user-?), for which addresses already exist. But even thinking further, it would most likely lead to problems, at the latest when it comes to allocating the accumulated credit of each address to the actual user. Programmatically, this would be a shambles. The approach of so-called forwarding addresses would be much more useful here. It's all about matching the amount deposited through different addresses for a specific user to a root wallet. Of course, this is just a proof of concept to show you how it's done. You'd want to keep track of each user's highest used address index e.g. in a database, fetch that number, increment by one, save it to DB again, construct the new address label and fetch a new address with that label from your wallet provider.Accumulating balances would just require you to query all userA-* addresses and add the results. I don't see a problem with that. Title: Re: block.io - create new address for existing label Post by: Slater8021 on December 05, 2022, 08:11:58 PM Of course, this is just a proof of concept to show you how it's done. You'd want to keep track of each user's highest used address index e.g. in a database, fetch that number, increment by one, save it to DB again, construct the new address label and fetch a new address with that label from your wallet provider. Accumulating balances would just require you to query all userA-* addresses and add the results. I don't see a problem with that. The more you think about it, the clearer the picture becomes. The only question is whether it is the best practice solution? Suppose a user would like to one day pay off his entire balance, which is shown to him from the database but is located at, say, 4 addresses. Doesn't he then pay transaction fees four times? Another question that comes to my mind now: How do I deal with the accumulated credit on different addresses of a user in advance? Title: Re: block.io - create new address for existing label Post by: n0nce on December 05, 2022, 08:40:15 PM Of course, this is just a proof of concept to show you how it's done. You'd want to keep track of each user's highest used address index e.g. in a database, fetch that number, increment by one, save it to DB again, construct the new address label and fetch a new address with that label from your wallet provider. Accumulating balances would just require you to query all userA-* addresses and add the results. I don't see a problem with that. The more you think about it, the clearer the picture becomes. The only question is whether it is the best practice solution? Suppose a user would like to one day pay off his entire balance, which is shown to him from the database but is located at, say, 4 addresses. Doesn't he then pay transaction fees four times? Another question that comes to my mind now: How do I deal with the accumulated credit on different addresses of a user in advance? More about inputs / outputs here: link (https://en.bitcoin.it/wiki/Transaction#Input) and link (https://en.bitcoin.it/wiki/Transaction#Output). This means if you don't use the exchange model, you can also use multiple balances of a user (in your example 4) as inputs and send them to one output address. That saves fees compared to doing 4 individual transactions, but costs more than a 1-input transaction due to taking up more space on the blockchain. |