add safety checks to prevent wallet disasters

This commit is contained in:
Niko Storni 2019-01-03 08:08:45 -05:00
parent d0e586f8ad
commit 730bcae128
3 changed files with 10 additions and 0 deletions

View file

@ -176,6 +176,7 @@ func (s *SyncManager) Start() error {
"NotEnoughFunds", "NotEnoughFunds",
"no space left on device", "no space left on device",
"failure uploading wallet", "failure uploading wallet",
"the channel in the wallet is different than the channel in the database",
} }
if util.SubstringInSlice(err.Error(), fatalErrors) { if util.SubstringInSlice(err.Error(), fatalErrors) {
return errors.Prefix("@Nikooo777 this requires manual intervention! Exiting...", err) return errors.Prefix("@Nikooo777 this requires manual intervention! Exiting...", err)

View file

@ -193,6 +193,11 @@ func (s *Sync) ensureChannelOwnership() error {
//TODO: eventually get rid of this when the whole db is filled //TODO: eventually get rid of this when the whole db is filled
if s.lbryChannelID == "" { if s.lbryChannelID == "" {
err = s.Manager.apiConfig.SetChannelClaimID(s.YoutubeChannelID, channel.ClaimID) 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 s.lbryChannelID = channel.ClaimID
isChannelMine = true isChannelMine = true

View file

@ -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) return false, errors.Err("something is wrong with this claim: %s", c.ClaimID)
} }
tn := *c.Value.Stream.Metadata.Thumbnail 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:] videoID := tn[strings.LastIndex(tn, "/")+1:]
log.Infof("claimid: %s, claimName: %s, videoID: %s", c.ClaimID, c.Name, videoID) log.Infof("claimid: %s, claimName: %s, videoID: %s", c.ClaimID, c.Name, videoID)