Comments (4)
Hi,
There's no real benefits to having an additional config value for passphrase, but it introduces issue with multi-wallet support as well as adds additional complication of having list of methods that require passphrase in client and keeping this list up to date with current Bitcoin Core API.
Hovewer, you can just call WalletPassphrase
method before issuing your other commands, that require unlocked wallet, and calling WalletLock
after you done.
$bitcoind->walletPassphrase('your_passphrase', 60);
...
// do your operations, that require wallet passphrase here
...
$bitcoind->walletLock();
For convenience sake, you can wrap it in function like this:
use Denpa\Bitcoin\Client as BitcoinClient;
function walletUnlock(BitcoinClient $bitcoind, string $passphrase, callable $fn, int $timeout = 60) : void {
if ($fn) {
$bitcoind->walletPassphrase($passphrase, $timeout);
$fn($bitcoind)
$bitcoind->walletLock();
}
}
// then call it like this
walletUnlock($bitcoind, 'your_passphrase', function($bitcoind) {
// do your operations, that require wallet passphrase here, e. g.
// $bitcoind->sendToMany(...);
});
That being said, having encrypted wallet and storing passphrase in plain text kind of defeats a whole purpoise of having an encrypted wallet anyway...
from php-bitcoinrpc.
Thank you @denpamusic for the reply. I thought using such config may let developer to have less coding for each transaction. However, it is a practical way.
Regarding to your last sentence, I think having a wallet without passphrase is dangerous, and developing a platform based on an encrypted wallet has another danger of using that passphrase in the codes. The only thing I can imagine is having an encrypted file containing that passphrase.
from php-bitcoinrpc.
Thank you for you feedback.
I understand your idea. If possible I still don't want to maintain a list of methods requiring unlocked wallet, since one of advantages of this client is that it doesn't require any update when Core API changes in any way.
If you're ok with manually telling client when you need to unlock wallet, I can implement such configuration parameter using the method I've mentioned above:
use Denpa\Bitcoin\Client as BitcoinClient;
$bitcoind = new BitcoinClient([
...
'passphrase' => 'your_passphrase',
...
]);
// when you'll need to execute some commands that require passphrase,
// you'll do it like this:
$bitcoind->withPassphrase(function ($bitcoind) {
$bitcoind->sendToMany(...);
...
});
from php-bitcoinrpc.
@denpamusic, thank you for your attention.
As using passphrase needs a time in seconds too, and it may differ for each Bitcoin Core action, I think the best solution is unlocking the wallet for each action (Your first reply). Having a fixed time duration in the config is not practical as methods may need different time periods.
$bitcoind->walletPassphrase('your_passphrase', 60);
...
// do your operations, that require wallet passphrase here
...
$bitcoind->walletLock();
from php-bitcoinrpc.
Related Issues (20)
- Different requirements in README.md and in composer.json HOT 3
- Support multi-wallet RPC calls
- Linux 500 Internal Server Error when attempting to make request HOT 5
- Danger! Re-sends RPC call on failure HOT 4
- withdrawal Requests
- bitcoin.conf options HOT 6
- Batch support HOT 2
- ListTransactions HOT 4
- How to create createrawtransaction i meet something wrong
- Command orders are important, whereas it shouldn't be on non-static usages.
- composer fails due to new Guzzle 7.0.1 with Laravel 7 HOT 2
- sendmany fails when passing valid json string HOT 4
- How library works HOT 1
- Method adrressbylabel response answer all directions HOT 1
- In simple HOT 3
- setaccount can only be used with own address
- Should not use set_exception_handler HOT 3
- How connect to third party RPC
- $bitcoind->sendToAddress and next steps
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-bitcoinrpc.