Bitcoin Core钱包如何安装与对接

资讯 2024-06-23 阅读:27 评论:0
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
发布时间:2021-12-04 11:39:07 来源:亿速云 阅读:708 作者:小新 栏目:互联网科技

这篇文章主要介绍了Bitcoin Core钱包如何安装与对接,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

Bitcoin介绍

比特币(Bitcoin)的概念最初由中本聪在2008年11月1日提出,并于2009年1月3日正式诞生。根据中本聪的思路设计发布的开源软件以及建构其上的P2P网络。比特币是一种P2P形式的虚拟的加密数字货币。点对点的传输意味着一个去中心化的支付系统。与所有的货币不同,比特币不依靠特定货币机构发行,它依据特定算法,通过大量的计算产生,比特币经济使用整个P2P网络中众多节点构成的分布式数据库来确认并记录所有的交易行为,并使用密码学的设计来确保货币流通各个环节安全性。P2P的去中心化特性与算法本身可以确保无法通过大量制造比特币来人为操控币值。基于密码学的设计可以使比特币只能被真实的拥有者转移或支付。这同样确保了货币所有权与流通交易的匿名性。比特币与其他虚拟货币最大的不同,是其总数量非常有限,具有极强的稀缺性。 bitcoin百度百科 bitcoin维基百科

Bitcoin, unlike all currencies, is not a centralized payment system. Bitcoin is not issued by a specific monetary institution, and it is based on a certain algorithm, generated by a large number of calculations, the Bitcoin economy uses a distributed database consisting of numerous nodes in the entire P2P network to identify and record all transactions and uses cryptographic designs to ensure the safety of the various links in currency circulation. The centralization of P2P and the algorithm itself can ensure that the value of currency is not artificially controlled by a large number of bitcos.

Bitcoin core钱包介绍

目前网络上有很多社区开发了多款bitcoin钱包,其中bitcoin core钱包安装后会下载全部节点,并且有一套rpc接口协议,代码在github也全部开源,bitcoin core支持多个操作系统,我们可以根据自己需要进行安装。我做过的项目需求都是交易系统和支付系统实现充值,提现,和归集功能,bitcoin core对我来说足够了,所以就选择他了。至于其他钱包我就没有具体深入研究了,如果有特殊需求的业务,也可以去研究下其他钱包是否支持。 想研究其他钱包可点击链接进行查看:bitcoin维基百科

There are currently many communities on the network that have developed a multiplicity of bitcoin wallets, of which bitcoin core wallets will be downloaded from all nodes when installed, and there is an rpc interface protocol, the code is all open in github, and bitcoin core supports several operating systems, and we can install them according to our own needs. I've done projects that require transactional and payment systems to charge values, cash withdrawals, and collection functions, and bitcoin core is enough for me, so I chose him. As for other wallets, I have no specific in-depth study, and if I have a business with special needs, I can look at other wallets if they are supported.

Bitcoin 需要知道的知识点

因为虚拟币价值比较高,所以有很多黑客会想尽各种办法盗取虚拟币资产,像一线交易所也都被盗过,目前最简单和成本最低的防范方法就是做冷热钱包隔离,我们在设计系统的时候也应该考虑此方面的解决方案,然后在这个思路上面延伸。我的解决方案是用户充值进钱包的虚拟币,我每天会通过定时任务把热钱包的虚拟币转到冷钱包。这样的话黑客就算黑了我们钱包,他能盗走的币也很少,可以减少平台的损失。

Because of the high value of virtual currency, many hackers would try to steal virtual currency assets by every means, like a single exchange, and the simplest and least costly precaution would be to isolate cold and hot wallets, which we should consider when designing the system, and to expand on that idea. My solution would be for users to fill in the virtual currency of wallets, which I would transfer daily to cold wallets through a timed task. If hackers hack our wallets, the currency he can steal would be very small and reduce the loss of platforms.

  • 热钱包,我们现在搭建的就属于热钱包,简单来讲就是与外界联网的钱包,充值地址的币,每天都会划转到冷钱包

    Hot wallets, what we're building right now are hot wallets, simple wallets connected to the outside world, coins filled with addresses, cut to cold wallets every day.

  • 冷钱包,与外界网络完全隔离,目前市面上也有很多相关的硬件钱包产品

    Cold wallets, completely isolated from the outside network. There's a lot of hardware wallet products on the market.

  • 区块链的机制就是一但生成交易就无法篡改和撤回了,我们在开发的时候也要多注意,特别是在转币的时候

    The block chain is a mechanism that produces transactions that cannot be tampered with and withdrawn, and we need to be more careful when we develop them, especially when we switch money.

  • utxo,官方解释是未经使用的交易输出,具体介绍可以点击看其他大哥写的详细介绍,utxo介绍

    utxo, the official explanation is an unused transaction output, with specifics to click on details written by other big brothers, utxo.

Bitcoin core钱包安装

1.服务器硬件配置
  • 我目前用的服务器配置是aws ubuntu 2c,8g,500g硬盘,下面的配置信息是我给的建议

    The server configuration I'm currently using is aws ubuntu 2c, 8g, 500g hard drive.

  • cpu:2c(同步区块的时候会占用cpu)

    cpu:2c (cpu is occupied while synchronizing blocks)

  • 内存:8G

    Memory: 8G

  • 硬盘:500G(不差钱上固态,固态同步区块速度会快很多)

    Hard drive: 500G.

2.注意事项

区块同步时cpu会怼满,所以你们到时候不要大惊小怪了,这是正常的,等区块同步完成后就会恢复正常

When the blocks are synchronized, cpu will be full, so don't make a fuss. It's normal. When the blocks are synchronized, they'll be back to normal.

3.安装钱包

安装也有多种方法,可以在上面地址下载安装文件也行,这里我是直接通过ubuntu的apt下载安装 首先需要添加bitcoin的源:

There are a number of ways to install it, either by downloading it at the address above, or by downloading it directly through ubuntu's apt download. First, I need to add a bitcoin source:

sudo add-apt-repository ppa:bitcoin/bitcoin

添加源成功之后,需要更新下源:

After adding the source has been successful, the source needs to be updated:

sudo apt-get update

安装bitcoind:

Install bitcound:

sudo apt-get install bitcoind

可以选择性的安装bitcoin-qt,在ubuntu-service版本上是不需要bitcoin-qt的,如果是在ubuntu-desktop上面想使用bitcoin-qt的话可以选择安装:

The optional installation of bitcoin-qt, which does not require bitcoin-qt in the ubuntu-service version, is optional if it is intended to use bitcoin-qt on ubuntu-desktop:

sudo apt-get install bitcoin-qt
4.运行bitcoind

直接输入bitcoind命令可以让bitcoind在前台直接运行:

Directly enter the bitcoind command to allow bitcoin to run directly from the front desk:

bitcoind

也可以采用后台运行的方式,也可以和我一样用nohup打印一下日志

You can run it backstage, you can print logs with nohup just like I do.

nohup bitcoind &

通过命令查看钱包版本,以及是否安装成功

View wallet version with command and install successfully

bitcoind -version

Bitcoin Core Daemon version v0.18.0.0-g2472733a24a9364e4c6233ccd04166a26a68cc65
Copyright (C) 2009-2019 The Bitcoin Core developers

Please contribute if you find Bitcoin Core useful. Visit
<https: bitcoincore.org> for further information about the software.
The source code is available from <https: github.com bitcoin>.

This is experimental software.
Distributed under the MIT software license, see the accompanying file COPYING
or <https: opensource.org licenses mit>

This product includes software developed by the OpenSSL Project for use in the
OpenSSL Toolkit <https: www.openssl.org> and cryptographic software written by
Eric Young and UPnP software written by Thomas Bernard.

启动后钱包会自动同步区块,可以打开日志查看具体同步情况

Autosync blocks after startup wallets can open logs to see specific synchronizations

tail -f nohup.out

进入bitcoin安装目录

Enter bitcoin install directory

cd $HOME/.bitcoin
ls
banlist.dat  bitcoind.pid  blocks  chainstate  debug.log  peers.dat  wallets
ls wallets/
database  db.log  wallet.dat

因为此次我安装的版本是0.18,所以相比老版本有所改变,wallet.bat文件在wallet文件夹里面,上面我们可以看到文件夹最新结构,下面是具体文件夹介绍

Because the version I installed is 0.18, so there's a change from the old version, and the Wallet.bat file is in the Wallet folder, where we can see the latest structure of the folder, and here's a description of the folder.

bitcoind.pid bitcoind   运行的进程文件

blocks  区块链数据文件

chainstate 区块链状态的数据库使用LevelDB存储

db.log 数据库日志文件

debug.log 运行时的日志文件

wallet.dat 钱包文件(这个要划重点了,此文件保存了我们钱包生成的私钥,特别重要,建议通过编写shell脚本或者使用后台程序每天做个备份)

安装supervisor(进程监控),钱包挂掉可以使程序自启

Installation of supervisor (process monitor) with a wallet hanging to enable the program to start on its own

sudo apt-get install supervisor
5.钱包命令介绍
bitcoin-cli getwalletinfo   查看钱包详情,在0.18版本中,以前的getinfo已经取消
{
  "walletname": "",
  "walletversion": 169900,              钱包版本
  "balance": 0.00000000,                钱包余额
  "unconfirmed_balance": 0.00000000,    未确认余额
  "immature_balance": 0.00000000,       这个暂时还不清楚
  "txcount": 0,                         钱包内交易数量
  "keypoololdest": 1562826486,          密钥池内最早密钥创建时间
  "keypoolsize": 1000,                  密钥池大小
  "keypoolsize_hd_internal": 1000,
  "paytxfee": 0.00000000,               手续费率(这个比较重要,后面单独讲)
  "hdseedid": "ed13b2019c2e28e9dc84cf7124ba2e36cebcb656",
  "private_keys_enabled": true
}

bitcoin-cli getblockchaininfo   查看区块详情
{
  "chain": "main",
  "blocks": 238558,                     钱包当前区块(btc安装启动后一般1-2天可以同步到最新区块高度)
  "headers": 584893,                    当前最新区块高度
  ....  后面还有其他信息,我们暂不关注
}

bitcoin-cli sendtoaddress   转账接口(后面具体介绍)
Response:
1. "address"            (string, required) 接收地址
2. "amount"             (numeric or string, required) 转账金额

Result:
"txid"                  (string) 唯一标识tx_id

Examples:
> bitcoin-cli sendtoaddress "1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd" 0.1
> curl --user myusername --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendtoaddress", "params": ["1M72Sfpbz1BPpXFHz9m3CdqATR44Jvaydd", 0.1] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/

业务系统对接BTC钱包

1.充值和提现实现方式
充值
  • 用户在页面进入btc充值页面时,调用后台查询充值地址,如果没有充值地址我们通过btc钱包rpc接口“getnewaddress”创建一个属于用户的充值地址保存到数据库并返回给页面,用户往这个地址转币进行充值。

    When a user enters the btc charge page, call the back-office query charge address. If there is no charge address, we create a user 'getnewaddress ', which belongs to the user, saves it to the database and returns it to the page, to which the user changes the currency charge.

  • 后台起一个线程或者调度任务根据区块高度扫描当前区块中交易记录,取出来和数据库中充值地址对比,如果是平台用户的充值地址交易记录,保存到区块转账记录表中(表中可设置tx_id为主键,tx_id为区块转账信息唯一标识,不会重复)。

    A line or dispatch task from the backstage scans the transaction records in the current block according to its height, removes them and compares them to the filled address in the database and, in the case of the billing address transaction records of the platform user, saves them in the block transfer log (the table can set tx_id as the main key, tx_id as the only identifier for block transfer information, and does not repeat it).

Bitcoin Core钱包如何安装与对接

How Bitcoin Core Wallet Installed and Connected

提现
  • 普通用户提交提现表单后,如果提现数量大于设置的审核数量,则需要进到管理后台人工审核,审核通过后同步给提现地址转币,并更新审核状态和修改用户资产信息。

    Once a generic user submits a cash form, if the number of cash withdrawals is greater than the number of checks set, it needs to go to the management backstage for manual clearance, which is followed by the simultaneous transfer of money to the cash withdrawal address and the updating of the audit status and modification of the user's asset information.

Bitcoin Core钱包如何安装与对接

How Bitcoin Core Wallet Installed and Connected

转账记录更新(处理区块中充值和提现的记录确认结果)
  • 添加调度任务扫描区块转账表中待处理的记录,根据确认数来决定是否进行后续处理

    Adds records to be processed in the schedule of movement-scan block transfer forms and decides on follow-up on the basis of confirmations

Bitcoin Core钱包如何安装与对接

How Bitcoin Core Wallet Installed and Connected

2.转账使用接口

转账目前有多种方式和接口,下面做详细介绍:

There are currently various modalities and interfaces for the transfer, which are described in more detail below:

  • 是使用离线签名方式的原生交易,适合冷钱包转账交易,大概步骤为先创建交易信息进行签名后,通过返回的hash值,广播出去后即可(广播也可以使用第三方服务进行广播),需要单独设置手续费,设置找零地址;

    It is a raw transaction by means of offline signatures, suitable for cold wallet transfer transactions, presumably by first signing the transaction information, then broadcasting it through the returned hash value (broadcasting can also be done using third-party services), with separate fees and zero addresses;

  • sendfrom接口,这个接口可以设置指定发送地址;

    (a) Sendfrom interface, which can set the specified send address;

  • sendmany接口,这个接口看名字也大概知道,可以批量转账;

    (a) The sendmany interface, which, by name, can be transferred in bulk;

  • sendtoaddress接口,这个接口是使用整个钱包的utxo(简单理解就是整个钱包的可用余额)进行对外转账,好处就是他是把钱包所有的余额汇集一起对外转账,比如说用户提现1btc,如果我用其他接口指定转出地址时,转出地址余额没有1btc就无法转账,但是因为这个接口是把钱包余额加起来对外转,所有可以成功转出。

    The sendtoaddress interface, which uses the utxo of the entire wallet (which is simply understood as the available balance of the entire wallet) for external transfers, has the advantage of bringing together all the balance of the wallet together for external transfers, e.g. the user cashes 1btc, which cannot be transferred without 1btc if I use the other interface to specify the address to be transferred, but because the interface combines the wallet balance to and from the outside and all can be transferred successfully.

3.用户充值btc余额归集

目前我的项目是设置的定时器每天在不同时间执行三次归集任务,因为用的sendtoaddress转账的接口,所以我每次归集的时候查询钱包余额是否超过归集阈值,超过就做归集操作。

My current project is a timer that performs three collection tasks per day at different times, and because of the interface used by the Sendtoaddress transfer, I search for wallet balances that exceed the concentration threshold at each collection and do so.

Bitcoin Core钱包如何安装与对接 

How Bitcoin Core Wallet Installed and Connected

感谢你能够认真阅读完这篇文章,希望小编分享的“Bitcoin Core钱包如何安装与对接”这篇文章对大家有帮助,同时也希望大家多多支持亿速云,关注亿速云行业资讯频道,更多相关知识等着你来学习!

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明

分享:

扫一扫在手机阅读、分享本文

上一篇:BCT币价格 下一篇:bitcoin客户端
发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
热门文章
  • 0.00003374个比特币等于多少人民币/美金

    0.00003374个比特币等于多少人民币/美金
    0.00003374比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00003374比特币等于2.2826 1222美元/16.5261124728人民币。比特币(BTC)美元(USDT)人民币(CNY)0.00003374克洛克-0/22216.5261124728比特币对人民币的最新汇率为:489807.72 CNY(1比特币=489807.72人民币)(1美元=7.24人民币)(0.00003374USDT=0.0002442776 CNY)。汇率更新于2024...
  • 134 USD toBTC Calculator -

    134                            USD                        toBTC                        Calculator -
    For the week (7 days) Date Day 134 USD to BTC Changes Changes % June...
  • 0.00006694个比特币等于多少人民币/美金

    0.00006694个比特币等于多少人民币/美金
    0.00006694比特币等于多少人民币?根据比特币对人民币的最新汇率,0.00006694比特币等于4.53424784美元/32.5436 16人民币。比特币(BTC)美元(USDT)人民币(CNY)0.000066944.53424784【比特币密码】32.82795436 16比特币对人民币的最新汇率为:490408.64 CNY(1比特币=490408.64人民币)(1美元=7.24人民币)(0.00006694USDT=0.0004846456 CNY)汇率更新时...
  • 12年怎么购买比特币?比特币投资,轻松掌控

    12年怎么购买比特币?比特币投资,轻松掌控
    12年怎么购买比特币?买卖比特币可以通过以下交易所进行购买,分别是:欧易官网平台、ZG交易所、艾戴克斯交易所、C2CX交易软件、BaseFEX交易APP、波网交易平台、安银交易所、BitMart交易软件、紫牛币交所交易APP和澳网(AOMEX)交易平台等等十大平台下载,高效安全的数字货币交易平台。How do you buy bitcoins in 12 years? Bitcoins can be purchased through ten major platforms...
  • 0.00015693个比特币等于多少人民币/美金

    0.00015693个比特币等于多少人民币/美金
    0.000 15693比特币等于多少人民币?根据比特币对人民币的最新汇率,0.000 15693比特币等于10.6 1678529美元/76.86554996人民币。比特币(BTC)【比特币价格翻倍】美元(USDT)人民币(CNY)0.000/克洛克-0/5693【数字货币矿机】10.6 167852976.8655254996比特币对人民币的最新汇率为:489,807.72 CNY(1比特币= 489,807.72人民币)(1美元=7.24人民币)(0.00015693 U...
标签列表