Coder Social home page Coder Social logo

datapay's People

Contributors

breavyn avatar monkeylord avatar mpapec avatar torusjkl avatar unwriter avatar

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  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

datapay's Issues

How to start datapay app ?

i'm not able to start datapay app and also there is no instruction given to run the script.
please specify which setting needed ?

Enhancement to documentation

Hi I am new to using this library. Managed to figure things out from youtube tutorials, but wanted to add what I thought was missing from the current documentation:

  • For beginners: linking resources on how to obtain a private key and add funds if they have never used datapay or moneybutton before.
  • For developers: more examples of the send callback function so devs can see what type of data they are receiving

Small Bug in a code example in README File

https://github.com/unwriter/datapay/blob/master/README.md#a-sending-from-data-and-pay

The code example under A. Sending from data and pay, currently is this:

const tx = {
  safe: true,
  data: ["0x6d02", "hello world"])
  pay: { key: "5JZ4RXH4MoXpaUQMcJHo8DxhZtkf5U5VnYd9zZH8BRKZuAbxZEw" }
}
datapay.send(tx, function(err, res) {
  console.log(res)
})

It's missing some commas and unnecessary parenthesis.

It should be this:

const tx = {
  safe: true,
  data: ["0x6d02", "hello world"],
  pay: { key: "5JZ4RXH4MoXpaUQMcJHo8DxhZtkf5U5VnYd9zZH8BRKZuAbxZEw" }
}
datapay.send(tx, function(err, res) {
  console.log(res)
})

Smarter UTXO handling

By default datapay uses all UTXOs when building a TX. When using datapay to send multiple large data transactions, users will very quickly hit either the 25 chained mempool tx limit or the 100k mempool bytes limit.

I have recently solved this problem in libitx/preserve-cli@e6598ec4 and the approach I used there comes in two parts:

  1. UTXOs are sorted so that confirmed TX are listed first (by default the insight api lists the UTXO in an unpredictable order, but often unconfirmed outputs come first).
    https://github.com/libitx/preserve-cli/blob/master/lib/bitindex.js#L18-L25
  2. Building the tx needs to be arranged in such a way that all the outputs are defined first, and then iterate over the sorted UTXO and one-by-one keep adding an input and re-estimate the fee until the sum of the inputs exceeds the sum of outputs plus fee.
    https://github.com/libitx/preserve-cli/blob/master/lib/commands/deploy.js#L146-L152

Datapay already has a filter option but unfortunately the bsv.Transaction.UnspentOutput objects from getUnspentUtxos don't provide very useful properties with which to filter by. For example, it's not possible to filter by confirmations.

I think bitcore-explorers will need to be replaced with a built-in bitindex client so the raw response from bitindex (which does include a confirmations property) can be sorted/filtered. This isn't a terribly hard thing to do, but it's going to break existing APIs (datapay.connect()) so I didn't just went to fire over a PR.

Opening this issue to discuss options.

Problem with rpc

  1. If I use default pay.rpc for datapay.send, the rpc fails with error
    1-default_rpc
    PayloadTooLargeError: request entity too large at readStream (/home/bchsv/prod-2/node_modules/raw-body/index.js:155:17) at getRawBody (/home/bchsv/prod-2/node_modules/raw-body/index.js:108:12) at read (/home/bchsv/prod-2/node_modules/body-parser/lib/read.js:77:3) at jsonParser (/home/bchsv/prod-2/node_modules/body-parser/lib/types/json.js:135:5) at Layer.handle [as handle_request] (/home/bchsv/prod-2/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/home/bchsv/prod-2/node_modules/express/lib/router/index.js:317:13) at /home/bchsv/prod-2/node_modules/express/lib/router/index.js:284:7 at Function.process_params (/home/bchsv/prod-2/node_modules/express/lib/router/index.js:335:12) at next (/home/bchsv/prod-2/node_modules/express/lib/router/index.js:275:10) at expressInit (/home/bchsv/prod-2/node_modules/express/lib/middleware/init.js:40:5)

  2. if I use my own pay.rpc for datapay.send
    2-my_rpc
    datapay fails with error returning only NodeError

  3. If I use default pay.rpc for datapay.build there is no error from rpc
    screenshot 2019-02-01 at 14 21 01
    but then I need to http send builded tx via my node rpc, and tx gets through successfully
    a80a0a2afc0ba2f76914b26ed98fd9db3e0aedbe3c399c6e3e157f126315332e

my node is available under bitcoinsv.si

if one would like to try directly with node rpc, I can give user & pass.

Possibility to broadcast to n number of networks via .send(config)

The datapay docs detail an example of broadcasting a transaction to the network, however, they explicitly define bitindex and implicitly suggest memo.cash.

Can users of this library get more control over how they broadcast?
As a merchant we may want to broadcast to as many networks/miners as we possibly can, as quick as we can.

What are our options here?

Thanks.

Error 66: insufficient priority

Hi,

I am trying to send image in hash format with dataPay.send example but receive an error:

code: 1,
message: 'the transaction was rejected by network rules.\n' +
'\n' +
'66: insufficient priority\n' +

I create transaction with:

const tx = this.createTx(message);
dataPay.send(tx, (err: object, res: string) => {
       if (err) {
            return reject(err);
       }
       return resolve(res);
});
private createTx(message: Buffer): TxTransaction {
        const bufferInHex = message.toString('hex');
        return {
            safe: true,
            data: [bufferInHex],
            pay: {
                key: this.privateKey,
                rpc: this.rpcApi, // 600
                fee: this.rpcFee, // https://api.mattercloud.net
            },
        };
    }

Any hint?

Thank you.

How to host a website on Bitcoin SV blockchain?

Is there any way to host a website on bitcoin SV blockchain? I saw somewhere, that there is a method to host a simple html page in bitcoin SV transaction.
How i can do that withoud 3rd party service. I mean i want to create transaction with html file in it.

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.