npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@aidpproject/aidpcoin-sign-transaction

v0.2.15

Published

Signs a Aidpcoin transaction

Downloads

20

Readme

aidpcoin-sign-transaction

Signs a Aidpcoin transaction

The sole purpose of this project is to enable us to "Sign AIDP or asset transfer transactions in pure JavaScript"

Working proof of concept.

We are able to sign Aidpcoin asset transfers using bitcoinjs-lib version 5.2 with a patched Transaction Builder.

How to use

The sign method has four arguments

  1. The network "string", can be "aidp" | "aidp-test" | "evr" | "evr-test",
  2. The raw transaction (in hex)
  3. An array of UTXO objects to use
  4. Private keys. An object with "address" as key and "WIF" as value

returns a signed transaction (hex), after that it is up to you to publish it on the network

import Signer from "@aidpproject/aidpcoin-sign-transaction";

const raw =
  "0200000002fe6cfe20184b592849231eea8167e3de073b6ec1b8218c2ef36838a4e07dd11c0200000000ffffffff28c32b825b14251708ea39c0ac706bd3d933778d7838d01b678b045a48e219950000000000ffffffff0200000000000000003a76a91416014dfb02a07417cbf8c0366ee5ae0a29d5878f88acc01e72766e74114652454e2f59554c45544944453230323100e1f5050000000075000e2707000000001976a914c6a0e8557c7567a4d9cc84574c34fbb62ece3c9688ac00000000";
const UTXOs = [
  {
    address: "RTPSdYw3iB93L6Hb9xWd1ixVxPYu1QePdi",
    assetName: "AIDP",
    txid: "1cd17de0a43868f32e8c21b8c16e3b07dee36781ea1e234928594b1820fe6cfe",
    outputIndex: 2,
    script: "76a914c6a0e8557c7567a4d9cc84574c34fbb62ece3c9688ac",
    satoshis: 122000000,
    height: 2670673,
  },
  {
    address: "RSuQSgXXr1z4gKommSqhHLffiNxnSE3Bwn",
    assetName: "FREN/YULETIDE2021",
    txid: "9519e2485a048b671bd038788d7733d9d36b70acc039ea081725145b822bc328",
    outputIndex: 0,
    script:
      "76a914c1536f46fa2fa04be210406529be283c1c85e4ce88acc01e72766e74114652454e2f59554c45544944453230323100e1f5050000000075",
    satoshis: 100000000,
    height: 2670669,
  },
];
const privateKeys = {
  RTPSdYw3iB93L6Hb9xWd1ixVxPYu1QePdi:
    "L2GD7txjmdKSTy7mBq2FowZusjdWP679ttWSRfj4eLBu2usTWMV9",
  RSuQSgXXr1z4gKommSqhHLffiNxnSE3Bwn:
    "Kxj2xMvLbcXeGzuSrZLtpnZWzXnTXnhtuCQRQhKLjN7bSQXuakyh",
};
const signed = Signer.sign("aidp", raw, UTXOs, privateKeys);
console.log(signed);

What we need

We need code that can take the UNSIGNED transaction, and sign it using the private keys. This transaction transfers one FREN/CIVILAZATION asset/token and pays fees in AIDP.

decoded UNSIGNED transaction

decoded SIGNED transaction

Private keys

Important stuff learned

  • Signing a transaction means, sign the inputs to the transaction and sign the whole transaction.

  • To sign a transaction, inputs and outputs are not enough, we need the UTXOs used (to get each utxo.script)

  • bitcoinjs-lib cant sign an unsigned transaction from Aidpcoin out of the box because of this line in transaction_builder.js

    const prevOutScript = payments.p2pkh({ pubkey: ourPubKey }).output;

    That is, transaction_builder assumes that the previous outputscript was "just" our pub key/address, that is not true in the case of Aidpcoin asset transfer transactions.

Stuff to look at

https://github.com/bitpay/bitcore-lib/blob/master/lib/script/script.js