本文整理汇总了Golang中github.com/skycoin/skycoin-exchange/src/server/engine.Exchange.WatchAddress方法的典型用法代码示例。如果您正苦于以下问题:Golang Exchange.WatchAddress方法的具体用法?Golang Exchange.WatchAddress怎么用?Golang Exchange.WatchAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/skycoin/skycoin-exchange/src/server/engine.Exchange
的用法示例。
在下文中一共展示了Exchange.WatchAddress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetNewAddress
// GetNewAddress account create new address for depositing.
func GetNewAddress(ee engine.Exchange) sknet.HandlerFunc {
return func(c *sknet.Context) error {
rlt := &pp.EmptyRes{}
for {
req := pp.GetDepositAddrReq{}
if err := c.BindJSON(&req); err != nil {
logger.Error(err.Error())
rlt = pp.MakeErrResWithCode(pp.ErrCode_WrongRequest)
break
}
// validate pubkey
pubkey := req.GetPubkey()
if err := validatePubkey(pubkey); err != nil {
logger.Error(err.Error())
rlt = pp.MakeErrResWithCode(pp.ErrCode_WrongPubkey)
break
}
at, err := ee.GetAccount(pubkey)
if err != nil {
rlt = pp.MakeErrResWithCode(pp.ErrCode_NotExits)
break
}
ct := req.GetCoinType()
// get the new address for depositing
addr := ee.GetNewAddress(ct)
// add the new address to engin for watching it's utxos.
at.AddDepositAddress(ct, addr)
ee.WatchAddress(ct, addr)
ds := pp.GetDepositAddrRes{
Result: pp.MakeResultWithCode(pp.ErrCode_Success),
CoinType: req.CoinType,
Address: &addr,
}
return c.SendJSON(&ds)
}
return c.Error(rlt)
}
}