繁体   English   中英

Bitcore创建事务脚本变量丢失

[英]Bitcore Creating a Transaction script variable is missing

我正在使用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(script)时,我得到了:

{
    "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库上进行事务的“ script”变量一样。

var privateKey = new bitcore.PrivateKey('the private key :P');
var address = privateKey.toWIP().toAddress();
var script = bitcore.Script.buildPublicKeyHashOut(address);

可能会有所帮助!

您需要使用相同的私钥创建地址,并且该地址应该是WIP密钥。 否则它将无法正常工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM