Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    adonnini
    @adonnini
    @ttmc Isn't this not necessarily the case if a TRANSFER transaction is used to append/update? In this case, originating and target public keys are the same, and the TRANSFER transaction is used to append new metadata
    adonnini
    @adonnini
    @ttmc is there a typical reason that causes a transaction to be "malformed" Is there a way that you know of to diagnose such a problem? Where in the js-driver code is the error caught? Thanks
    Troy McConaghy
    @ttmc
    @adonnini There are dozens of ways that a transaction could be malformed. Basically, it must conform to the BigchainDB Transaction Spec v2, and if it doesn't then it's invalid.
    https://github.com/bigchaindb/BEPs/tree/master/13
    The overall sequence for updating an asset with metadata is:
    (Initial CREATE transaction) ---> (First TRANSFER transaction with its metadata) ---> (Second TRANSFER transaction with its metadata) ---> (Third TRANSFER transaction with its metadata) ---> etc.
    and the ---> arrow always means spending/transferring output 0 to the same owner.
    so the (Third TRANSFER transaction) must spend output 0 in the (Second TRANSFER transaction).
    A common mistake is to try spending output 0 on the initial CREATE transaction again and again. That will not work. An output can only be spent once.
    adonnini
    @adonnini
    @ttmc Thanks. How does the above apply/change when a TRANSFER transaction is used to append/update? When you say "output 0" are you referring to the "amount"?
    Troy McConaghy
    @ttmc
    @adonnini "output 0" is the first (and often the only) output in a transaction.
    adonnini
    @adonnini

    @ttmc Is this the line in makeTransferTransaction you are referring to?

        const inputs = unspentOutputs.map((unspentOutput) => {
            const { tx, outputIndex } = { tx: unspentOutput.tx, outputIndex: unspentOutput.output_index }
            const fulfilledOutput = tx.outputs[outputIndex]
            const transactionLink = {
                'output_index': outputIndex,
                'transaction_id': tx.id,
            }

    I am sorry. I am really stuck here. How does this change when the TRANSFER transaction is not used to transfer but to append/update?

    Thanks

    Troy McConaghy
    @ttmc
    A TRANSFER transaction always transfers. There's no avoiding that. But you can transfer it from Joe back to Joe, so no real change of ownership happens, but the metadata in that TRANSFER transaction gets stored and conveys information about how the asset changed.
    adonnini
    @adonnini
    @ttmc thanks. Understood. But, how does the point you made about spending output change when you transfer to yourself, and the output doesn't matter?
    Troy McConaghy
    @ttmc
    @adonnini I don't understand your question
    Parvinder Thapar
    @psthapar
    @ttmc Thank you Troy. Appreciate the guidance. It makes sense. I will try it today. Following is what I plan to do. Let me know if this would work:
    Transaction transaction1 = doTransfer(createTransferID, output 0, metadata, keypairs); // Use Output 0
    Transaction transaction2 = doTransfer(createTransferID, transaction1.getOutputs.get(0), metadata, keypairs); // Use transaction1.getOutputs.get(0)
    adonnini
    @adonnini

    @ttmc when a TRANSFER transaction is used to append/update, I will be spending "output 0" every time I append/update the asset. Is that what you meant here

    "the ---> arrow always means spending/transferring output 0 to the same owner."?

    Thanks

    Parvinder Thapar
    @psthapar
    Here's the sample code in Java for doing the Transfer operation....I can not tell where is the Output being "spent"?? @adonnini @ttmc any ideas?
    public String doTransfer(String txId, MetaData metaData, KeyPair keys) throws Exception {
        try {
    
    
            //which transaction you want to fulfill?
            FulFill fulfill = new FulFill();
            fulfill.setOutputIndex(0);
            fulfill.setTransactionId(txId);
    
    
            //build and send TRANSFER transaction
            Transaction transaction = BigchainDbTransactionBuilder
                    .init()
                    .addInput(null, fulfill, (EdDSAPublicKey) keys.getPublic())
                    .addOutput("1", (EdDSAPublicKey) keys.getPublic())
                    .addAssets(txId, String.class)
                    .addMetaData(metaData)
                    .operation(Operations.TRANSFER)
                    .buildAndSign((EdDSAPublicKey) keys.getPublic(), (EdDSAPrivateKey) keys.getPrivate())
                    .sendTransaction(handleServerResponse());
    
            System.out.println("(*) TRANSFER Transaction sent.. - " + transaction.getId());
            return transaction.getId();
    
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }
    adonnini
    @adonnini
    @psthapar this is the code from the sample app published by @innoprenuer and similar to the code in read.md for the Java driver.
    The problem is that we do not know whether this code was tested and runs correctly.
    @ttmc I am not asking for support from @innoprenuer, just whether the code he posted in the sample app and in read.md was tested and works. Could we please get an answer to this question?
    Thanks
    Parvinder Thapar
    @psthapar
    OK. I seem to have it working. In the "Fulfill" construct, I use the last transaction's id. ...and inside the "Transfer" construct usting BigChainDBTransactionBuilder where it's referencing "addAsset", i used the original "Create" Transaction Id. My 3rd Transfer went smoothly and it added the new metadata (from Transfer Operation #3) to the originally created Asset....essentially mimicking the "append" behavior that @adonnini and I were trying to get.
    @adonnini Correct....I am using the sample code and was trying to make multiple "transfers" to mimic append behavior just like what you were trying to do
    adonnini
    @adonnini
    @psthapar in the code above the original trx id, txId, is used for both addAsset and for fullfill Is this what you meant?
    adonnini
    @adonnini
    @psthapar What is not clear to me how you would retain the transaction id of the last append transaction over time.
    For example, suppose the app updates/appends on day 1 twice. Assuming the application runs continuously, I can see having a construct that retains the trx id of the first append/update operation, and uses it, as I think you suggest, for the second append/update operation.
    Now suppose, instead that the app appends/updates an asset on day 1. Then on day X, it appends/updates the same asset again. In order for the app to know/use the trx id of the append/update transaction performed on day 1, it wold need to be able to retrieve it from somewhere.
    Am I missing something? Did I misunderstand how you built the append/update transaction in your code?
    Thanks
    Parvinder Thapar
    @psthapar
    @adonnini Good question. You can use the static method on the Class TransactionAPI called getTransactionsByAssetId to retrieve all the transactions. The last transaction's id is what you need to send for subsequent Transfers. All you need is Asset Id (or original createTransaction's ID) for the method getTransactionsByAssetId. Hope this helps,
    Here's the updated doTransfer Method:
    public Transaction doTransfer(String lastTxId, String createTxId, MetaData metaData, KeyPair keys) throws Exception {
    
        try {
    
    
            //which transaction you want to fulfill?
            FulFill fulfill = new FulFill();
            fulfill.setOutputIndex(0);
            fulfill.setTransactionId(lastTxId);
    
    
            //build and send TRANSFER transaction
            Transaction transaction = BigchainDbTransactionBuilder
                    .init()
                    .addInput(null, fulfill, (EdDSAPublicKey) keys.getPublic())
                    .addOutput("1", (EdDSAPublicKey) keys.getPublic())
                    .addAssets(createTxId, String.class)
                    .addMetaData(metaData)
                    .operation(Operations.TRANSFER)
                    .buildAndSign((EdDSAPublicKey) keys.getPublic(), (EdDSAPrivateKey) keys.getPrivate())
                    .sendTransaction(handleServerResponse());
    
            System.out.println("(*) TRANSFER Transaction sent.. - " + transaction.getId());
            return transaction;
    
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return null;
    }
    adonnini
    @adonnini

    @psthapar Thanks for the help. I appreciate it. To make sure I understand correctly what you are saying above:

    lastTxId = appendTransactions.get(appendTransactions.size() - 1).getId();
    where
    apAppendTransactions = appendTransactionRetrieve.getTransactionsByAssetId(originalTxId, Operations.TRANSFER).getTransactions();

    and

    createTxId = originalTxId;

    Did I understand you correctly?

    Parvinder Thapar
    @psthapar
    @adonnini Yes. Barring the syntax, your psuedo code seems right. Try it out and let me know.
    adonnini
    @adonnini
    @psthapar It seems to be working as expected. I had to make a few changes to allow for how I used the blockchain but it seems to work. Again, thanks.
    Parvinder Thapar
    @psthapar
    Great. Thanks for letting me know @adonnini . You are very welcome. Glad it worked out for you.
    Parvinder Thapar
    @psthapar
    Hi all, BigChain DB talks about "Burn" capability to essentially mimic "delete" (since an asset cannot be essentially be deleted in the world of blockchain). Is there any examples of "burning" an asset using Java libraries?
    CC: @adonnini @ttmc
    Troy McConaghy
    @ttmc
    @psthapar It's not complicated, you just transfer the asset to a public key where the associated private key is not known. The asset still exists in an unspent transaction output, but nobody can spend it.
    Parvinder Thapar
    @psthapar
    @ttmc aah....makes sense. However, even with an unspent transaction output, the asset would still be query-able and found. Wouldn't it (just wondering!?). One of my goals is to ensure that once burned, it's never found again, even in read-mode. Thoughts?
    Troy McConaghy
    @ttmc
    @psthapar The nature of most normal blockchains (like BigchainDB) is that:
    1) all the stored data is publicly readable (and auditable) forever.
    2) no stored data can be deleted or changed.
    If that's not what you want, then you don't want a blockchain.
    Parvinder Thapar
    @psthapar
    @ttmc Not what I wanted to hear but it is what it is :-) .... Thanks.
    The only strategy that I can think of to get close to what I want is:
    1) Use Private/ Permissioned Blockchain
    2) Use Business Logic Layer to manage data and use strategies to limit (or eliminate) views to burned assets such as purging assetId, public & private keys etc.
    Understandable it's not fail-proof but having some strategy is better than not having one at all. My 2 cents!
    Troy McConaghy
    @ttmc
    Yes, a private blockchain can certainly restrict read access, but that happens outside the blockchain itself.
    Parvinder Thapar
    @psthapar
    Yep. Agreed. Thanks.
    CodyMTX
    @CodyMTX
    I'm having an issue posting transactions
    is this where I would get some insight?
    Parvinder Thapar
    @psthapar
    Hi @CodyMTX what drivers are you using? js or java drivers?
    CodyMTX
    @CodyMTX
    @psthapar I am using JavaScript and also got the error with the Python drivers...leading me to believe it may be a configuration issue on my part? I have the docker installation running flawlessly, but can't seem to replicate it outside in a prod env
    Diego Sierra Fernandez
    @jdiegosierra
    Is someone using js-driver-orm?
    I'm trying to change the owner of an asset but when it reachs the append nothing happends.
    router.post('/transfer', function(req, res) {
        conn.searchAssets(req.body.assetName)
        .then(assets => {
            const did = new DID(req.body.assetPublicKey);
            did.define(req.body.modelName);
            did.models[req.body.modelName]
            .retrieve(assets[0].id)
            .then(asset => {
                console.log(asset)
                // [ OrmObject {
                //     _name: 'test',
                //     _schema: undefined,
                //     _connection:
                //      Connection {
                //        path: 'http://localhost:9984/api/v1/',
                //        headers: {},
                //        conn: [Connection] },
                //     _appId: 'global',
                //     transactionHistory: [ [Object] ],
                //     id: 'id:global:test:99040993-0fa3-4c32-9d54-f6d83a65fb1f',
                //     data: { myData: '', ownerName: 'Juan Diego' } } ]
                return asset.append({
                    toPublicKey: req.body.destPublicKey,
                    keypair: req.body.ownerKeyPair,
                    data: {
                        myData: req.body.data,
                        ownerName: req.body.ownerName
                    }
                })
            })
            .then(updatedAsset => {
                console.log("This message does not appear")
                console.log(updatedAsset);
                res.send(updatedAsset);
            })
        })
    });
    Shivank Chopra
    @ShivankChopra
    Hi everyone. For testing the tamper resistance of data stored on bigchainDB, I intentionally changed the asset and metadata stored on the bigchain mongo database to random values. But it didnt seem to affect the working of bigchain db node. Should'nt the blockchain become invalid due to changed hash value because of this?
    Vishal1010101
    @Vishal1010101
    I am having an issue in this line of code
    const alice = new BigchainDB.Ed25519Keypair(seed)
    at Object.encode (/Users/apple/Documents/big_chaindb/node_modules/base-x/index.js:29:41)
    at new Ed25519Keypair (/Users/apple/Documents/big_chaindb/node_modules/bigchaindb-driver/dist/node/Ed25519Keypair.js:28:33)

    /Users/apple/Documents/big_chaindb/node_modules/base-x/index.js:29
    if (!Buffer.isBuffer(source)) throw new TypeError('Expected Buffer')
    ^

    TypeError: Expected Buffer

    can anyone help
    Troy McConaghy
    @ttmc
    @Vishal1010101 I think something is wrong with the JS driver in npm. If you get the JS driver straight from GitHub, I think that one is working. https://github.com/bigchaindb/js-bigchaindb-driver
    Vishal1010101
    @Vishal1010101
    Thanks man @ttmc seems like there is an issue with the Ed25519Keypair.js file through npm.
    It's solved in the github commit.
    Vishal1010101
    @Vishal1010101
    querying for the metadata gives an error where as assets is working fine with the url
    @ttmc