比特币RPC API中文手册

区块链API
GetBestBlockHash GetBlock GetBlockChainInfo GetBlockCount GetBlockHash GetBlockHeader GetChainTips GetDifficulty GetMemPoolAncestors GetMemPoolDescendants GetMemPoolEntry GetMemPoolInfo GetRawMemPool GetTxOut GetTxOutProof GetTxOutSetInfo PreciousBlock PruneBlockChain VerifyChain VerifyTxOutProof
节点控制API
GetInfo Help Stop
区块构造与挖矿API
Generate GenerateToAddress GetBlockTemplate GetMiningInfo GetNetworkHashPS PrioritiseTransaction SubmitBlock
P2P网络通信API
AddNode ClearBanned DisconnectNode GetAddedNodeInfo GetConnectionCount GetNetTotals GetNetworkInfo GetPeerInfo ListBanned Ping SetBan SetNetworkActive
裸交易相关API
CreateRawTransaction FundRawTransaction DecodeRawTransaction DecodeScript GetRawTransaction SendRawTransaction SignRawTransaction
工具类
CreateMultiSig EstimateFee EstimatePriority GetMemoryInfo ValidateAddress VerifyMessage
钱包相关
AbandonTransaction AddWitnessAddress AddMultiSigAddress BackupWallet BumpFee DumpPrivKey DumpWallet EncryptWallet GetAccountAddress GetAccount GetAddressesByAccount GetBalance GetNewAddress GetRawChangeAddress GetReceivedByAccount GetReceivedByAddress GetTransaction GetUnconfirmedBalance GetWalletInfo ImportAddress ImportMulti ImportPrunedFunds ImportPrivKey ImportWallet KeyPoolRefill ListAccounts ListAddressGroupings ListLockUnspent ListReceivedByAccount ListReceivedByAddress ListSinceBlock ListTransactions ListUnspent LockUnspent Move RemovePrunedFunds SendFrom SendMany SendToAddress SetAccount SetTxFee SignMessage SignMessageWithPrivKey WalletLock WalletPassphrase WalletPassphraseChange

EncryptWallet

encryptwallet调用使用指定的密文加密钱包。该操作只需调用一次,一旦启用加密, 每次需要使用钱包中的密钥时,就需要输入密文。

如果在命令行使用这个调用,需要注意你使用的shell可能会保存输入的命令(包括输入 的密文)。另外,一旦钱包启用加密,目前没有其他的RPC接口可以禁用其加密。如果 需要一个不加密的钱包,你只能再创建一个新的钱包,然后使用dumpwallet调用的 输出来恢复加密钱包中的密钥。

参数

  • Passphrase:用于加密钱包的密文,最短1个字符

返回值

encryptwallet调用将返回一个提醒信息,提示钱包已加密、节点重启。

示例代码

下面命令使用密码test加密钱包:

~$ bitcoin-cli -testnet encryptwallet "test"

输出如下:

wallet encrypted; Bitcoin server stopping, restart to run with encrypted
wallet. The keypool has been flushed, you need to make a new backup.