- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
有人可以解释一下我如何使用 bitcoinjs 发送比特币交易吗???我已经使用 bitcoinjs 设置了两个钱包。
我想从这里发送 100000 聪:1G4iprWu7Q8tNbQLA8UBM2GearcnzwFrxM
到这里:1HsrKvboax8J3X1sgsRdWybEwnUNWsDw4Y
如果需要,这里是 1G4iprWu7Q8tNbQLA8UBM2GearcnzwFrxM 的最后一笔交易
我使用的代码来自 bitcoinjs.org 网站:
var tx = new bitcoin.TransactionBuilder()
// Add the input (who is paying):
// [previous transaction hash, index of the output to use]
var txId = 'aa94ab02c182214f090e99a0d57021caffd0f195a81c24602b1028b130b63e31'
tx.addInput(txId, 0)
// Add the output (who to pay to):
// [payee's address, amount in satoshis]
tx.addOutput("1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK", 15000)
// Initialize a private key using WIF
var privateKeyWIF = 'L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy'
var keyPair = bitcoin.ECPair.fromWIF(privateKeyWIF)
// Sign the first input with the new key
tx.sign(0, keyPair)
// Print transaction serialized as hex
console.log(tx.build().toHex())
// => 0100000001313eb630b128102b60241ca895f1d0ffca21 ...
// You could now push the transaction onto the Bitcoin network manually
// (see https://blockchain.info/pushtx)
现在我假设 var txId
是最后一笔交易的交易 ID here
`tx.addInput`` 是我放置费用的地方吗?如果是这样,100 够吗?
tx.addOutput
是 obvs,所以我同意!
var privateKeyWIF*
我把发送地址的私钥放在哪里?
不知道 var keyPair
和 tx.sign
是做什么的!
任何可以帮助告诉我细节应该去哪里的人将不胜感激!对于此示例,假设我的发件人地址私钥是 5Kb8kLf9zgWQnogidDA76MzPL6TsZZY36hWXMssSzNydYXYB9KF。
干杯
最佳答案
比特币交易通常将之前的交易输出作为新的交易输入。
首先,您需要查看之前的交易。如你所见here或者在上面的代码片段中 txId 是:4303caa91ca5a2236396af3bfae26b70a223a2bcee2fe8d23a7b24626c3c4bd2
{
"hash":"4303caa91ca5a2236396af3bfae26b70a223a2bcee2fe8d23a7b24626c3c4bd2",
"ver":1,
"vin_sz":1,
"vout_sz":2,
"size":225,
"weight":900,
"fee":18713,
"relayed_by":"0.0.0.0",
"lock_time":448506,
"tx_index":7399058499716239,
"double_spend":false,
"time":1484590465,
"block_index":448507,
"block_height":448507,
"inputs":[
{
"sequence":4294967294,
"witness":"",
"script":"47304402204fdab6f26efa32f49c79d8c91b5d42ea39760cff5afc34351f8595453bd3c9d102201ff8e25e4ababe3c3515617e90f97516cda50061ad0c02f215e4a008d580ede4012102e801e52ff6e7d1ad0bb46ef6732d8fcfae1e122a47ea5690e084b9fa4a73d106",
"index":0,
"prev_out":{
"spent":true,
"script":"76a914d7819c081b247a146922b8f90f89181b02a3c66f88ac",
"spending_outpoints":[
{
"tx_index":7399058499716239,
"n":0
}
],
"tx_index":356328836300976,
"value":469871307,
"addr":"1LeVYfpp1LQQUBqsmruVW6cMbYrZtmunPr",
"n":1,
"type":0
}
}
],
"out":[
{
"type":0,
"spent":true,
"value":469352594,
"spending_outpoints":[
{
"tx_index":5608049158171792,
"n":0
}
],
"n":0,
"tx_index":7399058499716239,
"script":"76a9147adfb2779ee7710b0dffeff8fb77c82867ed43e588ac",
"addr":"1CChR9sShAc61MNLhMoLzy87w5DwP6jRvv"
},
{
"type":0,
"spent":true,
"value":500000,
"spending_outpoints":[
{
"tx_index":8253272257190039,
"n":0
}
],
"n":1,
"tx_index":7399058499716239,
"script":"76a914a53e0c670a2836baef1ea93de125f1fdd77370dd88ac",
"addr":"1G4iprWu7Q8tNbQLA8UBM2GearcnzwFrxM"
}
]
}
您的地址 1G4iprWu7Q8tNbQLA8UBM2GearcnzwFrxM
显示为第二个输出(索引 1
)。
并且这个地址的总量是500000聪
。
那么,让我们创建我们的交易
var txb = new bitcoin.TransactionBuilder()
txb.addInput('4303caa91ca5a2236396af3bfae26b70a223a2bcee2fe8d23a7b24626c3c4bd2', 1)
现在我们将发送 100000 聪
txb.addOutput('1cMh228HTCiwS8ZsaakH8A8wze1JR5ZsP', 100000)
我们需要将零钱发送到您拥有的某个地址
txb.addOutput('1cMh228HTCiwS8ZsaakH8A8wze1JR5ZsP', 398130)
剩下的就是矿工费了。您可以使用 online services估算理想的费用。
(in)500000 Satoshis - (out)100000 - (out)398130 = (fee)1870
现在我们需要签署交易以确认您拥有输入的地址
var yourAddressPrivateKeyWIF = 'L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy'
var yourAddresskeyPair = bitcoin.ECPair.fromWIF(yourAddressPrivateKeyWIF)
txb.sign(0, yourAddresskeyPair)
如果您运行 yourAddresskeyPair.getAdress()
,输出应该是您的地址 1G4iprWu7Q8tNbQLA8UBM2GearcnzwFrxM
现在您可以将交易发送到网络。获取十六进制格式的原始交易:
txb.build().toHex()
在此处粘贴结果 https://blockchain.info/pushtx或在此处查看其他解决方案:https://github.com/bitcoinjs/bitcoinjs-lib/issues/839
关于javascript - 使用 bitcoinjs 发送比特币交易,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41686334/
我正在使用 voip 推送通知制作 ios 应用程序。 我想从 Node js 发送 voip 推送通知,但不是很好。 我阅读了本教程 CallKit iOS Swift Tutorial for V
我编写了一个服务器,当浏览器尝试连接到某些站点时,它会检查黑名单并发回 404,但是当我调用 send() 时没有错误,但消息不会出现在网络上浏览器,除非我关闭连接? 有什么建议吗? 接受来自浏览器的
#include int main() { char c = getchar(); //EOF (ctrl + d ) while( ( c = getchar() ) != '?'
我正在尝试使用MailMessage对象通过PowerShell发送电子邮件。该脚本使用Import-CSV来使用文件,然后在电子邮件正文中使用ConvertTo-HTML。由于我要发送的电子邮件客户
我需要创建一个脚本,每 30 秒对网络流量进行一次采样并存储发送/接收的字节。该数据随后用于绘制图形。我编写了一个在 Windows 2012 上完美运行的程序,但我意识到某些 cmdlet 在以前的
我正在运行“autoit3.chm”文件。当它运行时,我想发送一个向下键箭头,但它不起作用: $file = FileGetShortName("C:\Users\PHSD100-SIC\Deskto
当我使用网络浏览器测试我的程序时,我可以很好地写入套接字/FD,所以我决定循环它并在连接中途切断连接,我发现了一个问题。 send() 能够在套接字不可用时关闭整个程序。我认为问题在于该程序陷入了第
我正在运行“autoit3.chm”文件。当它运行时,我想发送一个向下键箭头,但它不起作用: $file = FileGetShortName("C:\Users\PHSD100-SIC\Deskto
所以我试图向自己发送数据并接收数据然后打印它,现在我已经测试了一段时间,我注意到它没有发送任何东西,事实上,也许它是,但我没有正确接收它,我需要这方面的帮助。 这就是我用来发送数据的
问题:开发人员创建自己的序列化格式有多常见?具体来说,我使用 java 本质上将对象作为一个巨大的字符串发送,并用标记来分隔变量。 我的逻辑:我选择这个是因为它几乎消除了语言依赖性(忽略java的修改
我必须在 Linux 上编写一个应用程序,该应用程序需要与具有自定义以太网类型的设备进行通信。甚至在如何编写这样的应用程序中也有很多解决方案。一个缺点是需要 root 访问权限(AFAIK)。之后释放
我有一个包含三个单选按钮选项的表单。我需要将表单数据提交到另一个文件,但由于某种原因,发送的数据包含所选单选按钮的值“on”,而不是 value 属性的值。 我尝试通过 post() 函数手动操作和发
基本上我想实现这样的目标: Process 1 Thread 1 Receive X from process 2 Thread 2 Receive Y from proces
我目前正在 Google App Engine 上开发一个系统,对它还很陌生,我正在使用 Java 平台进行开发。我在 servlet 之间发送 session 对象时遇到问题。我已经在 appeng
当我尝试将“this”(触发的元素)作为参数发送给函数时,函数收到“Object[Document build.php]”作为参数,而不是触发的元素。请让我知道我的错误: function set(a
我正在寻找让我的应用响应联系人 > 发送的魔法咒语。我希望能够接收联系人的 URI 以便检索联系人。谁有 list 过滤器/代码 fragment 吗? 最佳答案 我没有睾丸,但您可以尝试基于 ACT
关于我心爱的套接字的另一个问题。我先解释一下我的情况。之后我会告诉你是什么困扰着我。 我有一个客户端和一个服务器。这两个应用程序都是用 C++ 编写的,实现了 winsock2。连接通过 TCP 和
我看到了这篇文章 http://www.eskimo.com/~scs/cclass/int/sx5.html 但这部分让我感到困惑:如果我们已经使用 send_array 或 send_array_
我对这行代码有疑问。我必须将一个数据包带到一个端口并重新发送到接口(interface)(例如:eth0)。我的程序成功地从端口获取数据包,但是当我重新发送(使用 send())到接口(interfa
我正在尝试编写一个 X11 输入驱动程序,它可以使用我的 Android 手机上的触摸屏来移动和单击鼠标。我可以正常移动鼠标,但我无法让应用程序正确识别点击。我当前的代码位于 https://gist
我是一名优秀的程序员,十分优秀!