mirror of
https://github.com/AthanorLabs/atomic-swap.git
synced 2026-01-09 14:18:03 -05:00
implement refund path for Bob on unexpected stream closure, add contract checks (#56)
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/noot/atomic-swap/common"
|
||||
|
||||
logging "github.com/ipfs/go-log"
|
||||
)
|
||||
|
||||
@@ -13,7 +15,7 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
log = logging.Logger("common")
|
||||
log = logging.Logger("monero")
|
||||
)
|
||||
|
||||
// WaitForBlocks waits for a new block to arrive.
|
||||
@@ -39,3 +41,26 @@ func WaitForBlocks(client Client) error {
|
||||
|
||||
return fmt.Errorf("timed out waiting for next block")
|
||||
}
|
||||
|
||||
// CreateMoneroWallet creates a monero wallet from a private keypair.
|
||||
func CreateMoneroWallet(name string, env common.Environment, client Client, kpAB *PrivateKeyPair) (Address, error) {
|
||||
t := time.Now().Format("2006-Jan-2-15:04:05")
|
||||
walletName := fmt.Sprintf("%s-%s", name, t)
|
||||
if err := client.GenerateFromKeys(kpAB, walletName, "", env); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
log.Info("created wallet: ", walletName)
|
||||
|
||||
if err := client.Refresh(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
balance, err := client.GetBalance(0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
log.Info("wallet balance: ", balance.Balance)
|
||||
return kpAB.Address(env), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user