How TO Use rippled as private blockchain





  • Hi, I want to start rippled as private blockchain but I have some error in the flow.
    I took inspiration from this thread "https://forum.ripple.com/viewtopic.php?f=2&t=16207", and at this moment I installed the "rippled" server only on one machine running the serve in standalone mode.

    You can see below the step I follow:


    1) I modify the rippled.cfg as below:


    [server]
    port_rpc_admin_local
    port_peer
    port_ws_admin_local
    port_ws_public

    [port_rpc_admin_local]
    port = 5005
    ip = 127.0.0.1
    admin = 127.0.0.1
    protocol = http

    [port_peer]
    port = 51235
    ip = 0.0.0.0
    protocol = peer

    [port_ws_admin_local]
    port = 6006
    ip = 127.0.0.1
    admin = 127.0.0.1
    protocol = ws

    [port_ws_public]
    port = 5006
    ip = 0.0.0.0
    protocol=ws

    -----------------------------------------------------------------------------

    [node_size]
    medium

    [node_db]
    type=RocksDB
    path=/var/lib/rippled/db/rocksdb
    open_files=2000
    filter_bits=12
    cache_mb=256
    file_size_mb=8
    file_size_mult=2
    online_delete=2000
    advisory_delete=0

    [database_path]
    /var/lib/rippled/db

    [debug_logfile]
    /var/log/rippled/debug.log

    [sntp_servers]
    time.windows.com
    time.apple.com
    time.nist.gov
    pool.ntp.org

    [ips]
    r.ripple.com 51235
    #127.0.0.1

    [validation_seed]
    sxxxxxxxxxxxxxxxxxxxxxxxxxxx #<-- this is a validation seed that I have generated

    [validators_file]
    validators.txt

    # Public keys of the validators that this rippled instance trusts.
    [validators_file]
    n949f75evCHwgyP4fPVgaHqNHxUVN15PsJEZ3B3HnXPcPjcZAoy7 RL1
    n9MD5h24qrQqiyBC8aeqqCWvpiBiYQ3jxSr91uiDvmrkyHRdYLUj RL2
    n9L81uNCaPgtUJfaHh89gmdvXKAmSt5Gdsw2g1iPWaPkAHW5Nm4C RL3
    n9KiYM9CgngLvtRCQHZwgC2gjpdaZcCcbt3VboxiNFcKuwFVujzS RL4
    n9LdgEtkmGB9E2h3K4Vp7iGUaKuq23Zr32ehxiU8FWY7xoxbWTSA RL5
    n9JYcWMVE3RZxu99idsyqhLh9FG4u2GYtoHGSCu6mqMPAfztYoFP #<-- this is a validator that I have generated

    # The number of validators rippled needs to accept a consensus.
    # Don't change this unless you know what you're doing.
    [validation_quorum]
    3

    [rpc_startup]
    { "command": "log_level", "severity": "warning" }

    [ssl_verify]
    1

    I know that this configuration is not correct, but I don't know as I need to modify in order to have a private blockchain.



    2) I started the server using this command:
    sudo /opt/ripple/bin/rippled -a --load --conf=rippled.cfg



    3) I'm able to run "generateAddress" script:



    'use strict';
    const RippleAPI = require('ripple-lib').RippleAPI;

    const api = new RippleAPI({
    server: 'ws://127.0.0.1:5006'
    });
    api.connect().then(() => {
    console.log('generate address');
    return api.generateAddress();

    }).then(info => {
    console.log(info);
    console.log('getAccountInfo done');

    }).then(() => {
    return api.disconnect();
    }).then(() => {
    console.log('done and disconnected.');
    }).catch(console.error);

    3) I think that now I need to activate the generated account by transfer

    XRP from the Genesis Account to the address I previously generated:

    'use strict';
    const RippleAPI = require('ripple-lib').RippleAPI;
    const assert = require('assert');

    const myAddr = 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh'; #<-- GENESIS ACCOUNT
    const mySecret = 'snxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; #<-- SECRET OF GENESIS ACCOUNT

    const myPayment = {
    'source': {
    'address': 'rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh', #<-- GENESIS ACCOUNT
    'maxAmount': {
    'value': '10000000',
    'currency': 'XRP'
    }
    },
    'destination': {
    'address': 'rDEPH5NL8b6HHYzhPFLMVoiFuW8myL6L66', #<-- GENERATED ADDRESS
    'amount': {
    'value': '10000000',
    'currency': 'XRP'
    }
    }
    };

    const INTERVAL = 1000;
    const api = new RippleAPI({server: 'ws://127.0.0.1:5006'});
    const ledgerOffset = 5;
    const myInstructions = {maxLedgerVersionOffset: ledgerOffset};

    function verifyTransaction(hash, options) {
    console.log('Verifing Transaction');
    return api.getTransaction(hash, options).then(data => {
    console.log('Final Result: ', data.outcome.result);
    console.log('Validated in Ledger: ', data.outcome.ledgerVersion);
    console.log('Sequence: ', data.sequence);
    return data.outcome.result === 'tesSUCCESS';
    }).catch(error => {
    if (error instanceof api.errors.PendingLedgerVersionError) {
    return new Promise((resolve, reject) => {
    setTimeout(() => verifyTransaction(hash, options)
    .then(resolve, reject), INTERVAL);
    });
    }
    return error;
    });
    }

    function submitTransaction(lastClosedLedgerVersion, prepared, secret) {
    const signedData = api.sign(prepared.txJSON, secret);
    return api.submit(signedData.signedTransaction).then(data => {
    console.log('Tentative Result: ', data.resultCode);
    console.log('Tentative Message: ', data.resultMessage);
    assert.strictEqual(data.resultCode, 'tesSUCCESS');
    const options = {
    minLedgerVersion: lastClosedLedgerVersion,
    maxLedgerVersion: prepared.instructions.maxLedgerVersion
    };
    return new Promise((resolve, reject) => {
    setTimeout(() => verifyTransaction(signedData.id, options)
    .then(resolve, reject), INTERVAL);
    });
    });
    }

    api.connect().then(() => {
    console.log('Connected');
    return api.preparePayment(myAddr, myPayment, myInstructions);
    }).then(prepared => {
    console.log('Payment Prepared');
    return api.getLedger().then(ledger => {
    console.log('Current Ledger', ledger.ledgerVersion);
    console.log('LOG prepared', prepared);
    return submitTransaction(ledger.ledgerVersion, prepared, mySecret);
    });
    }).then(() => {
    api.disconnect().then(() => {
    console.log('api disconnected');
    process.exit();
    });
    }).catch(console.error);


    4) When I run this script I have this response:



    Connected
    Payment Prepared
    Current Ledger 22715879
    LOG prepared { txJSON: '{"TransactionType":"Payment","Account":"rHb9CJAWyB4rj91VRWn96DkukG4bwdtyTh","Destination":"rDEPH5NL8b6HHYzhPFLMVoiFuW8myL6L66",
    "Amount":"10000000000000","Flags":2147483648,"LastLedgerSequence":22715884,"Sequence":44196,"Fee":"12"}',
    instructions: { fee: '0.000012', sequence: 44196, maxLedgerVersion: 22715884 } }
    Tentative Result: tefMASTER_DISABLED
    Tentative Message: Master key is disabled.
    { [AssertionError: 'tefMASTER_DISABLED' === 'tesSUCCESS']
    name: 'AssertionError',
    actual: 'tefMASTER_DISABLED',
    expected: 'tesSUCCESS',
    operator: '===',
    message: '\'tefMASTER_DISABLED\' === \'tesSUCCESS\'',
    generatedMessage: true }


    Seems that the Genesis Account can't send XRP beacause has "tefMASTER_DISABLED".



    How I can fix this issue?
    I need to modify also the configuration of rippled.cfg?