我使用Bitcore尝试进行交易,如下例所示:
https://github.com/bitpay/bitcore-lib/blob/master/docs/examples.md(其中所说的"创建交易")。
但是,我在"脚本"中遇到了一些问题。部分,这是我的代码:
var privateKey = new bitcore.PrivateKey('the private key :P');
var address = bitcore.Address.fromString('1PP4jkxPhJVDP9cEkdbHXvXCiFuiEZTjtb');
var script = bitcore.Script.buildPublicKeyHashOut(address);
控制台告诉我这个:
但是,当我使用JSON.stringify(脚本)时,我得到了这个:
{
"chunks": [{
"opcodenum": 118
}, {
"opcodenum": 169
}, {
"buf": {
"type": "Buffer",
"data": [245, 127, 9, 190, 134, 210, 30, 178, 246, 47, 189, 61, 92, 64, 165, 177, 207, 158, 104, 156
]
},
"len": 20,
"opcodenum": 20
}, {
"opcodenum": 136
}, {
"opcodenum": 172
}],
"_network": {
"name": "live
net ","
alias ":"
mainnet ","
pubkeyhash ":0,"
privatekey ":128,"
scripthash ":5,"
xpubkey ":
76067358,
"xprivkey": 76066276,
"networkMagic": {
"type": "Buffer",
"data": [249, 190, 180, 217]
},
"port": 8333,
"dnsSeeds": ["seed.bitcoin.sipa.be", "dnsseed.bluematt.me", "dns
seed.bitcoin.dashjr.org ","
seed.bitcoinstats.com ","
seed.bitnodes.io ","
bitseed.xf2
.org "]
}
}
这些都不像"脚本"用于在Bitcore' github lib上进行交易的变量。
答案 0 :(得分:0)
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<body onLoad="load()" style="margin-top: 10px;">
<div class="container">
<div style="text-align: center; line-height: 2px;">
<h4>Image browser</h4>
<p>Coded by someone</p>
</div><br /><br />
<div id="pageCarousel" class="carousel slide" data-ride="carousel" data-interval="false">
<div class="carousel-inner" role="listbox" id="carousel-inner">
<!-- GONNA BE FILLED BY THE SCRIPT -->
</div>
<a class="carousel-control-prev" href="#pageCarousel" role="button" data-slide="prev">
<span class="carousel-control-prev-icon bg-primary" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#pageCarousel" role="button" data-slide="next">
<span class="carousel-control-next-icon bg-primary" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</html>
也许这会有所帮助!
您需要使用相同的私钥创建地址,并且该地址应该是WIP密钥。否则它将无法正常工作。