I'm using Bitcore to try and make a transaction like in this example:
https://github.com/bitpay/bitcore-lib/blob/master/docs/examples.md (Where it says "Create Transaction").
However, I'm having some issues with the "script" part, this is my code:
var privateKey = new bitcore.PrivateKey('the private key :P');
var address = bitcore.Address.fromString('1PP4jkxPhJVDP9cEkdbHXvXCiFuiEZTjtb');
var script = bitcore.Script.buildPublicKeyHashOut(address);
The console shows me this:
However, when I use JSON.stringify(script), I get this:
{
"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 "]
}
}
None of those look like the "script" variable that's used to make a transaction on Bitcore's github lib.
May be this will help!
You need to create the address with the same private key, and it should be a WIP key. Otherwise it will not work.