Esempio n. 1
0
// cmdCreateEncryptedWallet requests btcwallet to create a new wallet
// (or account), encrypted with the supplied passphrase.
func cmdCreateEncryptedWallet(ws *websocket.Conn, params *NewWalletParams) {
	n := <-NewJSONID
	cmd := btcws.NewCreateEncryptedWalletCmd(n, params.passphrase)
	msg, err := json.Marshal(cmd)
	if err != nil {
		triggerReplies.walletCreationErr <- err
		return
	}

	replyHandlers.Lock()
	replyHandlers.m[n] = func(result interface{}, err *btcjson.Error) {
		if err != nil {
			triggerReplies.walletCreationErr <- errors.New(err.Message)
		} else {
			triggerReplies.walletCreationErr <- nil

			// Request all wallet-related info again, now that the
			// default wallet is available.
			for _, f := range walletReqFuncs {
				go f(ws)
			}
		}
	}
	replyHandlers.Unlock()

	if err = websocket.Message.Send(ws, msg); err != nil {
		replyHandlers.Lock()
		delete(replyHandlers.m, n)
		replyHandlers.Unlock()
		triggerReplies.walletCreationErr <- err
	}
}
Esempio n. 2
0
// makeCreateEncryptedWallet generates the cmd structure for
// createencryptedwallet commands.
func makeCreateEncryptedWallet(args []interface{}) (btcjson.Cmd, error) {
	return btcws.NewCreateEncryptedWalletCmd("btcctl", args[0].(string)), nil
}
Esempio n. 3
0
// CreateEncryptedWalletAsync returns an instance of a type that can be used to
// get the result of the RPC at some future time by invoking the Receive
// function on the returned instance.
//
// See CreateEncryptedWallet for the blocking version and more details.
//
// NOTE: This is a btcwallet extension.
func (c *Client) CreateEncryptedWalletAsync(passphrase string) FutureCreateEncryptedWalletResult {
	id := c.NextID()
	cmd := btcws.NewCreateEncryptedWalletCmd(id, passphrase)
	return c.sendCmd(cmd)
}