Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command orders are important, whereas it shouldn't be on non-static usages. #54

Open
ahmeteminkocal opened this issue Jul 6, 2020 · 0 comments

Comments

@ahmeteminkocal
Copy link

       $free = $this->getWallet("emptyWallet");
        $address = $free->request("getnewaddress")->get();
        $amount = $free->request("getbalance")->get();
        $main = $this->getWallet("mainWallet");

        var_dump($main->request("sendtoaddress", $address, $amount, "payment", "user", true, false, null, 'CONSERVATIVE')->get());

when you do this is works, but if you declare $main before $free variable, it mixes up things. This means it is bound to some static variables on backend. So, if you do write the code in the following order;

      $main = $this->getWallet("mainWallet");
      $free = $this->getWallet("emptyWallet");

        $address = $free->request("getnewaddress")->get();
        $amount = $free->request("getbalance")->get();


        var_dump($main->request("sendtoaddress", $address, $amount, "payment", "user", true, false, null, 'CONSERVATIVE')->get());

It will give you "Insufficent Funds" error, as it will try to use the last active wallet's balance. "getWallet" function should not be static variable bound. Normally if you save it in memory on $main variable, when you use $main variable, it should point to the state of its declaration no matter which variable you change afterwards, as long as you don't change the main variable.

If it is working as non-static library, it should be completely compatible with it.

To reproduce this problem,
Just create two wallets, one of them should be empty. Put the empty wallet to $free variable section and the other to the $main. The second code group I sent will give you "Insufficent Funds" error no matter how much you have on the main wallet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant