mirror of
https://github.com/aljazceru/ark.git
synced 2025-12-18 04:34:19 +01:00
* scaffolding wallet * remove wallet db, add loader instead * wip * implement some wallet methods * signing and utxos * renaming * fee estimator * chain source options * config * application service * clark docker-compose * CLI refactor * v0 clark * v0.1 clark * fix SignTapscriptInput (btcwallet) * wallet.Broadcast, send via explora * fix ASP pubkey * Use lnd's btcwallet & Add rpc to get wallet staus * wip * unilateral exit * Fixes on watching for notifications and cli init * handle non-final BIP68 errors * Fixes * Fixes * Fix * a * fix onboard cosigners + revert tree validation * fix covenant e2e tests * fix covenantless e2e tests * fix container naming * fix lint error * update REAME.md * Add env var for wallet password --------- Co-authored-by: altafan <18440657+altafan@users.noreply.github.com>
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package oceanwallet
|
|
|
|
import (
|
|
"context"
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
|
|
pb "github.com/ark-network/ark/api-spec/protobuf/gen/ocean/v1"
|
|
"github.com/ark-network/ark/internal/core/ports"
|
|
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
|
)
|
|
|
|
func (s *service) WatchScripts(ctx context.Context, scripts []string) error {
|
|
for _, script := range scripts {
|
|
if _, err := s.notifyClient.WatchExternalScript(ctx, &pb.WatchExternalScriptRequest{
|
|
Script: script,
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (s *service) UnwatchScripts(ctx context.Context, scripts []string) error {
|
|
for _, script := range scripts {
|
|
scriptHash := calcScriptHash(script)
|
|
if _, err := s.notifyClient.UnwatchExternalScript(ctx, &pb.UnwatchExternalScriptRequest{
|
|
Label: scriptHash,
|
|
}); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (s *service) GetNotificationChannel(ctx context.Context) <-chan map[string]ports.VtxoWithValue {
|
|
return s.chVtxos
|
|
}
|
|
|
|
func calcScriptHash(script string) string {
|
|
buf, _ := hex.DecodeString(script)
|
|
hashedBuf := sha256.Sum256(buf)
|
|
hash, _ := chainhash.NewHash(hashedBuf[:])
|
|
return hash.String()
|
|
}
|