Giter Site home page Giter Site logo

bat-native-ledger's People

Contributors

bbondy avatar bridiver avatar bsclifton avatar emerick avatar garrettr avatar gdregalo avatar kylehickinson avatar nejczdovc avatar ryanml avatar sergeyzhukovsky avatar simonhong avatar tmancey avatar yrliou avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bat-native-ledger's Issues

Remove leveldb

We should remove level db and functions RunTask / RunIOTask when we move exclude check to the same list as we will be using for verified

Add captcha grant claim

We need to add call that can be called from JS that resolves captcha and actually claim grant

Modernize debug switch...

right now we have --debug=N where N is one of:

LOG_ERROR = 1,
LOG_WARNING = 2,
LOG_INFO = 3,
LOG_DEBUG = 4,
LOG_REQUEST = 5,
LOG_RESPONSE = 6

if we're going to make things more general, let us try to make them better as well as general, e.g., the way it was done back in 1982:

  1. The values above should be a bitmask, e.g.,

    LOG_NONE = 0x00,
    LOG_ERROR = 0x01,
    LOG_WARNING = 0x02,
    LOG_INFO = 0x04,
    LOG_DEBUG = 0x08,
    LOG_REQUEST = 0x10,
    LOG_RESPONSE = 0x20

and the code which tests them should be using & instead of ==

  1. there should be an environment variable that sets the default for the --debug switch (so it can be overridden on the command line, if desired).

  2. both the environment variable and the switch should take both a numeric value, and a comma-separated string, e.g., --debug=error,request ...

thanks!

Refactor sort using operator overloading

Recommended to refactor the following code (not just limited to PublisherInfo):

bool PublisherInfo::operator<(const PublisherInfo& rhs) const {
    return score > rhs.score;

to

bool PublisherInfoSort(PublisherInfo const& lhs, PublisherInfo const& rhs) {
    return lhs.score > rhs.score;
}

std::sort(publisher_info.begin(), publisher_info.end(), &PublisherInfoSort);

Default monthly value

  1. we need to know if user changed default monthly budget (add bool flag)
  2. every time that we fetch balance we also get default monthly budget. If user did not change his monthly budget, we need to set it to the value returned in the balance response
  3. follow up to #97: value should be only added if user changed it

Response

{
   "altcurrency":"BAT",
   "probi":"0",
   "balance":"0.0000",
   "unconfirmed":"0.0000",
   "rates":{
      "BTC":0.0000315,
      "ETH":0.000793831530483428,
      "XRP":0.6861360718870346,
      "BCH":0.0003652369718724429,
      "LTC":0.0035704742818971277,
      "DASH":0.0010850588712951685,
      "BTG":0.010842151526420773,
      "USD":0.23455291335672,
      "EUR":0.20217945114946598
   },
   "parameters":{
      "adFree":{
         "currency":"BAT",
         "fee":{
            "BAT":20
         },
         "choices":{
            "BAT":[
               10,
               15,
               20,
               30,
               50,
               100
            ]
         },
         "range":{
            "BAT":[
               10,
               100
            ]
         },
         "days":30
      }
   }
}

Default monthly budget:
"fee":{"BAT":20}

Create helper for keyInfoSeed

We need helper that will return recovery keys (look at the image) from keyInfoSeed which looks like this WM4Ye5z/Y5S2+rrhKvCUW210EPCN2MFntjTNLJQmjnc=

image

Debug assertion for IO on no-blocking thread

[39551:775:0702/104607.259415:ERROR:bat_client.cc(51)] BatClient::loadStateOrRegisterPersona exit
[39551:32515:0702/104607.259491:ERROR:bat_client.cc(56)] !!!here1
[39551:32515:0702/104607.259555:ERROR:bat_client_webrequest_chromium.cc(86)] !!!web_request URL == https://ledger-staging.mercury.basicattentiontoken.org/v2/registrar/persona
[39551:775:0702/104607.259466:FATAL:thread_restrictions.cc(29)] Check failed: !g_blocking_disallowed.Get().Get(). Function marked as blocking was called from a scope that disallows blocking! If this task is running inside the TaskScheduler, it needs to have MayBlock() in its TaskTraits. Otherwise, consider making this blocking work asynchronous or, as a last resort, you may use ScopedAllowBlocking in a narrow scope.
0   libbase.dylib                       0x0000000109fbfb3e base::debug::StackTrace::StackTrace(unsigned long) + 174
1   libbase.dylib                       0x0000000109fbfbfd base::debug::StackTrace::StackTrace(unsigned long) + 29
2   libbase.dylib                       0x0000000109fbe0ac base::debug::StackTrace::StackTrace() + 28
3   libbase.dylib                       0x000000010a05b19c logging::LogMessage::~LogMessage() + 460
4   libbase.dylib                       0x000000010a058f05 logging::LogMessage::~LogMessage() + 21
5   libbase.dylib                       0x000000010a2c88fc base::AssertBlockingAllowed() + 188
6   libbase.dylib                       0x000000010a0071af base::File::Close() + 111
7   libbase.dylib                       0x0000000109fe0cc9 base::File::~File() + 25
8   libbase.dylib                       0x0000000109fe0d15 base::File::~File() + 21
9   libleveldatabase.dylib              0x00000001368b4d21 leveldb_env::(anonymous namespace)::ChromiumFileLock::~ChromiumFileLock() + 65
10  libleveldatabase.dylib              0x00000001368b4ca5 leveldb_env::(anonymous namespace)::ChromiumFileLock::~ChromiumFileLock() + 21
11  libleveldatabase.dylib              0x00000001368b4cc9 leveldb_env::(anonymous namespace)::ChromiumFileLock::~ChromiumFileLock() + 25
12  libleveldatabase.dylib              0x00000001368a599a leveldb_env::ChromiumEnv::UnlockFile(leveldb::FileLock*) + 1258
13  libleveldatabase.dylib              0x00000001368c64da leveldb::DBImpl::~DBImpl() + 202
14  libleveldatabase.dylib              0x00000001368c68a5 leveldb::DBImpl::~DBImpl() + 21
15  libleveldatabase.dylib              0x00000001368c68c9 leveldb::DBImpl::~DBImpl() + 25
16  libchrome_dll.dylib                 0x00000001119b92b3 braveledger_bat_get_media::BatGetMedia::~BatGetMedia() + 67
17  libchrome_dll.dylib                 0x00000001119b9325 braveledger_bat_get_media::BatGetMedia::~BatGetMedia() + 21
18  libchrome_dll.dylib                 0x0000000111983643 braveledger_ledger::Ledger::~Ledger() + 83
19  libchrome_dll.dylib                 0x0000000111983835 braveledger_ledger::Ledger::~Ledger() + 21
20  libchrome_dll.dylib                 0x000000011176d969 BraveBrowserCommandController::ExecuteBraveCommandWithDisposition(int, WindowOpenDisposition) + 921
21  libchrome_dll.dylib                 0x000000011176d5a0 BraveBrowserCommandController::ExecuteCommandWithDisposition(int, WindowOpenDisposition) + 64
22  libchrome_dll.dylib                 0x0000000117e26911 chrome::BrowserCommandController::ExecuteCommand(int) + 33
23  libchrome_dll.dylib                 0x0000000117e2b5ec chrome::ExecuteCommand(Browser*, int) + 44
24  libchrome_dll.dylib                 0x0000000117f6f3c7 AppMenuModel::ExecuteCommand(int, int) + 135
25  libui_base.dylib                    0x000000010a94be7e ui::SimpleMenuModel::ActivatedAt(int, int) + 94
26  libui_base.dylib                    0x000000010a8f800d -[MenuControllerCocoa itemSelected:uiEventFlags:] + 509
27  libui_base.dylib                    0x000000010a8f7afa -[MenuControllerCocoa itemSelected:] + 874
28  AppKit                              0x00007fff29f7d75a -[NSApplication(NSResponder) sendAction:to:from:] + 312
29  libchrome_dll.dylib                 0x00000001125f55a7 __43-[BrowserCrApplication sendAction:to:from:]_block_invoke + 87
30  libbase.dylib                       0x000000010a06065a base::mac::CallWithEHFrame(void () block_pointer) + 10
31  libchrome_dll.dylib                 0x00000001125f542b -[BrowserCrApplication sendAction:to:from:] + 1211
32  AppKit                              0x00007fff29a125f7 -[NSMenuItem _corePerformAction] + 323
33  AppKit                              0x00007fff29a1237f -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 114
34  AppKit                              0x00007fff29a97fba -[NSMenu performActionForItemAtIndex:] + 133
35  AppKit                              0x00007fff29a97f25 -[NSMenu _internalPerformActionForItemAtIndex:] + 94
36  AppKit                              0x00007fff29a97d55 -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 106
37  AppKit                              0x00007fff2995e6b2 NSSLMMenuEventHandler + 882
38  HIToolbox                           0x00007fff2b4f3814 DispatchEventToHandlers(EventTargetRec*, OpaqueEventRef*, HandlerCallRec*) + 1541
39  HIToolbox                           0x00007fff2b4f2b5d SendEventToEventTargetInternal(OpaqueEventRef*, OpaqueEventTargetRef*, HandlerCallRec*) + 374
40  HIToolbox                           0x00007fff2b507e61 SendEventToEventTarget + 39
41  HIToolbox                           0x00007fff2b551489 SendHICommandEvent(unsigned int, HICommand const*, unsigned int, unsigned int, unsigned char, void const*, OpaqueEventTargetRef*, OpaqueEventTargetRef*, OpaqueEventRef**) + 411
42  HIToolbox                           0x00007fff2b57a3be SendMenuCommandWithContextAndModifiers + 49
43  HIToolbox                           0x00007fff2b57a37a SendMenuItemSelectedEvent + 188
44  HIToolbox                           0x00007fff2b57a254 FinishMenuSelection(SelectionData*, MenuResult*, MenuResult*) + 96
45  HIToolbox                           0x00007fff2b692b9c PopUpMenuSelectCore(MenuData*, Point, double, Point, unsigned short, unsigned int, unsigned int, Rect const*, unsigned short, unsigned int, Rect const*, Rect const*, __CFDictionary const*, __CFString const*, OpaqueMenuRef**, unsigned short*) + 1662
46  HIToolbox                           0x00007fff2b692017 _HandlePopUpMenuSelection8(OpaqueMenuRef*, OpaqueEventRef*, unsigned int, Point, unsigned short, unsigned int, unsigned int, Rect const*, unsigned short, Rect const*, Rect const*, __CFDictionary const*, __CFString const*, OpaqueMenuRef**, unsigned short*) + 409
47  HIToolbox                           0x00007fff2b55a4bc _HandlePopUpMenuSelectionWithDictionary + 268
48  AppKit                              0x00007fff29a8eada _NSSLMPopUpCarbonMenu3 + 5632
49  AppKit                              0x00007fff29a8d434 -[NSCarbonMenuImpl popUpMenu:atLocation:width:forView:withSelectedItem:withFont:withFlags:withOptions:] + 439
50  AppKit                              0x00007fff29afd59c -[NSPopUpButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 570
51  AppKit                              0x00007fff29b763a7 -[NSPopUpButtonCell performClickWithFrame:inView:] + 128
52  libchrome_dll.dylib                 0x000000011840fc8d -[MenuButton(Private) showMenu:] + 1549
53  libchrome_dll.dylib                 0x0000000118410077 -[MenuButton(Private) dragShowMenu:] + 279
54  AppKit                              0x00007fff29f7d75a -[NSApplication(NSResponder) sendAction:to:from:] + 312
55  libchrome_dll.dylib                 0x00000001125f55a7 __43-[BrowserCrApplication sendAction:to:from:]_block_invoke + 87
56  libbase.dylib                       0x000000010a06065a base::mac::CallWithEHFrame(void () block_pointer) + 10
57  libchrome_dll.dylib                 0x00000001125f542b -[BrowserCrApplication sendAction:to:from:] + 1211
58  AppKit                              0x00007fff29a23933 -[NSControl sendAction:to:] + 86
59  libchrome_dll.dylib                 0x0000000118336b0d -[ClickHoldButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 2013
60  AppKit                              0x00007fff29a20a64 -[NSControl mouseDown:] + 965
61  AppKit                              0x00007fff2a11c959 -[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 5891

load/save race condition

There is a potential race condition because save and load are async. It's possible that the same publisher info record could be loaded in different places (the UI and the library for instance) and then the last save will win and overwrite the first one. A record version field could be used to check and update within a db transaction.

Recovery keys from muon are not working

If you try to recover wallet from muon it fails.

I tried with just initial park scene frog stand vintage black love close noodle hunt siren amateur combine lawsuit blouse addict faculty must piano dirt ivory alert (generated in muon)

and HKDF returns different result in muon then it returns in core

muon implementation: https://github.com/brave/crypto/blob/master/index.js#L126
image

core implementation: https://github.com/brave-intl/bat-native-ledger/blob/master/src/bat_helper.cc#L1240
image

Not all data is fetched when wallet is created

muon version (ledger-state.json)

{
  "personaId": "2f919656-f3df-4e77-a2a7-d15a9e910067",
  "options": {
    "debugP": false,
    "loggingP": false,
    "rulesTestP": false,
    "verboseP": false,
    "server": {
      "protocol": "https:",
      "slashes": true,
      "auth": null,
      "host": "ledger.mercury.basicattentiontoken.org",
      "port": null,
      "hostname": "ledger.mercury.basicattentiontoken.org",
      "hash": null,
      "search": null,
      "query": null,
      "pathname": "/",
      "path": "/",
      "href": "https://ledger.mercury.basicattentiontoken.org/"
    },
    "version": "v2",
    "environment": "production",
    "prefix": "/v2"
  },
  "ballots": [],
  "batch": {},
  "transactions": [],
  "properties": {
    "setting": "adFree",
    "fee": {
      "currency": "BAT",
      "amount": 7.5
    },
    "days": 30,
    "wallet": {
      "keyinfo": {
        "seed": {
          "0": 76,
          "1": 250,
          "2": 44,
          "3": 238,
          "4": 198,
          "5": 193,
          "6": 242,
          "7": 145,
          "8": 157,
          "9": 215,
          "10": 186,
          "11": 98,
          "12": 241,
          "13": 210,
          "14": 80,
          "15": 98,
          "16": 83,
          "17": 61,
          "18": 87,
          "19": 135,
          "20": 84,
          "21": 109,
          "22": 174,
          "23": 77,
          "24": 62,
          "25": 3,
          "26": 162,
          "27": 247,
          "28": 177,
          "29": 192,
          "30": 43,
          "31": 149
        }
      },
      "paymentId": "8070cab8-4994-42f1-9634-e0625170b92b",
      "addresses": {
        "BAT": "0xfE544da498B913a6A21Bdc27D104b71943bFf9e6",
        "BTC": "1M9a7RuGjKXDhCwzQUcxVx8CYGmzVKineH",
        "CARD_ID": "f92a9f41-64dc-43ea-bce2-3f8dc0ff8ace",
        "ETH": "0xfE544da498B913a6A21Bdc27D104b71943bFf9e6",
        "LTC": "LUVDj8HsKTZ4BJJp9Ufm29W6YcBmEUqVTm"
      }
    }
  },
  "reconcileStamp": 1535723968983,
  "memos": [
    "{\"who\":\"sync\",\"what\":{\"reconcileStamp\":1534341565349,\"reconcileDate\":\"2018-08-15T13:59:25.349Z\"},\"when\":1533131965349}"
  ],
  "ruleset": [
    {
      "condition": "/^[a-z][a-z].gov$/.test(SLD)",
      "consequent": "QLD + '.' + SLD",
      "description": "governmental sites"
    },
    {
      "condition": "TLD === 'gov' || /^go.[a-z][a-z]$/.test(TLD) || /^gov.[a-z][a-z]$/.test(TLD)",
      "consequent": "SLD",
      "description": "governmental sites"
    },
    {
      "condition": "SLD === 'keybase.pub'",
      "consequent": "QLD + '.' + SLD",
      "description": "keybase users"
    },
    {
      "condition": true,
      "consequent": "SLD",
      "description": "the default rule"
    }
  ],
  "persona": "{\"userId\":\"2f919656f3dfe77a2a7d15a9e910067\",\"registrarVK\":\"==========ANONLOGIN_VK_BEG==========\\n5Zo7fjdryszdwgAZO+HiK18yErXRoPvRkmYmo4E2UQV 4NMDAdwHg0z3LdGN3KkOoFLbza3SpeUWBcMKOUvJ8O1 1\\n7MpAGVMgs+tuMQs4pH+nKUh0M+rl21RyUAdhRHKGhq4 5LXnl7uUw0XwaSTIojyDh4hODTEcT5BAiAhPCGIItDM 1\\n2qtVvVwfxlDGzPSXXl0Ms94eycXiUJpthRp6uAjrjW8 Auhpv58KOuncZfXB1eekbOwTXloSAgPPRJ3A1g2a1MZ 1\\n41nN9zSpWB6xfefhy/BWOouZnE5Vz+Akgtu3WavASEJ AF4pxNogZT38xdPdxe51RIGaFXKNVj3K2vbfN3uzI1T 1\\n31ND6Q8qewDElWUU88rMWn4RZl95sjbSvoimlfsVFEg 8VjyRwkfd4dWwMQhShAIiyY0L9tOiJIR4PWlRIwyQs6 wLm/Ph3gh2ZtdqNbGJIcQM1LoCr+23zELEwUKvAnSL 1sWQdlB2UL0xSqgNcb9NObxiSof322GgHUg2nq43Y4l 1 0\\n===========ANONLOGIN_VK_END==========\",\"masterUserToken\":\"==========ANONLOGIN_CRED_BEG==========\\n2f919656f3dfe77a2a7d15a9e910067\\nC0XXxxOGBim2CcaP6L3Lh5DIMbZ97se3Lwee3jxSEAv\\nHNGLT7z6YBreSTM9mA1ec1/i05aB0WcUrPH/1S7EWX 6R95RQ0/Mc4uhXXF+I5hyeSNo7ZYIu23F1Vmiby6x7t 1\\nAZTo8na2OEK+Uf/GdU1RtW2pUrBmXsQVgAdDdxwIqvB\\n2HCjWMrj3xJ6buIPWauAJmICVxGXaq1ryEk/LBAsDdp\\n===========ANONLOGIN_CRED_END==========\"}",
  "bootStamp": 1533131968983
}

core version (ledger_state)

{
  "walletInfo": {
    "paymentId": "91e5c623-89a3-410f-972e-db7730641075",
    "addressBAT": "0xA357EB022d47B1a6CD4BFDfa2d41e81d9D7C6f1C",
    "addressBTC": "",
    "addressCARD_ID": "242a68ed-1a8e-431f-842d-59a143afec3c",
    "addressETH": "0xA357EB022d47B1a6CD4BFDfa2d41e81d9D7C6f1C",
    "addressLTC": "moioAap43AxtGvQpicb42VQXQ94Z5vYkMQ",
    "keyInfoSeed": "WM4Ye5z/Y5S2+rrhKvCUW210EPCN2MFntjTNLJQmjnc="
  },
  "bootStamp": 1533131517000,
  "reconcileStamp": 1535723517000,
  "personaId": "70a0eecf-3a81-401f-b734-d7416727f3a7",
  "userId": "70a0eecf3a8101fb734d7416727f3a7",
  "registrarVK": "==========ANONLOGIN_VK_BEG==========\nx3EmZXFb2jD7OocZz6l7o638S45k2kKrX5BrWp1Ox+ ANJXSauJVPNHKl/mmakFwxbkwJkJzfXe+c9+jxFtuX6 1\n5xMuqWE8J7HIHbW/UEJwFELYjTWRF10x7LMd7s46MVT 4DC6LqGM8zLz1pCsHA3qab48gkpeiQpNZAdb9owFvU6 1\n1tADCD6LdrEDQQDhRy1ijjAfhV9uKwlKKuhD6xXyPAZ BLOzUy+ZZh48riPnAHnUGal+ceCclccZXmoXXx92WHW 1\n7VRDst4U4iaT/9QNCwajEaqgRNtKPV1Dp5QuMjP019h HucbxBMGGAZBNLXGzfKsTlF+wAdmOFAvBRAo8i2Azd 1\n5SLk8SphICEkF+CNhN5g7IX2ih+Tb6w14LLlwupKw7y 96ANsdHzg0pwo2DDWOyAh1YPnION196pIT9xwISFZTA 3ef5G5d2c8cctdK4LuaxlSeEf1OZ100Sy5un5EjuHJB 77yFnY61GM7PHd6q3TLs2QS6c9PfrXD2idxaFq2DMd 1 0\n===========ANONLOGIN_VK_END==========",
  "masterUserToken": "==========ANONLOGIN_CRED_BEG==========\n70a0eecf3a8101fb734d7416727f3a7\nE1CvtBCELPQB9D+bd4moJSzvhmDPr0pGrhZo7oHqkwh\n7bRtu6mSVgzs0txjvCexjh9InWF/rd/b2wFIizGURoL BAaO6MbuHzeVVvJcDiK3LjKGou3rvW9d1TI4y68Abj+ 1\n51sX4d7fKvs5wGg8D6VnkA0ZMxa4SxRoBJ9fYN9sW9q\nCsGFlfQRwpBVztEATNRc4/vyG18KaHQgB2TW0bgZtih\n===========ANONLOGIN_CRED_END==========",
  "preFlight": "==========ANONLOGIN_CRED_BEG==========\n70a0eecf3a8101fb734d7416727f3a7\nE1CvtBCELPQB9D+bd4moJSzvhmDPr0pGrhZo7oHqkwh\n0 0 0\n0\nCsGFlfQRwpBVztEATNRc4/vyG18KaHQgB2TW0bgZtih\n===========ANONLOGIN_CRED_END==========",
  "fee_currency": "BAT",
  "settings": "adFree",
  "fee_amount": 20,
  "days": 30,
  "transactions": [],
  "ballots": [],
  "ruleset": "",
  "rulesetV2": "",
  "batch": []
}

we should not make background requests for remote sites

For some media pubs we make extra requests to urls the user has not visited to extract things like channel id and favicon. We should try to find ways to get this information using existing requests. At the very least we should minimize the number or find other ways to get the data we need.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.