github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/service/cryptocurrency.go (about)

     1  // Copyright 2015 Keybase, Inc. All rights reserved. Use of
     2  // this source code is governed by the included BSD license.
     3  
     4  package service
     5  
     6  import (
     7  	"github.com/keybase/client/go/engine"
     8  	"github.com/keybase/client/go/libkb"
     9  	keybase1 "github.com/keybase/client/go/protocol/keybase1"
    10  	"github.com/keybase/go-framed-msgpack-rpc/rpc"
    11  	"golang.org/x/net/context"
    12  )
    13  
    14  type CryptocurrencyHandler struct {
    15  	*BaseHandler
    16  	libkb.Contextified
    17  }
    18  
    19  func NewCryptocurrencyHandler(xp rpc.Transporter, g *libkb.GlobalContext) *CryptocurrencyHandler {
    20  	return &CryptocurrencyHandler{
    21  		BaseHandler:  NewBaseHandler(g, xp),
    22  		Contextified: libkb.NewContextified(g),
    23  	}
    24  }
    25  
    26  // BTC creates a BTCEngine and runs it.
    27  func (h *CryptocurrencyHandler) RegisterAddress(nctx context.Context, arg keybase1.RegisterAddressArg) (keybase1.RegisterAddressRes, error) {
    28  	uis := libkb.UIs{
    29  		LogUI:     h.getLogUI(arg.SessionID),
    30  		SecretUI:  h.getSecretUI(arg.SessionID, h.G()),
    31  		SessionID: arg.SessionID,
    32  	}
    33  	eng := engine.NewCryptocurrencyEngine(h.G(), arg)
    34  	m := libkb.NewMetaContext(nctx, h.G()).WithUIs(uis)
    35  	err := engine.RunEngine2(m, eng)
    36  	res := eng.Result()
    37  	return res, err
    38  }
    39  
    40  func (h *CryptocurrencyHandler) RegisterBTC(nctx context.Context, arg keybase1.RegisterBTCArg) error {
    41  	uis := libkb.UIs{
    42  		LogUI:     h.getLogUI(arg.SessionID),
    43  		SecretUI:  h.getSecretUI(arg.SessionID, h.G()),
    44  		SessionID: arg.SessionID,
    45  	}
    46  	m := libkb.NewMetaContext(nctx, h.G()).WithUIs(uis)
    47  	eng := engine.NewCryptocurrencyEngine(h.G(), keybase1.RegisterAddressArg{Address: arg.Address, Force: arg.Force})
    48  	return engine.RunEngine2(m, eng)
    49  }