Giter Site home page Giter Site logo

zencashjs's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zencashjs's Issues

HDE Scavenger Hunt #1 - zencashjs - 1122211318

Scope of work:

The idea of this task is to learn and earn at the same time!

If you want to learn something and gain 0.02229 ZEN in the process + a bounty of $50 paid in ZEN, the multisignature address used in the zencashjs readme example currently holds a small balance (probably left over from someone testing): https://github.com/HorizenOfficial/zencashjs#example-usage-multi-sig

Your task is to transfer ZEN from the multisignature address to your own address (you will have to prove address ownership by signing a message)


I've successfully completed this one - the zen has been withdrawn to znV5ouD7gGq1ArV8EZDcySn1gtmiYNQer7y and I've signed with the taskid which gives IGmVw8CCAy8YHgGLudpn4fMD9KrtHJID+shEKjCH2SXrNi0UOefpAPEux2bGzHtgJshBdb38fAbABnLpWn9bXto=

To verify run:

zen-cli verifymessage "znV5ouD7gGq1ArV8EZDcySn1gtmiYNQer7y" "IGmVw8CCAy8YHgGLudpn4fMD9KrtHJID+shEKjCH2SXrNi0UOefpAPEux2bGzHtgJshBdb38fAbABnLpWn9bXto=" "1122211318"

Thanks!

I love project

Excellent project and a good job deserving of appreciation and respect

Update list of nodejs versions in CI

We currently run the CI pipeline on these versions of nodejs which translate to node 10, 12 and 17:

zencashjs/.travis.yml

Lines 10 to 12 in af20824

- lts/dubnium
- lts/erbium
- node

The list should be updated to include all currently supported versions of nodejs, and for node 17 a workaround is needed due to breaking changes, see #65 (comment).

TypeError: unsupported input type for privateKey

Getting this error when using zencashjs.zaddress.zSecretKeyToPayingKey(secretKey).

The error is coming from the libsodium-wrappers-sumo dependency.

I'm using the example secretKey and it's still not working and I"ve no idea why. I've tested the usage in fresh projects as well as the npm browser tester and it works properly.

the code is no different from the example besides hardcoding the example secret key.

`
const secretKey = '0c10a61a669bc4a51000c4c74ff58c151912889891089f7bae5e4994a73af7a8';

    const spendingKey = zencashjs.zaddress.zSecretKeyToSpendingKey(secretKey);
    
    const payingKey = zencashjs.zaddress.zSecretKeyToPayingKey(secretKey);
    
    const transmissionKey = zencashjs.zaddress.zSecretKeyToTransmissionKey(secretKey);
    
    const zAddress = zencashjs.zaddress.mkZAddress(payingKey, transmissionKey);`

How to convert deserialized script into address

About outs when eg using zencashjs.transaction.deserializeTx method. I can only get satoshis and script, I want to know how to get the real address through script

{
version: 1,
locktime: 0,
ins: [{
output: [Object],
script: '',
sequence: 'ffffffff',
prevScriptPubKey: ''
}],
outs: [{
satoshis: 100000,
script: '76a914da46f44467949ac9321b16402c32bbeede5e3e5f88ac200206260143838b5ff52dc2eb7b4b8099d4e4c99dc3ef19794289a2cd4c10070000b4'
}]
}

example:How to get the corresponding address through 76a914da46f44467949ac9321b16402c32bbeede5e3e5f88ac200206260143838b5ff52dc2eb7b4b8099d4e4c99dc3ef19794289a2cd4c10070000b4

pubKeyToAddr only outputs correct address when compressed pubkey is used

At least the documentation needs to be updated.

$ zen-cli getnewaddress
zno4a6ahSfsXhvbtqxa8QSTNVRmbN8TmcoV
$ zen-cli dumpprivkey zno4a6ahSfsXhvbtqxa8QSTNVRmbN8TmcoV
KxFWSSpyJa3tf2ZLCirHCTNht4YwsC5fQtHTpfLh3JuNYW3prry3
$ zen-cli validateaddress zno4a6ahSfsXhvbtqxa8QSTNVRmbN8TmcoV
{
  "isvalid": true,
  "address": "zno4a6ahSfsXhvbtqxa8QSTNVRmbN8TmcoV",
  "scriptPubKey": "76a914f111bea65d77e5b7f25e560282b6f63642fef6ce88ac20573cda020cea4da8c2125b1236a715b0b6888c07ceb2549eb48fb1390000000003ab7d05b4",
  "ismine": true,
  "iswatchonly": false,
  "isscript": false,
  "pubkey": "028450b9273f2a3d85145f153b988c389f7b7803b03431f847ec850dc09bb6db5d",
  "iscompressed": true,
  "account": ""
}
var zencashjs = require('zencashjs')

var privWIF = 'KxFWSSpyJa3tf2ZLCirHCTNht4YwsC5fQtHTpfLh3JuNYW3prry3'

var privFromWIF = zencashjs.address.WIFToPrivKey(privWIF)

var pubKey = zencashjs.address.privKeyToPubKey(privFromWIF)
// 048450b9273f2a3d85145f153b988c389f7b7803b03431f847ec850dc09bb6db5d375623658ec1fddd509c357114e3139afba4058e96556f0fc2a931e72f3d8bd4

var pubKeyCompressed = zencashjs.address.privKeyToPubKey(privFromWIF, true)
// 028450b9273f2a3d85145f153b988c389f7b7803b03431f847ec850dc09bb6db5d

var zAddr = zencashjs.address.pubKeyToAddr(pubKey)
// zng9X9Y8J9VkFNbyXQaZcN15dKxtKBcbRvn

var zAddrCompressed = zencashjs.address.pubKeyToAddr(pubKeyCompressed)
// zno4a6ahSfsXhvbtqxa8QSTNVRmbN8TmcoV

Err: Code:-25

I don't know why this problem occurs.
Is it because of the lack of fee?If yes, I did not see where to add the fee in the tutorial.

                const bip115BlockHeight = 142091
                const bip115BlockHash = '00000001cf4e27ce1dd8028408ed0a48edd445ba388170c9468ba0d42fff3052'
                let transaction = zencashjs.transaction.createRawTx(
                    utxos,
                    [{ address: data.toAddr, satoshis: parseInt(data.sum) }],
                    bip115BlockHeight,
                    bip115BlockHash
                )
                let prv = this.privateKey(phrase)
                for (let i = 0; i < transaction.ins.length; i += 1) {
                    transaction = zencashjs.transaction.signTx(transaction, i, prv, true)
                }
                let tx= zencashjs.transaction.serializeTx(transaction)

hex
01000000018796da41cc54e918e62bb660c01e992492e3bfa4a56317961f5483e022d02165010000006a47304402200def4b7a9dab41b10de8b9ec1736edd729a4c7994fcf48a7d963c87050e148e0022022012750838cbac3552b71c736072e16a642cc75bbbcb0b9fddf79f78945911c012102b51117ca8b6b0de630f42763a2be1b1ce7fe322ae750ee8d4eaaaf65ed7aeb5affffffff0140420f00000000003f76a9147bfb6527e7e3f95cf3b009068483176b86de130d88ac205230ff2fd4a08b46c9708138ba45d4ed480aed088402d81dce274ecf01000000030b2b02b400000000

Script failed an OP_EQUALVERIFY operation

Hi!

We are using this lib in our wallet and from 13 Sep 2018 ~10am UTC we are getting this error on all transactions:
16: mandatory-script-verify-flag-failed (Script failed an OP_EQUALVERIFY operation). Code:-26

What's the cause of this and how could this be fixed?

UPD: actual code

// Create tx
let transaction = core.transaction.createRawTx(
  data.inputs.map(item => ({
    txid: item.txId,
    vout: item.outputIndex,
    scriptPubKey: item.script,
  })),
  data.outputs.map(item => ({
    address: item.address,
    satoshis: item.value,
  })),
  blockHeight,
  blockHash,
);

// Get private key hex
let pvKey = null;
try {
  pvKey = core.address.WIFToPrivKey(privateKey);
} catch (ignore) {
  pvKey = core.address.mkPrivKey(privateKey);
}

// Sign tx
for (let i = 0; i < transaction.ins.length; i += 1) {
  transaction = core.transaction.signTx(transaction, i, pvKey);
}

// Publish serialized tx
const signedRawTx = core.transaction.serializeTx(transaction);
const { data: result } = await axios.post(API_BROADCAST, { rawtx: signedRawTx });

RpcError: 16: mandatory-script-verify-flag-failed (Script failed an OP_EQUALVERIFY operation)

Hi!
When I have 1 input I am signing it with my private key and send it successfuly.
But now I have 3 inputs, balance 0.29, 0.29, 0.009 and want to send 0.5.
When I am trying to send signed txs with 3 different inputs I have RPC error:
RpcError: 16: mandatory-script-verify-flag-failed (Script failed an OP_EQUALVERIFY operation)
Summarizing; I have 1 private key and derive it using input.type, input.index.

Could you please explain what I am missing ?

My sign code is:

        let j = 0;
        for (const input of inputs) {
            //getting derived private key for input addresses
            const privKey = this.getPrivKeyForAddress(opts.masterPrivateKey, input.type, input.index);
            zenTX = zencashjs.transaction.signTx(zenTX, j, privKey, true);
            j++;
        }

My signed tx hash is:
0100000003fb1d96993073ba3c3d2234e44cf28335826d03f8a9ea2fb663bdb269edad1f9a000000006a473044022069ce076f72baa9faa11a3af0e3899e9e20097e7476cca406e53fa9a697045a60022041911f3b49387cf01b66e4d26ce18144c9943f53290552a0da06d6d470134d62012103d5ccd3be1eca7dbb98beac5509d5c51a119ba2f688ae01c366127304565fa628ffffffff1968531b9008f99ab9c9d1d44d84b3434e067e12e94ea56179d9aefc12ede754000000006a47304402205e4debe82d12bc4a4cc19b434f259b7f8f46b4c370afb4eae02a57fbfa5b85ca02205a6a822b5796bf429a2a7255e75740b7da4ee74ab2fb1b4fae31a1ea3f98e67d012102ffa20e7e566d8f9be6377a6e93baf5437c3f2a3d3217d8003c61b89c69078ae8fffffffffef681a4a25e3f219625b214d404c311075a73cf46193ce0c22735c77b70f0d0000000006a47304402206490fac8cf548451bc3e577158c6a96a948ac9d3294aa710ba47e8649d806e92022064b1f96e4db24175d39641686aaf42afeee8517f04b09484df5688147cfad9c1012102c7ea07bcaaa12e2f50cce34e9ab2c538c23cb334e850b5df0dea2882dfe39d43ffffffff0283886203000000003f76a91458124d01c5102cc3f14956a1a5ec137e12c24a5d88ac204de424e2f383062ed41f28bd1221d9ea22aa42ac79e7e5db922464000000000003616f12b48d1b3a00000000003f76a914028d839813eeb07719946125786128009a10189b88ac204de424e2f383062ed41f28bd1221d9ea22aa42ac79e7e5db922464000000000003616f12b400000000

Configuration for ZENCash Coin

module.exports = {
mainnet: {
messagePrefix: 'ZENCash main net',
bip32: {
public: '0488b21e',
private: '0488ade4'
},
pubKeyHash: '2089',
scriptHash: '2096',
zcPaymentAddressHash: '169a', // Private z-address
zcSpendingKeyHash: 'ab36', // Spending key
wif: '80'
},
testnet: {
wif: 'ef',
pubKeyHash: '2098',
scriptHash: '2092',
zcPaymentAddressHash: '16b6',
zcSpendingKeyHash: 'ac08'
}
};

What's the role of "bip32", "pubKeyHash"," scriptHash"," zcPaymentAddressHash"," zcSpendingKeyHash"," wif" ?

Where is the configuration?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.