Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I use regtest to call loopd rpc api getinfo,got:14 UNAVAILABLE: No connection established. #749

Open
jimtracy1007 opened this issue May 20, 2024 · 1 comment

Comments

@jimtracy1007
Copy link

version: "3"
services:
  bitcoind:
    image: ruimarinho/bitcoin-core:23
    container_name: bitcoind
    restart: unless-stopped
    networks:
      regtest:
        aliases:
          - bitcoind
    command:
      - "-txindex"
      - "-regtest"
      - "-rest"
      - "-printtoconsole"
      - "-zmqpubrawblock=tcp://0.0.0.0:28332"
      - "-zmqpubrawtx=tcp://0.0.0.0:28333"
      - "-rpcport=18443"
      - "-rpcbind=0.0.0.0"
      # This is just the hashed string "lightning" with a salt.
      - "-rpcauth=lightning:8492220e715bbfdf5f165102bfd7ed4$$88090545821ed5e9db614588c0afbad575ccc14681fb77f3cae6899bc419af67"
      - "-rpcallowip=0.0.0.0/0"
      - "-fallbackfee=0.0002"
      - "-peerblockfilters=1"
      - "-blockfilterindex=1"
      - "-wallet=/home/bitcoin/.bitcoin/regtest/wallets/miner"
    environment:
      - HOME=/home/bitcoin
    volumes:
      - ./bitcoind:/home/bitcoin/.bitcoin

  lndserver:
    image: lightninglabs/lnd:v0.17.4-beta
    container_name: lndserver
    restart: unless-stopped
    networks:
      regtest:
        aliases:
          - lndserver
    volumes:
      - "./lndserver:/root/.lnd"
    depends_on:
      - bitcoind
    command:
      - "--logdir=/root/.lnd"
      - "--alias=lndserver"
      - "--rpclisten=0.0.0.0:10009"
      - "--noseedbackup"
      - "--bitcoin.active"
      - "--bitcoin.regtest"
      - "--bitcoin.node=bitcoind"
      - "--bitcoind.rpchost=bitcoind"
      - "--bitcoind.rpcuser=lightning"
      - "--bitcoind.rpcpass=lightning"
      - "--bitcoind.zmqpubrawblock=tcp://bitcoind:28332"
      - "--bitcoind.zmqpubrawtx=tcp://bitcoind:28333"
      - "--debuglevel=debug"
      - "--externalip=lndserver"
      - "--tlsextradomain=lndserver"

  loopserver:
    image: lightninglabs/loopserver
    container_name: loopserver
    restart: unless-stopped
    networks:
      regtest:
        aliases:
          - loopserver
    volumes:
      - "./lndserver:/root/.lnd"
    depends_on:
      - lndserver
    expose:
      - "11009"
    ports:
      - "11009:11009"
    command:
      - "daemon"
      - "--maxamt=5000000"
      - "--lnd.host=lndserver:10009"
      - "--lnd.macaroondir=/home/loopserver/"
      - "--lnd.tlspath=/home/loopserver/tls.cert"
      - "--bitcoin.host=bitcoind:18443"
      - "--bitcoin.user=lightning"
      - "--bitcoin.password=lightning"
      - "--bitcoin.zmqpubrawblock=tcp://bitcoind:28332"
      - "--bitcoin.zmqpubrawtx=tcp://bitcoind:28333"

  lndclient:
    image: lightninglabs/lnd:v0.17.4-beta
    container_name: lndclient
    restart: unless-stopped
    networks:
      regtest:
        aliases:
          - lndclient
    volumes:
      - "./lndclient:/root/.lnd"
    expose:
      - "8080"
      - "10009"
      - "9735"
    ports:
      - "10009:10009"
    depends_on:
      - bitcoind
    command:
      - "--logdir=/root/.lnd"
      - "--alias=lndclient"
      - "--rpclisten=0.0.0.0:10009"
      - "--noseedbackup"
      - "--bitcoin.active"
      - "--bitcoin.regtest"
      - "--bitcoin.node=bitcoind"
      - "--bitcoind.rpchost=bitcoind"
      - "--bitcoind.rpcuser=lightning"
      - "--bitcoind.rpcpass=lightning"
      - "--bitcoind.zmqpubrawblock=tcp://bitcoind:28332"
      - "--bitcoind.zmqpubrawtx=tcp://bitcoind:28333"
      - "--debuglevel=debug"
      - "--externalip=lndclient"
      - "--tlsextradomain=lndclient"

  loopclient:
    image: loopd
    container_name: loopclient
    build:
      context: ../
      dockerfile: Dockerfile
    restart: unless-stopped
    networks:
      regtest:
        aliases:
          - loopclient
    volumes:
      - "./lndclient:/root/.lnd"
      - "./lndclient/loop:/root/.loop"
    expose:
      - "8081"
      - "11010"
    ports:
      - "11010:11010"
      - "8081:8081"
    depends_on:
      - lndclient
      - loopserver
    command:
      - "loopd"
      - "--network=regtest"
      - "--debuglevel=debug"
      - "--server.host=loopserver:11009"
      - "--server.notls"
      - "--lnd.host=lndclient:10009"
      - "--lnd.macaroonpath=/root/.lnd/data/chain/bitcoin/regtest/admin.macaroon"
      - "--lnd.tlspath=/root/.lnd/tls.cert"

networks:
  regtest:


 {
  host: '127.0.0.1:11010',
  certFilePath: '/Users/wjl/Documents/gamichi/2024/loop/regtest/lndclient/loop/regtest/tls.cert',
  macaroonFilePath: '/Users/wjl/Documents/gamichi/2024/loop/regtest/lndclient/loop/regtest/loop.macaroon'
}
const loaderOptions = {
    keepCase: true,
    longs: String,
    enums: String,
    defaults: true,
    oneofs: true,
  };
  process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
  const tlsCert = certFilePath ? fs.readFileSync(certFilePath) : '';
  const sslCreds = grpc.credentials.createSsl(tlsCert);
  if (!macaroonFilePath) {
    throw new Error('macaroonFilePath is required')
  }
  const macaroon = fs.readFileSync(macaroonFilePath).toString('hex');
  const macaroonCreds = grpc.credentials.createFromMetadataGenerator(function (args, callback) {
    let metadata = new grpc.Metadata();
    metadata.add('macaroon', macaroon);
    callback(null, metadata);
  });
  let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
  const packageDefinition = protoLoader.loadSync(protoClient, loaderOptions);
  const looprpc = grpc.loadPackageDefinition(packageDefinition).looprpc;
  let client = new looprpc.SwapClient(host, creds);


  return client
  
  const getInfo = () => {
    return new Promise((resolve, reject) => {
      client.getInfo({}, function (err, response) {
        if (err) {
          reject(err)

        }
        resolve(response)
      });
    })
  }
  

❌ ~ getRepayByMessage ~ e.message: 14 UNAVAILABLE: No connection established. Last error: Client network socket disconnected before secure TLS connection was established (2024-05-20T12:11:41.245Z)
@jimtracy1007
Copy link
Author

How to constructor creds and let it work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant