I'd suggest looking for a different approach here. I don't what is the
purpose of use here so it's hard to make a recommendation, but if memory
serves then each wallet object probably consumes at least 300 MB of RAM due
to blockchain related objects (which is why I ultimately moved to different
solution for my use case, but I digress). What you could try (and I am no
bitcoinj expert) is attempt to make wallets that share block chain related
stuff (i.e. block store, blockchain etc.) though I am not sure bitcoinj
allows for such approach to be used. Also if it's possible maybe creating a
wallet for every user is not necessary.
These are my 2 cents on this question. And I am mostly speaking as
developer/designer here.
On Tuesday, November 14, 2017 at 7:21:23 AM UTC+2, Ajit Soman wrote:
>
> Could you suggest any solution for this issue. I have also tried to save
> wallet object in database using WalletProtoBuf but i was not able to
> synchronize wallet and also faced issues like balance mismatch and dead
> transaction , so i revert back to my previous approach (HashMap).
>
> Based on your reply bitcoinj is not suitable for creating web application .
>
> It would be great, if you could able to suggest some solution to solve
> this issue because we are using bitcoinj in 4 project . 1 project is in
> production with around 700 users.
>
>
> On Tuesday, November 14, 2017 at 1:00:18 AM UTC+5:30, Andreas Schildbach
> wrote:
>>
>> It's known issue. Bitcoinj is designed around the assumption of approx.
>> one wallet per device (or at least only a low number). The "webwallet"
>> usecase has always been excluded.
>>
>>
>> On 11/13/2017 06:32 PM, Ajit Soman wrote:
>> > I have a java web application. When ever a user signup i create a
>> wallet
>> > for them. I use the below code to create wallet for user and put that
>> > wallet object in Map<String,Wallet>.
>> >
>> > |
>> > /**
>> > * This is the global map that maintain wallet across application. When
>> ever
>> > * i have to get balance or make transaction i use wallet object in the
>> map.
>> > *
>> > * The main reason for doing this is that Wallet object in map will
>> always
>> > * be in synchronization with the blockchain
>> > */
>> > Map<String,Wallet>applicationWalletMap =newHashMap<String,Wallet>();
>> >
>> >
>> > publicvoidcreateWalletForUser()throwsIOException{
>> > intbits =128;
>> > SecureRandomrandom =newSecureRandom();
>> > DeterministicKeyChaindeterminstickeychain
>> > =newDeterministicKeyChain(random,bits);
>> > DeterministicSeedseed =determinstickeychain.getSeed();
>> > System.out.println("seed "+seed.getSeedBytes());
>> > Walletwallet =Wallet.fromSeed(TestNet3Params.get(),seed);
>> > ECKeyeckey =newECKey();
>> > wallet.importKey(eckey);
>> > StringfileName =UUID.randomUUID().toString();
>> > wallet.saveToFile(newFile("/opt/"+fileName+".dat"));
>> > System.out.println("Wallet has been created");
>> > applicationWalletMap.put(fileName,wallet);
>> > }
>> > |
>> >
>> >
>> >
>> > Also I put all user's synchronized wallet object in
>> > *applicationWalletMap *when i start web application.
>> >
>> > The issue is that when user keep on increasing the size
>> > of *applicationWalletMap *increases. *This consumes a lot of RAM*. So
>> is
>> > there is any efficient way to handle this problem.
>> >
>> > Thanks in advance
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "bitcoinj" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an email to [email protected]
>> > <mailto:[email protected]>.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
--
You received this message because you are subscribed to the Google Groups
"bitcoinj" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.