kandi background
Explore Kits

bitcoin | Bitcoin Core integration/staging tree | Blockchain library

 by   bitcoin C++ Version: v22.0 License: MIT

 by   bitcoin C++ Version: v22.0 License: MIT

Download this library from

kandi X-RAY | bitcoin Summary

bitcoin is a C++ library typically used in Blockchain, Bitcoin applications. bitcoin has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.
Bitcoin is an experimental digital currency that enables instant payments to anyone, anywhere in the world. Bitcoin uses peer-to-peer technology to operate with no central authority: managing transactions and issuing money are carried out collectively by the network. Bitcoin Core is the name of open source software which enables the use of this currency. For more information read the original Bitcoin whitepaper.
Support
Support
Quality
Quality
Security
Security
License
License
Reuse
Reuse

kandi-support Support

  • bitcoin has a medium active ecosystem.
  • It has 63479 star(s) with 32203 fork(s). There are 3928 watchers for this library.
  • It had no major release in the last 12 months.
  • There are 597 open issues and 6242 have been closed. On average issues are closed in 309 days. There are 402 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of bitcoin is v22.0
bitcoin Support
Best in #Blockchain
Average in #Blockchain
bitcoin Support
Best in #Blockchain
Average in #Blockchain

quality kandi Quality

  • bitcoin has 0 bugs and 0 code smells.
bitcoin Quality
Best in #Blockchain
Average in #Blockchain
bitcoin Quality
Best in #Blockchain
Average in #Blockchain

securitySecurity

  • bitcoin has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • bitcoin code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.
bitcoin Security
Best in #Blockchain
Average in #Blockchain
bitcoin Security
Best in #Blockchain
Average in #Blockchain

license License

  • bitcoin is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.
bitcoin License
Best in #Blockchain
Average in #Blockchain
bitcoin License
Best in #Blockchain
Average in #Blockchain

buildReuse

  • bitcoin releases are available to install and integrate.
  • It has 37182 lines of code, 2154 functions and 325 files.
  • It has medium code complexity. Code complexity directly impacts maintainability of the code.
bitcoin Reuse
Best in #Blockchain
Average in #Blockchain
bitcoin Reuse
Best in #Blockchain
Average in #Blockchain
Top functions reviewed by kandi - BETA

Coming Soon for all Libraries!

Currently covering the most popular Java, JavaScript and Python libraries. See a SAMPLE HERE.
kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.

bitcoin Key Features

Bitcoin Core integration/staging tree

Adjusting Labels of Altair Grouped Bar Chart

copy iconCopydownload iconDownload
table['TERM'] = table['TERM'].str.split(' ', 1)
alt.Chart(table).transform_fold(
    ["Bitcoin", "S&P500", "Real Estate", "Gold"], as_=["key", "value"]
).mark_bar().encode(
    x=alt.X("key:N", title=None),
    y=alt.Y("value:Q", scale=alt.Scale(type='symlog'),
           axis=alt.Axis(values=[0] + [10**x * y for (x, y) in product(range(1, 10, 1), (1, -0.01))])),
    color="key:N",
    column="TERM"
)

different htaccess for directory issue

copy iconCopydownload iconDownload
RewriteEngine On

RewriteRule ^are-bitcoin-gains-taxable/?$ /pages/questions/viewQuestion.php?id=9 [L,NC,QSA]

Add data into 2 columns in same row with the data coming from Javascipt Websocket

copy iconCopydownload iconDownload
<table id="tableprice" class="table table-striped">
  <thead>
    <tr>
      <th>Amount(BTC)</th>
      <th scope="col">Price(USDT)</th>
    </tr>
  </thead>
  <tbody id="pricetable" class="crypt-table-hover"></tbody>
</table>

<script>
          window.onload = () => {
              function insertRow(numberOfCoins,price){
    var tr      = document.createElement("tr"),
        tdCoin  = document.createElement("td"),
        tdPrice = document.createElement("td"),
        docFrag = new DocumentFragment();
        tdPrice.style.color="#49C279";
      // tdCoin.textContent = `${(price.slice(0)).toLocaleString("en-US")}`;
    tdPrice.textContent = `${Number(price.slice(0,-6)).toLocaleString("en-US",{style: 'currency', currency: 'USD'})}`;
    tdCoin.textContent = `${numberOfCoins}`;
    tr.appendChild(tdCoin);
    tr.appendChild(tdPrice);
    docFrag.appendChild(tr);
    return docFrag;
  }


  var binanceSocket = new WebSocket("wss://stream.binance.com:9443/ws/btcusdt@aggTrade"),
      table = document.getElementById("pricetable");
  binanceSocket.onmessage = function(event) {
    var messageObject = JSON.parse(event.data);
    table.appendChild(insertRow(messageObject.q, messageObject.p));



    const MAX_ROWS = 16;
      const rows = table.querySelectorAll("tr");
      if (rows.length > MAX_ROWS) table.removeChild(rows[0]);


  }
}
</script>

How to resample frequency conditional on two columns in pandas?

copy iconCopydownload iconDownload
df["Date"] = df["Date"].dt.round("1H")
cross = df.pivot_table(index="Date", columns=["Asset", "Class"], values="Score", aggfunc="mean")
Asset      baidu-inc                    bitcoin         ftse-100          
Class              E        G       S         E       S        G         S
Date                                                                      
2015-01-01   0.32285 -0.37895 -0.0322 -0.035767  0.1492  -0.1204 -0.112567
agg = cross.melt(ignore_index=False).reset_index()
        Date      Asset Class     value
0 2015-01-01  baidu-inc     E  0.322850
1 2015-01-01  baidu-inc     G -0.378950
2 2015-01-01  baidu-inc     S -0.032200
3 2015-01-01    bitcoin     E -0.035767
4 2015-01-01    bitcoin     S  0.149200
5 2015-01-01   ftse-100     G -0.120400
6 2015-01-01   ftse-100     S -0.112567
df["Date"] = df["Date"].dt.round("1H")
agg = df.groupby(["Date", "Asset", "Class"])["Score"].mean().reset_index()
-----------------------
df["Date"] = df["Date"].dt.round("1H")
cross = df.pivot_table(index="Date", columns=["Asset", "Class"], values="Score", aggfunc="mean")
Asset      baidu-inc                    bitcoin         ftse-100          
Class              E        G       S         E       S        G         S
Date                                                                      
2015-01-01   0.32285 -0.37895 -0.0322 -0.035767  0.1492  -0.1204 -0.112567
agg = cross.melt(ignore_index=False).reset_index()
        Date      Asset Class     value
0 2015-01-01  baidu-inc     E  0.322850
1 2015-01-01  baidu-inc     G -0.378950
2 2015-01-01  baidu-inc     S -0.032200
3 2015-01-01    bitcoin     E -0.035767
4 2015-01-01    bitcoin     S  0.149200
5 2015-01-01   ftse-100     G -0.120400
6 2015-01-01   ftse-100     S -0.112567
df["Date"] = df["Date"].dt.round("1H")
agg = df.groupby(["Date", "Asset", "Class"])["Score"].mean().reset_index()
-----------------------
df["Date"] = df["Date"].dt.round("1H")
cross = df.pivot_table(index="Date", columns=["Asset", "Class"], values="Score", aggfunc="mean")
Asset      baidu-inc                    bitcoin         ftse-100          
Class              E        G       S         E       S        G         S
Date                                                                      
2015-01-01   0.32285 -0.37895 -0.0322 -0.035767  0.1492  -0.1204 -0.112567
agg = cross.melt(ignore_index=False).reset_index()
        Date      Asset Class     value
0 2015-01-01  baidu-inc     E  0.322850
1 2015-01-01  baidu-inc     G -0.378950
2 2015-01-01  baidu-inc     S -0.032200
3 2015-01-01    bitcoin     E -0.035767
4 2015-01-01    bitcoin     S  0.149200
5 2015-01-01   ftse-100     G -0.120400
6 2015-01-01   ftse-100     S -0.112567
df["Date"] = df["Date"].dt.round("1H")
agg = df.groupby(["Date", "Asset", "Class"])["Score"].mean().reset_index()
-----------------------
df["Date"] = df["Date"].dt.round("1H")
cross = df.pivot_table(index="Date", columns=["Asset", "Class"], values="Score", aggfunc="mean")
Asset      baidu-inc                    bitcoin         ftse-100          
Class              E        G       S         E       S        G         S
Date                                                                      
2015-01-01   0.32285 -0.37895 -0.0322 -0.035767  0.1492  -0.1204 -0.112567
agg = cross.melt(ignore_index=False).reset_index()
        Date      Asset Class     value
0 2015-01-01  baidu-inc     E  0.322850
1 2015-01-01  baidu-inc     G -0.378950
2 2015-01-01  baidu-inc     S -0.032200
3 2015-01-01    bitcoin     E -0.035767
4 2015-01-01    bitcoin     S  0.149200
5 2015-01-01   ftse-100     G -0.120400
6 2015-01-01   ftse-100     S -0.112567
df["Date"] = df["Date"].dt.round("1H")
agg = df.groupby(["Date", "Asset", "Class"])["Score"].mean().reset_index()
-----------------------
df["Date"] = df["Date"].dt.round("1H")
cross = df.pivot_table(index="Date", columns=["Asset", "Class"], values="Score", aggfunc="mean")
Asset      baidu-inc                    bitcoin         ftse-100          
Class              E        G       S         E       S        G         S
Date                                                                      
2015-01-01   0.32285 -0.37895 -0.0322 -0.035767  0.1492  -0.1204 -0.112567
agg = cross.melt(ignore_index=False).reset_index()
        Date      Asset Class     value
0 2015-01-01  baidu-inc     E  0.322850
1 2015-01-01  baidu-inc     G -0.378950
2 2015-01-01  baidu-inc     S -0.032200
3 2015-01-01    bitcoin     E -0.035767
4 2015-01-01    bitcoin     S  0.149200
5 2015-01-01   ftse-100     G -0.120400
6 2015-01-01   ftse-100     S -0.112567
df["Date"] = df["Date"].dt.round("1H")
agg = df.groupby(["Date", "Asset", "Class"])["Score"].mean().reset_index()
-----------------------
df.set_index('Date').groupby(['Asset','Class']).resample('1h').mean().reset_index()

       Asset Class       Date     Score
0  baidu-inc     E 2015-01-01  0.322850
1  baidu-inc     G 2015-01-01 -0.378950
2  baidu-inc     S 2015-01-01 -0.032200
3    bitcoin     E 2015-01-01 -0.035767
4    bitcoin     S 2015-01-01  0.149200
5   ftse-100     G 2015-01-01 -0.120400
6   ftse-100     S 2015-01-01 -0.112567
df.groupby(['Asset','Class']).resample('1h', on='Date').mean().reset_index()

       Asset Class       Date     Score
0  baidu-inc     E 2015-01-01  0.322850
1  baidu-inc     G 2015-01-01 -0.378950
2  baidu-inc     S 2015-01-01 -0.032200
3    bitcoin     E 2015-01-01 -0.035767
4    bitcoin     S 2015-01-01  0.149200
5   ftse-100     G 2015-01-01 -0.120400
6   ftse-100     S 2015-01-01 -0.112567
-----------------------
df.set_index('Date').groupby(['Asset','Class']).resample('1h').mean().reset_index()

       Asset Class       Date     Score
0  baidu-inc     E 2015-01-01  0.322850
1  baidu-inc     G 2015-01-01 -0.378950
2  baidu-inc     S 2015-01-01 -0.032200
3    bitcoin     E 2015-01-01 -0.035767
4    bitcoin     S 2015-01-01  0.149200
5   ftse-100     G 2015-01-01 -0.120400
6   ftse-100     S 2015-01-01 -0.112567
df.groupby(['Asset','Class']).resample('1h', on='Date').mean().reset_index()

       Asset Class       Date     Score
0  baidu-inc     E 2015-01-01  0.322850
1  baidu-inc     G 2015-01-01 -0.378950
2  baidu-inc     S 2015-01-01 -0.032200
3    bitcoin     E 2015-01-01 -0.035767
4    bitcoin     S 2015-01-01  0.149200
5   ftse-100     G 2015-01-01 -0.120400
6   ftse-100     S 2015-01-01 -0.112567

How to fix LevelDB library load error when running RSKj node on a Windows machine?

copy iconCopydownload iconDownload
curl \
  -X POST \
  -H “Content-Type:application/json” \
  --data ‘{“jsonrpc”:“2.0",“method”:“eth_blockNumber”,“params”:[],“id”:67}’ \
  http://localhost:4444

{“jsonrpc”:“2.0",“id”:67,“result”:“0x2b12”}
-----------------------
curl \
  -X POST \
  -H “Content-Type:application/json” \
  --data ‘{“jsonrpc”:“2.0",“method”:“eth_blockNumber”,“params”:[],“id”:67}’ \
  http://localhost:4444

{“jsonrpc”:“2.0",“id”:67,“result”:“0x2b12”}

after updating flutter, Firebase.initializeApp() does not seem to work on my phone anymore

copy iconCopydownload iconDownload
void main() {
  WidgetsFlutterBinding.ensureInitialized();
  Firebase.initializeApp();
  runApp(const App());
}

How to retreive the date when video has been released on Youtube using Python and Selenium

copy iconCopydownload iconDownload
driver.get("https://www.youtube.com/results?search_query=%27+term+%27&sp=CAISAhAB")
print([my_elem.get_attribute("innerHTML") for my_elem in WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.XPATH, "//div[@id='metadata-line' and @class='style-scope ytd-video-meta-block']////following::span[2][contains(., 'hours') or contains(., 'day')]")))])
['2 hours ago', '2 hours ago', '3 hours ago', 'Streamed 3 hours ago', 'Streamed 3 hours ago', '5 hours ago', 'Streamed 6 hours ago', '6 hours ago', '6 hours ago', '7 hours ago', '8 hours ago', 'Streamed 8 hours ago', '9 hours ago', 'Streamed 10 hours ago', '11 hours ago']
-----------------------
driver.get("https://www.youtube.com/results?search_query=%27+term+%27&sp=CAISAhAB")
print([my_elem.get_attribute("innerHTML") for my_elem in WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.XPATH, "//div[@id='metadata-line' and @class='style-scope ytd-video-meta-block']////following::span[2][contains(., 'hours') or contains(., 'day')]")))])
['2 hours ago', '2 hours ago', '3 hours ago', 'Streamed 3 hours ago', 'Streamed 3 hours ago', '5 hours ago', 'Streamed 6 hours ago', '6 hours ago', '6 hours ago', '7 hours ago', '8 hours ago', 'Streamed 8 hours ago', '9 hours ago', 'Streamed 10 hours ago', '11 hours ago']

Python - BeautifulSoup - Selecting a 'div' with 'class'-attribute shows every div in the html

copy iconCopydownload iconDownload
import requests
import pandas as pd

alpha = ['count', 'ratio']
payload = {
'id': '1',
'range': '7d'}


for each in alpha:
        url = f'https://api.coinmarketcap.com/data-api/v3/cryptocurrency/detail/holders/{each}'
        jsonData = requests.get(url, params=payload).json()['data']['points']
        
        if each == 'count':
            count_df = pd.DataFrame.from_dict(jsonData,orient='index')
            count_df = count_df.rename(columns={0:'Total Addresses'})
            
        else:
            ratio_df = pd.DataFrame.from_dict(jsonData,orient='index')
            df = count_df.merge(ratio_df, how='left', left_index=True, right_index=True)
            
df = df.sort_index()          
        
print(df.to_string())
                      Total Addresses  topTenHolderRatio  topTwentyHolderRatio  topFiftyHolderRatio  topHundredHolderRatio
2021-11-24T00:00:00Z         39279627               5.25                  7.19                10.51                  13.26
2021-11-25T00:00:00Z         39255811               5.25                  7.19                10.49                  13.22
2021-11-26T00:00:00Z         39339840               5.25                  7.19                10.51                  13.24
2021-11-27T00:00:00Z         39391849               5.23                  7.11                10.45                  13.18
2021-11-28T00:00:00Z         39505340               5.24                  7.11                10.45                  13.18
2021-11-29T00:00:00Z         39502099               5.24                  7.11                10.43                  13.16
2021-11-30T00:00:00Z         39523000               5.24                  7.11                10.38                  13.12
from bs4 import BeautifulSoup
import requests
import json
import re

url = 'https://coinmarketcap.com/currencies/bitcoin/holders/'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')

jsonStr = str(soup.find('script', {'id':'__NEXT_DATA__'}))
jsonStr = re.search(r"({.*})", jsonStr).groups()[0]
jsonData = json.loads(jsonStr)['props']['initialProps']['pageProps']['info']['holders']

df = pd.DataFrame(jsonData).drop('holderList', axis=1).drop_duplicates()
print(df.to_string())
   holderCount  dailyActive  topTenHolderRatio  topTwentyHolderRatio  topFiftyHolderRatio  topHundredHolderRatio
0     39523000       963625               5.24                  7.11                10.38                  13.12
import requests
import pandas as pd

url = 'https://api.coinmarketcap.com/data-api/v3/project-info/detail?slug=bitcoin'
jsonData = requests.get(url).json()
socialStats = jsonData['data']['socialStats']

row = {}
for k, v in socialStats.items():
    if type(v) == dict:
        row.update(v)
    else:
        row.update({k:v})
        
df = pd.DataFrame([row])
print(df.to_string())
   cryptoId commits contributors  stars  forks watchers              lastCommitAt  members               updatedTime
0         1   31588          836  59687  30692     3881  2021-11-30T00:09:02.000Z  3617460  2021-11-30T16:00:02.365Z
-----------------------
import requests
import pandas as pd

alpha = ['count', 'ratio']
payload = {
'id': '1',
'range': '7d'}


for each in alpha:
        url = f'https://api.coinmarketcap.com/data-api/v3/cryptocurrency/detail/holders/{each}'
        jsonData = requests.get(url, params=payload).json()['data']['points']
        
        if each == 'count':
            count_df = pd.DataFrame.from_dict(jsonData,orient='index')
            count_df = count_df.rename(columns={0:'Total Addresses'})
            
        else:
            ratio_df = pd.DataFrame.from_dict(jsonData,orient='index')
            df = count_df.merge(ratio_df, how='left', left_index=True, right_index=True)
            
df = df.sort_index()          
        
print(df.to_string())
                      Total Addresses  topTenHolderRatio  topTwentyHolderRatio  topFiftyHolderRatio  topHundredHolderRatio
2021-11-24T00:00:00Z         39279627               5.25                  7.19                10.51                  13.26
2021-11-25T00:00:00Z         39255811               5.25                  7.19                10.49                  13.22
2021-11-26T00:00:00Z         39339840               5.25                  7.19                10.51                  13.24
2021-11-27T00:00:00Z         39391849               5.23                  7.11                10.45                  13.18
2021-11-28T00:00:00Z         39505340               5.24                  7.11                10.45                  13.18
2021-11-29T00:00:00Z         39502099               5.24                  7.11                10.43                  13.16
2021-11-30T00:00:00Z         39523000               5.24                  7.11                10.38                  13.12
from bs4 import BeautifulSoup
import requests
import json
import re

url = 'https://coinmarketcap.com/currencies/bitcoin/holders/'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')

jsonStr = str(soup.find('script', {'id':'__NEXT_DATA__'}))
jsonStr = re.search(r"({.*})", jsonStr).groups()[0]
jsonData = json.loads(jsonStr)['props']['initialProps']['pageProps']['info']['holders']

df = pd.DataFrame(jsonData).drop('holderList', axis=1).drop_duplicates()
print(df.to_string())
   holderCount  dailyActive  topTenHolderRatio  topTwentyHolderRatio  topFiftyHolderRatio  topHundredHolderRatio
0     39523000       963625               5.24                  7.11                10.38                  13.12
import requests
import pandas as pd

url = 'https://api.coinmarketcap.com/data-api/v3/project-info/detail?slug=bitcoin'
jsonData = requests.get(url).json()
socialStats = jsonData['data']['socialStats']

row = {}
for k, v in socialStats.items():
    if type(v) == dict:
        row.update(v)
    else:
        row.update({k:v})
        
df = pd.DataFrame([row])
print(df.to_string())
   cryptoId commits contributors  stars  forks watchers              lastCommitAt  members               updatedTime
0         1   31588          836  59687  30692     3881  2021-11-30T00:09:02.000Z  3617460  2021-11-30T16:00:02.365Z
-----------------------
import requests
import pandas as pd

alpha = ['count', 'ratio']
payload = {
'id': '1',
'range': '7d'}


for each in alpha:
        url = f'https://api.coinmarketcap.com/data-api/v3/cryptocurrency/detail/holders/{each}'
        jsonData = requests.get(url, params=payload).json()['data']['points']
        
        if each == 'count':
            count_df = pd.DataFrame.from_dict(jsonData,orient='index')
            count_df = count_df.rename(columns={0:'Total Addresses'})
            
        else:
            ratio_df = pd.DataFrame.from_dict(jsonData,orient='index')
            df = count_df.merge(ratio_df, how='left', left_index=True, right_index=True)
            
df = df.sort_index()          
        
print(df.to_string())
                      Total Addresses  topTenHolderRatio  topTwentyHolderRatio  topFiftyHolderRatio  topHundredHolderRatio
2021-11-24T00:00:00Z         39279627               5.25                  7.19                10.51                  13.26
2021-11-25T00:00:00Z         39255811               5.25                  7.19                10.49                  13.22
2021-11-26T00:00:00Z         39339840               5.25                  7.19                10.51                  13.24
2021-11-27T00:00:00Z         39391849               5.23                  7.11                10.45                  13.18
2021-11-28T00:00:00Z         39505340               5.24                  7.11                10.45                  13.18
2021-11-29T00:00:00Z         39502099               5.24                  7.11                10.43                  13.16
2021-11-30T00:00:00Z         39523000               5.24                  7.11                10.38                  13.12
from bs4 import BeautifulSoup
import requests
import json
import re

url = 'https://coinmarketcap.com/currencies/bitcoin/holders/'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')

jsonStr = str(soup.find('script', {'id':'__NEXT_DATA__'}))
jsonStr = re.search(r"({.*})", jsonStr).groups()[0]
jsonData = json.loads(jsonStr)['props']['initialProps']['pageProps']['info']['holders']

df = pd.DataFrame(jsonData).drop('holderList', axis=1).drop_duplicates()
print(df.to_string())
   holderCount  dailyActive  topTenHolderRatio  topTwentyHolderRatio  topFiftyHolderRatio  topHundredHolderRatio
0     39523000       963625               5.24                  7.11                10.38                  13.12
import requests
import pandas as pd

url = 'https://api.coinmarketcap.com/data-api/v3/project-info/detail?slug=bitcoin'
jsonData = requests.get(url).json()
socialStats = jsonData['data']['socialStats']

row = {}
for k, v in socialStats.items():
    if type(v) == dict:
        row.update(v)
    else:
        row.update({k:v})
        
df = pd.DataFrame([row])
print(df.to_string())
   cryptoId commits contributors  stars  forks watchers              lastCommitAt  members               updatedTime
0         1   31588          836  59687  30692     3881  2021-11-30T00:09:02.000Z  3617460  2021-11-30T16:00:02.365Z
-----------------------
import requests
import pandas as pd

alpha = ['count', 'ratio']
payload = {
'id': '1',
'range': '7d'}


for each in alpha:
        url = f'https://api.coinmarketcap.com/data-api/v3/cryptocurrency/detail/holders/{each}'
        jsonData = requests.get(url, params=payload).json()['data']['points']
        
        if each == 'count':
            count_df = pd.DataFrame.from_dict(jsonData,orient='index')
            count_df = count_df.rename(columns={0:'Total Addresses'})
            
        else:
            ratio_df = pd.DataFrame.from_dict(jsonData,orient='index')
            df = count_df.merge(ratio_df, how='left', left_index=True, right_index=True)
            
df = df.sort_index()          
        
print(df.to_string())
                      Total Addresses  topTenHolderRatio  topTwentyHolderRatio  topFiftyHolderRatio  topHundredHolderRatio
2021-11-24T00:00:00Z         39279627               5.25                  7.19                10.51                  13.26
2021-11-25T00:00:00Z         39255811               5.25                  7.19                10.49                  13.22
2021-11-26T00:00:00Z         39339840               5.25                  7.19                10.51                  13.24
2021-11-27T00:00:00Z         39391849               5.23                  7.11                10.45                  13.18
2021-11-28T00:00:00Z         39505340               5.24                  7.11                10.45                  13.18
2021-11-29T00:00:00Z         39502099               5.24                  7.11                10.43                  13.16
2021-11-30T00:00:00Z         39523000               5.24                  7.11                10.38                  13.12
from bs4 import BeautifulSoup
import requests
import json
import re

url = 'https://coinmarketcap.com/currencies/bitcoin/holders/'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')

jsonStr = str(soup.find('script', {'id':'__NEXT_DATA__'}))
jsonStr = re.search(r"({.*})", jsonStr).groups()[0]
jsonData = json.loads(jsonStr)['props']['initialProps']['pageProps']['info']['holders']

df = pd.DataFrame(jsonData).drop('holderList', axis=1).drop_duplicates()
print(df.to_string())
   holderCount  dailyActive  topTenHolderRatio  topTwentyHolderRatio  topFiftyHolderRatio  topHundredHolderRatio
0     39523000       963625               5.24                  7.11                10.38                  13.12
import requests
import pandas as pd

url = 'https://api.coinmarketcap.com/data-api/v3/project-info/detail?slug=bitcoin'
jsonData = requests.get(url).json()
socialStats = jsonData['data']['socialStats']

row = {}
for k, v in socialStats.items():
    if type(v) == dict:
        row.update(v)
    else:
        row.update({k:v})
        
df = pd.DataFrame([row])
print(df.to_string())
   cryptoId commits contributors  stars  forks watchers              lastCommitAt  members               updatedTime
0         1   31588          836  59687  30692     3881  2021-11-30T00:09:02.000Z  3617460  2021-11-30T16:00:02.365Z
-----------------------
import requests
import pandas as pd

alpha = ['count', 'ratio']
payload = {
'id': '1',
'range': '7d'}


for each in alpha:
        url = f'https://api.coinmarketcap.com/data-api/v3/cryptocurrency/detail/holders/{each}'
        jsonData = requests.get(url, params=payload).json()['data']['points']
        
        if each == 'count':
            count_df = pd.DataFrame.from_dict(jsonData,orient='index')
            count_df = count_df.rename(columns={0:'Total Addresses'})
            
        else:
            ratio_df = pd.DataFrame.from_dict(jsonData,orient='index')
            df = count_df.merge(ratio_df, how='left', left_index=True, right_index=True)
            
df = df.sort_index()          
        
print(df.to_string())
                      Total Addresses  topTenHolderRatio  topTwentyHolderRatio  topFiftyHolderRatio  topHundredHolderRatio
2021-11-24T00:00:00Z         39279627               5.25                  7.19                10.51                  13.26
2021-11-25T00:00:00Z         39255811               5.25                  7.19                10.49                  13.22
2021-11-26T00:00:00Z         39339840               5.25                  7.19                10.51                  13.24
2021-11-27T00:00:00Z         39391849               5.23                  7.11                10.45                  13.18
2021-11-28T00:00:00Z         39505340               5.24                  7.11                10.45                  13.18
2021-11-29T00:00:00Z         39502099               5.24                  7.11                10.43                  13.16
2021-11-30T00:00:00Z         39523000               5.24                  7.11                10.38                  13.12
from bs4 import BeautifulSoup
import requests
import json
import re

url = 'https://coinmarketcap.com/currencies/bitcoin/holders/'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')

jsonStr = str(soup.find('script', {'id':'__NEXT_DATA__'}))
jsonStr = re.search(r"({.*})", jsonStr).groups()[0]
jsonData = json.loads(jsonStr)['props']['initialProps']['pageProps']['info']['holders']

df = pd.DataFrame(jsonData).drop('holderList', axis=1).drop_duplicates()
print(df.to_string())
   holderCount  dailyActive  topTenHolderRatio  topTwentyHolderRatio  topFiftyHolderRatio  topHundredHolderRatio
0     39523000       963625               5.24                  7.11                10.38                  13.12
import requests
import pandas as pd

url = 'https://api.coinmarketcap.com/data-api/v3/project-info/detail?slug=bitcoin'
jsonData = requests.get(url).json()
socialStats = jsonData['data']['socialStats']

row = {}
for k, v in socialStats.items():
    if type(v) == dict:
        row.update(v)
    else:
        row.update({k:v})
        
df = pd.DataFrame([row])
print(df.to_string())
   cryptoId commits contributors  stars  forks watchers              lastCommitAt  members               updatedTime
0         1   31588          836  59687  30692     3881  2021-11-30T00:09:02.000Z  3617460  2021-11-30T16:00:02.365Z
-----------------------
import requests
import pandas as pd

alpha = ['count', 'ratio']
payload = {
'id': '1',
'range': '7d'}


for each in alpha:
        url = f'https://api.coinmarketcap.com/data-api/v3/cryptocurrency/detail/holders/{each}'
        jsonData = requests.get(url, params=payload).json()['data']['points']
        
        if each == 'count':
            count_df = pd.DataFrame.from_dict(jsonData,orient='index')
            count_df = count_df.rename(columns={0:'Total Addresses'})
            
        else:
            ratio_df = pd.DataFrame.from_dict(jsonData,orient='index')
            df = count_df.merge(ratio_df, how='left', left_index=True, right_index=True)
            
df = df.sort_index()          
        
print(df.to_string())
                      Total Addresses  topTenHolderRatio  topTwentyHolderRatio  topFiftyHolderRatio  topHundredHolderRatio
2021-11-24T00:00:00Z         39279627               5.25                  7.19                10.51                  13.26
2021-11-25T00:00:00Z         39255811               5.25                  7.19                10.49                  13.22
2021-11-26T00:00:00Z         39339840               5.25                  7.19                10.51                  13.24
2021-11-27T00:00:00Z         39391849               5.23                  7.11                10.45                  13.18
2021-11-28T00:00:00Z         39505340               5.24                  7.11                10.45                  13.18
2021-11-29T00:00:00Z         39502099               5.24                  7.11                10.43                  13.16
2021-11-30T00:00:00Z         39523000               5.24                  7.11                10.38                  13.12
from bs4 import BeautifulSoup
import requests
import json
import re

url = 'https://coinmarketcap.com/currencies/bitcoin/holders/'
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')

jsonStr = str(soup.find('script', {'id':'__NEXT_DATA__'}))
jsonStr = re.search(r"({.*})", jsonStr).groups()[0]
jsonData = json.loads(jsonStr)['props']['initialProps']['pageProps']['info']['holders']

df = pd.DataFrame(jsonData).drop('holderList', axis=1).drop_duplicates()
print(df.to_string())
   holderCount  dailyActive  topTenHolderRatio  topTwentyHolderRatio  topFiftyHolderRatio  topHundredHolderRatio
0     39523000       963625               5.24                  7.11                10.38                  13.12
import requests
import pandas as pd

url = 'https://api.coinmarketcap.com/data-api/v3/project-info/detail?slug=bitcoin'
jsonData = requests.get(url).json()
socialStats = jsonData['data']['socialStats']

row = {}
for k, v in socialStats.items():
    if type(v) == dict:
        row.update(v)
    else:
        row.update({k:v})
        
df = pd.DataFrame([row])
print(df.to_string())
   cryptoId commits contributors  stars  forks watchers              lastCommitAt  members               updatedTime
0         1   31588          836  59687  30692     3881  2021-11-30T00:09:02.000Z  3617460  2021-11-30T16:00:02.365Z
-----------------------
soup.select('h3:-soup-contains("Holders Statistics") ~ div :not(span)')
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
options = webdriver.ChromeOptions()
service = ChromeService(executable_path='YOUR PATH TO CHROM DRIVER')
driver = webdriver.Chrome(service=service, options=options)
driver.get('https://coinmarketcap.com/currencies/bitcoin/holders/')

soup = BeautifulSoup(driver.page_source,'html.parser')

data = {x.get_text('|').split('|')[0]:x.get_text('|').split('|')[1] for x in soup.select('h3:-soup-contains("Holders Statistics") ~ div :not(span)')}
print(data)

driver.close()
{'Total Addresses': '39,523,000',
 'Active Addresses': '24h',
 'Top 10 Holders': '5.24%',
 'Top 20 Holders': '7.11%',
 'Top 50 Holders': '10.38%',
 'Top 100 Holders': '13.12%'}
-----------------------
soup.select('h3:-soup-contains("Holders Statistics") ~ div :not(span)')
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
options = webdriver.ChromeOptions()
service = ChromeService(executable_path='YOUR PATH TO CHROM DRIVER')
driver = webdriver.Chrome(service=service, options=options)
driver.get('https://coinmarketcap.com/currencies/bitcoin/holders/')

soup = BeautifulSoup(driver.page_source,'html.parser')

data = {x.get_text('|').split('|')[0]:x.get_text('|').split('|')[1] for x in soup.select('h3:-soup-contains("Holders Statistics") ~ div :not(span)')}
print(data)

driver.close()
{'Total Addresses': '39,523,000',
 'Active Addresses': '24h',
 'Top 10 Holders': '5.24%',
 'Top 20 Holders': '7.11%',
 'Top 50 Holders': '10.38%',
 'Top 100 Holders': '13.12%'}
-----------------------
soup.select('h3:-soup-contains("Holders Statistics") ~ div :not(span)')
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
options = webdriver.ChromeOptions()
service = ChromeService(executable_path='YOUR PATH TO CHROM DRIVER')
driver = webdriver.Chrome(service=service, options=options)
driver.get('https://coinmarketcap.com/currencies/bitcoin/holders/')

soup = BeautifulSoup(driver.page_source,'html.parser')

data = {x.get_text('|').split('|')[0]:x.get_text('|').split('|')[1] for x in soup.select('h3:-soup-contains("Holders Statistics") ~ div :not(span)')}
print(data)

driver.close()
{'Total Addresses': '39,523,000',
 'Active Addresses': '24h',
 'Top 10 Holders': '5.24%',
 'Top 20 Holders': '7.11%',
 'Top 50 Holders': '10.38%',
 'Top 100 Holders': '13.12%'}

Scraping with BeautifulSoup - problem with same class names

copy iconCopydownload iconDownload
import requests
import pandas as pd

headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36'}

url = "https://www.coingecko.com/en/coins/bitcoin/historical_data/usd?start_date=2021-01-01&end_date=2021-09-30#panel"

req = requests.get(url,headers=headers)

table = pd.read_html(req.text, attrs = {"class":"table-striped"} )

df = table[0]#.to_csv('score.csv',index = False)

print(df)
 Date        Market Cap            Volume     Open    Close
0    2021-09-30  $782,626,384,092   $30,068,690,312  $41,588      NaN
1    2021-09-29  $775,534,111,089   $29,691,944,223  $41,010  $41,588
2    2021-09-28  $794,889,951,096   $30,483,144,439  $42,247  $41,010
3    2021-09-27  $825,341,135,636   $30,462,815,705  $43,337  $42,247
4    2021-09-26  $808,279,417,023   $30,898,116,660  $42,857  $43,337
..          ...               ...               ...      ...      ...
268  2021-01-05  $585,726,270,249   $74,657,165,356  $31,516  $34,082
269  2021-01-04  $613,616,917,626  $178,894,068,361  $33,008  $31,516
270  2021-01-03  $597,887,713,054   $57,273,436,641  $32,164  $33,008
271  2021-01-02  $545,593,282,215   $34,089,717,988  $29,352  $32,164
272  2021-01-01  $539,438,036,436   $43,503,516,563  $29,022  $29,352

[273 rows x 5 columns]
-----------------------
import requests
import pandas as pd

headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36'}

url = "https://www.coingecko.com/en/coins/bitcoin/historical_data/usd?start_date=2021-01-01&end_date=2021-09-30#panel"

req = requests.get(url,headers=headers)

table = pd.read_html(req.text, attrs = {"class":"table-striped"} )

df = table[0]#.to_csv('score.csv',index = False)

print(df)
 Date        Market Cap            Volume     Open    Close
0    2021-09-30  $782,626,384,092   $30,068,690,312  $41,588      NaN
1    2021-09-29  $775,534,111,089   $29,691,944,223  $41,010  $41,588
2    2021-09-28  $794,889,951,096   $30,483,144,439  $42,247  $41,010
3    2021-09-27  $825,341,135,636   $30,462,815,705  $43,337  $42,247
4    2021-09-26  $808,279,417,023   $30,898,116,660  $42,857  $43,337
..          ...               ...               ...      ...      ...
268  2021-01-05  $585,726,270,249   $74,657,165,356  $31,516  $34,082
269  2021-01-04  $613,616,917,626  $178,894,068,361  $33,008  $31,516
270  2021-01-03  $597,887,713,054   $57,273,436,641  $32,164  $33,008
271  2021-01-02  $545,593,282,215   $34,089,717,988  $29,352  $32,164
272  2021-01-01  $539,438,036,436   $43,503,516,563  $29,022  $29,352

[273 rows x 5 columns]
-----------------------
from bs4 import BeautifulSoup
import requests
import pandas as pd

website = 'https://www.coingecko.com/en/coins/bitcoin/historical_data/usd?start_date=2021-01-01&end_date=2021-09-30#panel'

response = requests.get(website)

soup = BeautifulSoup(response.content, 'html.parser')

results = soup.select('table.table-striped tbody tr')

# close = []
# volume = []
# datum = []
# open = []
data=[]
for result in results:
    close = result.select_one('td.text-center:nth-child(5)').get_text(strip=True)
    volume = result.select_one('td.text-center:nth-child(3)').get_text(strip=True)
    open = result.select_one('td.text-center:nth-child(4)').get_text(strip=True)
    date = result.select_one('th[scope="row"]').get_text(strip=True)
    data.append([close,volume,open,date])


cols = ["close", "volume","open","datum"]

df = pd.DataFrame(data, columns= cols)
print(df)
     close            volume     open       datum
0        N/A   $30,068,690,312  $41,588  2021-09-30
1    $41,588   $29,691,944,223  $41,010  2021-09-29
2    $41,010   $30,483,144,439  $42,247  2021-09-28
3    $42,247   $30,462,815,705  $43,337  2021-09-27
4    $43,337   $30,898,116,660  $42,857  2021-09-26
..       ...               ...      ...         ...
268  $34,082   $74,657,165,356  $31,516  2021-01-05
269  $31,516  $178,894,068,361  $33,008  2021-01-04
270  $33,008   $57,273,436,641  $32,164  2021-01-03
271  $32,164   $34,089,717,988  $29,352  2021-01-02
272  $29,352   $43,503,516,563  $29,022  2021-01-01

[273 rows x 4 columns]
-----------------------
from bs4 import BeautifulSoup
import requests
import pandas as pd

website = 'https://www.coingecko.com/en/coins/bitcoin/historical_data/usd?start_date=2021-01-01&end_date=2021-09-30#panel'

response = requests.get(website)

soup = BeautifulSoup(response.content, 'html.parser')

results = soup.select('table.table-striped tbody tr')

# close = []
# volume = []
# datum = []
# open = []
data=[]
for result in results:
    close = result.select_one('td.text-center:nth-child(5)').get_text(strip=True)
    volume = result.select_one('td.text-center:nth-child(3)').get_text(strip=True)
    open = result.select_one('td.text-center:nth-child(4)').get_text(strip=True)
    date = result.select_one('th[scope="row"]').get_text(strip=True)
    data.append([close,volume,open,date])


cols = ["close", "volume","open","datum"]

df = pd.DataFrame(data, columns= cols)
print(df)
     close            volume     open       datum
0        N/A   $30,068,690,312  $41,588  2021-09-30
1    $41,588   $29,691,944,223  $41,010  2021-09-29
2    $41,010   $30,483,144,439  $42,247  2021-09-28
3    $42,247   $30,462,815,705  $43,337  2021-09-27
4    $43,337   $30,898,116,660  $42,857  2021-09-26
..       ...               ...      ...         ...
268  $34,082   $74,657,165,356  $31,516  2021-01-05
269  $31,516  $178,894,068,361  $33,008  2021-01-04
270  $33,008   $57,273,436,641  $32,164  2021-01-03
271  $32,164   $34,089,717,988  $29,352  2021-01-02
272  $29,352   $43,503,516,563  $29,022  2021-01-01

[273 rows x 4 columns]
-----------------------
from collections import defaultdict
from bs4 import BeautifulSoup
import requests

website = 'https://www.coingecko.com/en/coins/bitcoin/historical_data/usd?start_date=2021-01-01&end_date=2021-09-30#panel'

response = requests.get(website)

soup = BeautifulSoup(response.content, 'html.parser')
table = soup.find('table', {'class':'table-striped'})
columns = [th.text for th in table.find('thead').find_all('th')]
rows = table.find('tbody').find_all('tr')

data = defaultdict(list)
[data[columns[i]].append(col.text.strip()) for row in rows for i, col in enumerate(row.find_all('td'))]

print(data.keys())
print(data['Date'][:5])
dict_keys(['Date', 'Market Cap', 'Volume', 'Open'])
['$782,626,384,092', '$775,534,111,089', '$794,889,951,096', '$825,341,135,636', '$808,279,417,023']
r = 0
for row in rows:
   cols = row.find_all('td')
   date[r] = cols[0]
   cap[r] = cols[1]
   ...
   r += 1
-----------------------
from collections import defaultdict
from bs4 import BeautifulSoup
import requests

website = 'https://www.coingecko.com/en/coins/bitcoin/historical_data/usd?start_date=2021-01-01&end_date=2021-09-30#panel'

response = requests.get(website)

soup = BeautifulSoup(response.content, 'html.parser')
table = soup.find('table', {'class':'table-striped'})
columns = [th.text for th in table.find('thead').find_all('th')]
rows = table.find('tbody').find_all('tr')

data = defaultdict(list)
[data[columns[i]].append(col.text.strip()) for row in rows for i, col in enumerate(row.find_all('td'))]

print(data.keys())
print(data['Date'][:5])
dict_keys(['Date', 'Market Cap', 'Volume', 'Open'])
['$782,626,384,092', '$775,534,111,089', '$794,889,951,096', '$825,341,135,636', '$808,279,417,023']
r = 0
for row in rows:
   cols = row.find_all('td')
   date[r] = cols[0]
   cap[r] = cols[1]
   ...
   r += 1
-----------------------
from collections import defaultdict
from bs4 import BeautifulSoup
import requests

website = 'https://www.coingecko.com/en/coins/bitcoin/historical_data/usd?start_date=2021-01-01&end_date=2021-09-30#panel'

response = requests.get(website)

soup = BeautifulSoup(response.content, 'html.parser')
table = soup.find('table', {'class':'table-striped'})
columns = [th.text for th in table.find('thead').find_all('th')]
rows = table.find('tbody').find_all('tr')

data = defaultdict(list)
[data[columns[i]].append(col.text.strip()) for row in rows for i, col in enumerate(row.find_all('td'))]

print(data.keys())
print(data['Date'][:5])
dict_keys(['Date', 'Market Cap', 'Volume', 'Open'])
['$782,626,384,092', '$775,534,111,089', '$794,889,951,096', '$825,341,135,636', '$808,279,417,023']
r = 0
for row in rows:
   cols = row.find_all('td')
   date[r] = cols[0]
   cap[r] = cols[1]
   ...
   r += 1

How can I get notified when money has been sent to a particular Bitcoin address on a local regtest network?

copy iconCopydownload iconDownload
docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
docker exec -it 0aa2e863cd9927 bash
peerbloomfilters=1
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
import java.io.File;

import org.bitcoinj.core.Address;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.params.RegTestParams;

public class Kit {

  public static void main(String[] args) {
    Kit kit  = new Kit();
    kit.run();
  }

  private synchronized void run(){
    NetworkParameters params = RegTestParams.get();
    WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
    kit.connectToLocalHost();

    kit.startAsync();
    kit.awaitRunning();

    kit.wallet().addWatchedAddress(Address.fromString(params, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));

    kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> {
      System.out.println("-----> coins resceived: " + tx.getTxId());
    });

    while (true) {
      try {
        this.wait(2000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
...
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] ->pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
-----> coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
2021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms
-----------------------
docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
docker exec -it 0aa2e863cd9927 bash
peerbloomfilters=1
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
import java.io.File;

import org.bitcoinj.core.Address;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.params.RegTestParams;

public class Kit {

  public static void main(String[] args) {
    Kit kit  = new Kit();
    kit.run();
  }

  private synchronized void run(){
    NetworkParameters params = RegTestParams.get();
    WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
    kit.connectToLocalHost();

    kit.startAsync();
    kit.awaitRunning();

    kit.wallet().addWatchedAddress(Address.fromString(params, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));

    kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> {
      System.out.println("-----> coins resceived: " + tx.getTxId());
    });

    while (true) {
      try {
        this.wait(2000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
...
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] ->pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
-----> coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
2021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms
-----------------------
docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
docker exec -it 0aa2e863cd9927 bash
peerbloomfilters=1
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
import java.io.File;

import org.bitcoinj.core.Address;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.params.RegTestParams;

public class Kit {

  public static void main(String[] args) {
    Kit kit  = new Kit();
    kit.run();
  }

  private synchronized void run(){
    NetworkParameters params = RegTestParams.get();
    WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
    kit.connectToLocalHost();

    kit.startAsync();
    kit.awaitRunning();

    kit.wallet().addWatchedAddress(Address.fromString(params, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));

    kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> {
      System.out.println("-----> coins resceived: " + tx.getTxId());
    });

    while (true) {
      try {
        this.wait(2000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
...
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] ->pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
-----> coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
2021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms
-----------------------
docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
docker exec -it 0aa2e863cd9927 bash
peerbloomfilters=1
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
import java.io.File;

import org.bitcoinj.core.Address;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.params.RegTestParams;

public class Kit {

  public static void main(String[] args) {
    Kit kit  = new Kit();
    kit.run();
  }

  private synchronized void run(){
    NetworkParameters params = RegTestParams.get();
    WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
    kit.connectToLocalHost();

    kit.startAsync();
    kit.awaitRunning();

    kit.wallet().addWatchedAddress(Address.fromString(params, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));

    kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> {
      System.out.println("-----> coins resceived: " + tx.getTxId());
    });

    while (true) {
      try {
        this.wait(2000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
...
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] ->pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
-----> coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
2021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms
-----------------------
docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
docker exec -it 0aa2e863cd9927 bash
peerbloomfilters=1
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
import java.io.File;

import org.bitcoinj.core.Address;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.params.RegTestParams;

public class Kit {

  public static void main(String[] args) {
    Kit kit  = new Kit();
    kit.run();
  }

  private synchronized void run(){
    NetworkParameters params = RegTestParams.get();
    WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
    kit.connectToLocalHost();

    kit.startAsync();
    kit.awaitRunning();

    kit.wallet().addWatchedAddress(Address.fromString(params, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));

    kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> {
      System.out.println("-----> coins resceived: " + tx.getTxId());
    });

    while (true) {
      try {
        this.wait(2000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
...
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] ->pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
-----> coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
2021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms
-----------------------
docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
docker exec -it 0aa2e863cd9927 bash
peerbloomfilters=1
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
import java.io.File;

import org.bitcoinj.core.Address;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.params.RegTestParams;

public class Kit {

  public static void main(String[] args) {
    Kit kit  = new Kit();
    kit.run();
  }

  private synchronized void run(){
    NetworkParameters params = RegTestParams.get();
    WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
    kit.connectToLocalHost();

    kit.startAsync();
    kit.awaitRunning();

    kit.wallet().addWatchedAddress(Address.fromString(params, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));

    kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> {
      System.out.println("-----> coins resceived: " + tx.getTxId());
    });

    while (true) {
      try {
        this.wait(2000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
...
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] ->pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
-----> coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
2021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms
-----------------------
docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
docker exec -it 0aa2e863cd9927 bash
peerbloomfilters=1
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
import java.io.File;

import org.bitcoinj.core.Address;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.params.RegTestParams;

public class Kit {

  public static void main(String[] args) {
    Kit kit  = new Kit();
    kit.run();
  }

  private synchronized void run(){
    NetworkParameters params = RegTestParams.get();
    WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
    kit.connectToLocalHost();

    kit.startAsync();
    kit.awaitRunning();

    kit.wallet().addWatchedAddress(Address.fromString(params, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));

    kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> {
      System.out.println("-----> coins resceived: " + tx.getTxId());
    });

    while (true) {
      try {
        this.wait(2000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
...
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] ->pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
-----> coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
2021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms
-----------------------
docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
docker exec -it 0aa2e863cd9927 bash
peerbloomfilters=1
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
import java.io.File;

import org.bitcoinj.core.Address;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.params.RegTestParams;

public class Kit {

  public static void main(String[] args) {
    Kit kit  = new Kit();
    kit.run();
  }

  private synchronized void run(){
    NetworkParameters params = RegTestParams.get();
    WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
    kit.connectToLocalHost();

    kit.startAsync();
    kit.awaitRunning();

    kit.wallet().addWatchedAddress(Address.fromString(params, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));

    kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> {
      System.out.println("-----> coins resceived: " + tx.getTxId());
    });

    while (true) {
      try {
        this.wait(2000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
...
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] ->pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
-----> coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
2021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms
-----------------------
docker run -p 18444:19000 -d ulamlabs/bitcoind-custom-regtest:latest
docker exec -it 0aa2e863cd9927 bash
peerbloomfilters=1
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest getnewaddress
2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest generatetoaddress 101 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 
import java.io.File;

import org.bitcoinj.core.Address;
import org.bitcoinj.core.NetworkParameters;
import org.bitcoinj.kits.WalletAppKit;
import org.bitcoinj.params.RegTestParams;

public class Kit {

  public static void main(String[] args) {
    Kit kit  = new Kit();
    kit.run();
  }

  private synchronized void run(){
    NetworkParameters params = RegTestParams.get();
    WalletAppKit kit = new WalletAppKit(params, new File("."), "walletappkit-example");
    kit.connectToLocalHost();

    kit.startAsync();
    kit.awaitRunning();

    kit.wallet().addWatchedAddress(Address.fromString(params, "2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181"));

    kit.wallet().addCoinsReceivedEventListener((wallet, tx, prevBalance, newBalance) -> {
      System.out.println("-----> coins resceived: " + tx.getTxId());
    });

    while (true) {
      try {
        this.wait(2000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
}
docker exec -it 0aa2e863cd9927 bitcoin-cli -regtest sendtoaddress 2N23tWAFEtBtTgxNjBNmnwzsiPdLcNek181 0.00001
0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Received a pending transaction 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26 that spends 0.00 BTC from our own wallet, and sends us 0.00001 BTC
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] commitTx of 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
...
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] ->pending: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.537 INFO  [NioClientManager][Wallet] Estimated balance is now: 0.00001 BTC
-----> coins resceived: 0f972642713c72ae0fe03fe51818b9ea4d483720b69b90e795f35eb80a587c26
2021-11-09 23:51:20.538 INFO  [NioClientManager][WalletFiles] Saving wallet; last seen block is height 165, date 2021-11-09T22:50:48Z, hash 23451521947bc5ff098c088ae0fc445becca8837d39ee8f6dd88f2c47ad5ac23
2021-11-09 23:51:20.543 INFO  [NioClientManager][WalletFiles] Save completed in 4.736 ms

Community Discussions

Trending Discussions on bitcoin
  • Flutter - How to refresh a Widget on button Click?
  • Adjusting Labels of Altair Grouped Bar Chart
  • different htaccess for directory issue
  • Add data into 2 columns in same row with the data coming from Javascipt Websocket
  • How to resample frequency conditional on two columns in pandas?
  • How to fix LevelDB library load error when running RSKj node on a Windows machine?
  • after updating flutter, Firebase.initializeApp() does not seem to work on my phone anymore
  • How to retreive the date when video has been released on Youtube using Python and Selenium
  • Calculating Bitcoin mining difficulty
  • Python - BeautifulSoup - Selecting a 'div' with 'class'-attribute shows every div in the html
Trending Discussions on bitcoin

QUESTION

Flutter - How to refresh a Widget on button Click?

Asked 2022-Mar-01 at 10:15

I'm making an app where I plot charts of cryptocurrency. I have a file like this, that renders a chart of btc/24h in it. I'm using chart_sparkline package to plot the chart.

I have the following code, and it is not working on a button click, how do I fix this?

import 'package:flutter/material.dart';
import 'package:tracker/renderchart.dart';

class Portfolio extends StatefulWidget {
    @override
    _PortfolioState createState() => _PortfolioState();
}

class _PortfolioState extends State<Portfolio> {
    Widget portfolioChart = RenderPortfolioChart(coin: "bitcoin", days: 1);

    @override
    Widget build(BuildContext context) {
        return Container(
            child: Column(
                children: [
                    portfolioChart,

                    const Padding(padding: EdgeInsets.only(top: 10.0)),

                    const Text("Hello, there!", style: TextStyle(color: Colors.white)),

                    const Padding(padding: EdgeInsets.only(top: 10.0)),

                    ElevatedButton(
                        onPressed: (){
                            print("updating chart");
                            setState(() {
                              portfolioChart = RenderPortfolioChart(coin: "ethereum", days: 1);
                            });
                        },

                        child: Text("ETH"),
                    )
                ]
            ),
        );
    }
}

Basically, the elevatedButton should update the chart, but it is not working in my case, how to fix this?

ANSWER

Answered 2022-Mar-01 at 10:15

I fixed this, I was passing constructor parameters of Portfolio to _PortfolioState, this won't update the values the next time. Instead of passing these values to _PortfolioState, I used widget.coin and widget.days to extract the data from the Portfolio class.

Thanks to this StackOverflow link: Passing Data to a Stateful Widget in Flutter

Source https://stackoverflow.com/questions/71293849

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install bitcoin

You can download it from GitHub.

Support

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

DOWNLOAD this Library from

Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

Explore Related Topics

Share this Page

share link
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from
over 430 million Knowledge Items
Find more libraries
Reuse Solution Kits and Libraries Curated by Popular Use Cases

Save this library and start creating your kit

  • © 2022 Open Weaver Inc.