mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-18 12:44:19 +01:00
Add Faucet endpoint (#36)
* Add internal methods for faucet feature * Add grpc handler * Lint
This commit is contained in:
committed by
GitHub
parent
6344005785
commit
9e9e61fb89
33
asp/internal/interface/grpc/handlers/utils.go
Normal file
33
asp/internal/interface/grpc/handlers/utils.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
|
||||
"github.com/ark-network/ark/common"
|
||||
"github.com/vulpemventures/go-elements/psetv2"
|
||||
)
|
||||
|
||||
func parseTxs(txs []string) ([]string, error) {
|
||||
if len(txs) <= 0 {
|
||||
return nil, fmt.Errorf("missing list of forfeit txs")
|
||||
}
|
||||
for _, tx := range txs {
|
||||
if _, err := psetv2.NewPsetFromBase64(tx); err != nil {
|
||||
return nil, fmt.Errorf("invalid tx format")
|
||||
}
|
||||
}
|
||||
return txs, nil
|
||||
}
|
||||
|
||||
func parseAddress(addr string) (string, error) {
|
||||
if len(addr) <= 0 {
|
||||
return "", fmt.Errorf("missing address")
|
||||
}
|
||||
_, userPubkey, _, err := common.DecodeAddress(addr)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("invalid address: %s", err)
|
||||
}
|
||||
pubkey := hex.EncodeToString(userPubkey.SerializeCompressed())
|
||||
return pubkey, nil
|
||||
}
|
||||
Reference in New Issue
Block a user