mirror of
https://github.com/aljazceru/ark.git
synced 2026-02-20 18:34:19 +01:00
* CLI skeleton * noah CLI: send flags * add cypher.go file * fix .PHONY * add password_hash in state.json * encode public key using common pkg * use common.DecodeUrl * remove cli.Exit calls * redeem command: make --amount flag optional only if --force is not set * remove validateURL func * chmod +x scripts/build-noah * Update cmd/noah/redeem.go Co-authored-by: João Bordalo <bordalix@users.noreply.github.com> * Update cmd/noah/redeem.go Co-authored-by: João Bordalo <bordalix@users.noreply.github.com> * Update cmd/noah/init.go Co-authored-by: João Bordalo <bordalix@users.noreply.github.com> * Update cmd/noah/main.go Co-authored-by: João Bordalo <bordalix@users.noreply.github.com> * Update cmd/noah/send.go Co-authored-by: João Bordalo <bordalix@users.noreply.github.com> * rework receive and send * Update cmd/noah/send.go Co-authored-by: João Bordalo <bordalix@users.noreply.github.com> * Update cmd/noah/send.go Co-authored-by: João Bordalo <bordalix@users.noreply.github.com> * Update cmd/noah/redeem.go Co-authored-by: João Bordalo <bordalix@users.noreply.github.com> * receive command: return ark address --------- Co-authored-by: bordalix <joao.bordalo@gmail.com> Co-authored-by: João Bordalo <bordalix@users.noreply.github.com>
68 lines
1.3 KiB
Go
68 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
var (
|
|
addressFlag = cli.StringFlag{
|
|
Name: "address",
|
|
Usage: "main chain address receiving the redeeemed VTXO",
|
|
Value: "",
|
|
Required: true,
|
|
}
|
|
|
|
amountToRedeemFlag = cli.Uint64Flag{
|
|
Name: "amount",
|
|
Usage: "amount to redeem",
|
|
Value: 0,
|
|
Required: false,
|
|
}
|
|
|
|
forceFlag = cli.BoolFlag{
|
|
Name: "force",
|
|
Usage: "force redemption without collaborate with the Ark service provider",
|
|
Value: false,
|
|
Required: false,
|
|
}
|
|
)
|
|
|
|
var redeemCommand = cli.Command{
|
|
Name: "redeem",
|
|
Usage: "Redeem VTXO(s) to onchain",
|
|
Flags: []cli.Flag{&addressFlag, &amountToRedeemFlag, &forceFlag},
|
|
Action: redeemAction,
|
|
}
|
|
|
|
func redeemAction(ctx *cli.Context) error {
|
|
address := ctx.String("address")
|
|
amount := ctx.Uint64("amount")
|
|
force := ctx.Bool("force")
|
|
|
|
if len(address) <= 0 {
|
|
return fmt.Errorf("missing address flag (--address)")
|
|
}
|
|
|
|
if !force && amount <= 0 {
|
|
return fmt.Errorf("missing amount flag (--amount)")
|
|
}
|
|
|
|
if force {
|
|
return unilateralRedeem(address)
|
|
}
|
|
|
|
return collaborativeRedeem(address, amount)
|
|
}
|
|
|
|
func collaborativeRedeem(address string, amount uint64) error {
|
|
fmt.Println("collaborative redeem is not implemented yet")
|
|
return nil
|
|
}
|
|
|
|
func unilateralRedeem(address string) error {
|
|
fmt.Println("unilateral redeem is not implemented yet")
|
|
return nil
|
|
}
|