From 730bcae12891717725050af5afac694b9c5cd1e9 Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Thu, 3 Jan 2019 08:08:45 -0500 Subject: [PATCH] add safety checks to prevent wallet disasters --- manager.go | 1 + setup.go | 5 +++++ ytsync.go | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/manager.go b/manager.go index 477e5b3..f6dba68 100644 --- a/manager.go +++ b/manager.go @@ -176,6 +176,7 @@ func (s *SyncManager) Start() error { "NotEnoughFunds", "no space left on device", "failure uploading wallet", + "the channel in the wallet is different than the channel in the database", } if util.SubstringInSlice(err.Error(), fatalErrors) { return errors.Prefix("@Nikooo777 this requires manual intervention! Exiting...", err) diff --git a/setup.go b/setup.go index 63183da..32e07b2 100644 --- a/setup.go +++ b/setup.go @@ -193,6 +193,11 @@ func (s *Sync) ensureChannelOwnership() error { //TODO: eventually get rid of this when the whole db is filled if s.lbryChannelID == "" { err = s.Manager.apiConfig.SetChannelClaimID(s.YoutubeChannelID, channel.ClaimID) + } else if channel.ClaimID != s.lbryChannelID { + return errors.Err("the channel in the wallet is different than the channel in the database") + } + if channel.Name != s.LbryChannelName { + return errors.Err("the channel in the wallet is different than the channel in the database") } s.lbryChannelID = channel.ClaimID isChannelMine = true diff --git a/ytsync.go b/ytsync.go index 47cc7e6..168964d 100644 --- a/ytsync.go +++ b/ytsync.go @@ -383,6 +383,10 @@ func (s *Sync) fixDupes(claims []jsonrpc.Claim) (bool, error) { return false, errors.Err("something is wrong with this claim: %s", c.ClaimID) } tn := *c.Value.Stream.Metadata.Thumbnail + if !strings.Contains(tn, "https://berk.ninja/thumbnails/") { + //we're dealing with something that wasn't published by us! + continue + } videoID := tn[strings.LastIndex(tn, "/")+1:] log.Infof("claimid: %s, claimName: %s, videoID: %s", c.ClaimID, c.Name, videoID)