Link

Custody Server

  1. Start CU server

    docker run --rm -ti \
      -v ${PWD}/key-backups/:/app/keys/ \
      -p 8080:8080 \
      docker.copper.co/custody/copper-unlimited-server:v1.0.0
    

    ${PWD}/key-backups/ should contain MPC wallets backup from Copper Unlimited.

  2. Create withdraw order (example: move funds from Vault to some WG exchange)

     + POST https://api.copper.co/platform/orders
        
     + Request
       {
         "externalOrderId": "ckdr8xy1l00303g5neu5iunh4",
         "orderType": "withdraw",
         "baseCurrency": "LTC",
         "mainCurrency": "LTC",
         "amount": "0.01",
         "portfolioId": "edd7e0ea-9d00-4538-b187-c14813d7b0ba",  // from account
         "toPortfolioId": "28a26c72-4d72-4f97-9b36-6811ab708216", // to account
         "includeFeeInWithdraw": true,
         "feeLevel": "low"
       } 
          
     + Response 201
       {
         "orderId": "5824946",
         "orderType": "withdraw",
         "amount": "0.01",
         "baseCurrency": "LTC",
         "mainCurrency": "LTC",
         "externalOrderId": "ckdr8xy1l00303g5neu5iunh4",
         "extra": {
           "feeLevel": "low",
           "includeFeeInWithdraw": true,
           "toAddress": "mhS6JYtebpadLR2gHFmLMo1yPCVLKBnskR",
           "toPortfolioId": "28a26c72-4d72-4f97-9b36-6811ab708216"
         },
         "portfolioId": "edd7e0ea-9d00-4538-b187-c14813d7b0ba",
         "portfolioType": "custody",
         "status": "awaiting-settlement"
       }
    
  3. Start transaction settlement flow

     + PATCH https://api.copper.co/platform/orders/{orderId}
       
     + Headers
       Content-Type: application/vnd.start-custody-settlement+json
        
     + Response 200
       {
         "amount": "0.01",
         "baseCurrency": "LTC",
         "externalOrderId": "ckdr8xy1l00303g5neu5iunh4",
         "extra": {
           "feeLevel": "low",
           "includeFeeInWithdraw": true,
           "toAddress": "mhS6JYtebpadLR2gHFmLMo1yPCVLKBnskR",
           "toPortfolioId": "28a26c72-4d72-4f97-9b36-6811ab708216",
           "transactionRequest": {
             "amount": "1000000",
             "currency": "LTC",
             "includeFee": true,
             "mainCurrency": "LTC",
             "toAddress": "mhS6JYtebpadLR2gHFmLMo1yPCVLKBnskR",
             "transactionRequest": {
               "changeAmount": "30889893",
               "changePathSuffix": "1",
               "fee": "37400",
               "includeFee": true,
               "inputs": [
                 {
                   "pathSuffix": "0",
                   "txId": "42e51255161a401ac6549e30fc3b9b176a5587d7513e15b7ed7860b5dbdf6eea",
                   "txIndex": "5",
                   "value": "31889893"
                 }
               ],
               "outputs": [
                 {
                   "address": "mhS6JYtebpadLR2gHFmLMo1yPCVLKBnskR",
                   "value": "1000000"
                 }
               ]
             },
             "xpubHash": "ea2725e998cf7c74149dc0f26d2106fdc1e4b596d97906b348516675fc4405f2"
           },
           "withdrawFee": "0.00037400"
         },
         "mainCurrency": "LTC",
         "orderId": "5824946",
         "orderType": "withdraw",
         "portfolioId": "edd7e0ea-9d00-4538-b187-c14813d7b0ba",
         "portfolioType": "custody",
         "status": "working"
       }
    
  4. Sign transaction in offline copper-unlimited-server

    + POST http://127.0.0.1:8080/signatures
    
    + Request
      {
        "type": "request",
        "transactionPassword": "Test.1234!",
        "keyPassword": "myTestPaswordFromKeyBackup.1234#",
        "keyFilename": "BTC_My Default Vault_wallet.copper",
       
       
         // get all this fields from order.extra.transactionRequest, described above
       
        "amount": "1000000",
        "currency": "LTC",
        "includeFee": true,
        "mainCurrency": "LTC",
        "toAddress": "mhS6JYtebpadLR2gHFmLMo1yPCVLKBnskR",
        "transactionRequest": {
          "changeAmount": "30889893",
          "changePathSuffix": "1",
          "fee": "37400",
          "includeFee": true,
          "inputs": [
            {
              "pathSuffix": "0",
              "txId": "42e51255161a401ac6549e30fc3b9b176a5587d7513e15b7ed7860b5dbdf6eea",
              "txIndex": "5",
              "value": "31889893"
            }
          ],
          "outputs": [
            {
              "address": "mhS6JYtebpadLR2gHFmLMo1yPCVLKBnskR",
              "value": "1000000"
            }
          ]
        },
        "xpubHash": "ea2725e998cf7c74149dc0f26d2106fdc1e4b596d97906b348516675fc4405f2"
      }
       
    + Response 200 OK
      {
        "type": "part-signed-tx",
        "value": "AQRwL5FqGrbLaPO4w+NoEq9oZ...R5I/wjEQND/4YmIn+rbN9uh5U/0=",
      }
    
  5. Upload part-signed transaction to Copper

     + PATCH https://api.copper.co/platform/orders/{orderId}
        
     + Headers
       Content-Type: application/vnd.upload-part-signed-tx+json
          
     + Request
       {
         "transaction": {
           "type": "part-signed-tx",
           "value": "AQRwL5FqGrbLaPO4w+NoEq9oZ...R5I/wjEQND/4YmIn+rbN9uh5U/0="
         }
       }