Withdraw - Go Account (Manual)
Build, authenticate, and send withdrawals with granular control. See the Guide.
-
This step is required only for withdrawing fiat from your Go Account to a BitGo-approved bank account. Crypto withdrawals skip this step.
-
Build the transaction by specifying transaction details and sending them to BitGo. BitGo constructs an unsigned transaction payload.
-
Use your Go Account passphrase to authenticate the transaction. Use BitGo Express in external-signing mode, the JavaScript SDK, or Java to ensure your passphrase isn't sent over the Internet.
-
Send the authenticated transaction to BitGo. If approval isn't required, BitGo processes the withdrawal. If you have policy rules, the transaction remains pending until approved.
-
If your withdrawal requires approval, another admin must approve it — you cannot approve your own transactions.
// 1. Get idHash (Optional)
export ENTERPRISE_ID="<ENTERPRISE_ID>"
export ACCESS_TOKEN="<YOUR_ACCESS_TOKEN>"
curl -X GET \
https://app.bitgo-test.com/api/v2/bankaccounts?enterpriseId=$ENTERPRISE_ID \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN"
// 2. Build Transaction
export COIN="<OFC_ASSET_ID>"
export WALLET_ID="<YOUR_WALLET_ID>"
export AMOUNT="<AMOUNT_IN_BASE_UNITS>"
export ADDRESS="<DESTINATION_ADDRESS_OR_ID_HASH>"
curl -X POST \
https://app.bitgo-test.com/api/v2/$COIN/wallet/$WALLET_ID/tx/build \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"recipients": [
{
"amount": "'"$AMOUNT"'",
"address": "'"$ADDRESS"'"
}
]
}'
// 3. Authenticate Transaction
export BITGO_EXPRESS_HOST="<YOUR_LOCAL_HOST>"
export WALLET_PASSPHRASE="<YOUR_GO_ACCOUNT_PASSPHRASE>"
curl -X POST \
http://$BITGO_EXPRESS_HOST/api/v2/ofc/signPayload \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"walletId": "'"$WALLET_ID"'",
"walletPassphrase": "'"$WALLET_PASSPHRASE"'",
"payload": "<PAYLOAD_FROM_BUILD_STEP>"
}'
// 4. Send Transaction
curl -X POST \
https://app.bitgo-test.com/api/v2/$COIN/wallet/$WALLET_ID/tx/send \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"halfSigned": {
"payload": "<PAYLOAD>",
"signature": "<SIGNATURE_FROM_AUTH_STEP>"
}
}'
// 5. Approve Transaction (Optional)
export APPROVAL_ID="<APPROVAL_ID>"
export OTP="<YOUR_OTP>"
curl -X PUT \
https://app.bitgo-test.com/api/v2/pendingApprovals/$APPROVAL_ID \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d '{
"state": "approved",
"otp": "'"$OTP"'"
}'
// 1. Get idHash (Optional)
// Use REST API to list bank accounts for fiat withdrawals
// 2. Build Transaction
let params = {
recipients: [
{
amount: 1000,
address: '2NFfxvXpAWjKng7enFougtvtxxCJ2hQEMo4',
},
],
};
wallet.prebuildTransaction(params).then(function (transaction) {
console.dir(transaction);
});
// 3. Authenticate Transaction
const wallet = await bitgo.coin('ofc').wallets().get({ id: goAccountId });
const walletPassphrase = "<YOUR_WALLET_PASSPHRASE>";
const tradingAccount = wallet.toTradingAccount();
const signature = await tradingAccount.signPayload({
payload: stringifiedPayload,
walletPassphrase,
});
// 4. Send Transaction
// Use the signature from step 3 with the tx/send endpoint
// 5. Approve Transaction (Optional)
const baseCoin = bitgo.coin(initialPendingApproval.coin);
const pendingApproval = await baseCoin.pendingApprovals().get({ id: initialPendingApproval.id });
const result = await pendingApproval.approve(params);
// 1. Get idHash (Optional)
// Use the cURL tab for this step
// 2. Build Transaction
// Use the cURL tab for this step
// 3. Authenticate Transaction
import javax.crypto.*;
import javax.crypto.spec.*;
import java.security.*;
import java.security.spec.*;
import java.nio.charset.StandardCharsets;
import java.util.*;
import com.google.gson.*;
import org.bitcoinj.core.ECKey;
import org.bitcoinj.core.Sha256Hash;
import org.bitcoinj.crypto.DeterministicKey;
public class SignPayload {
public static void main(String[] args) throws Exception {
System.out.println("=== Sign Payload for Go Account Withdrawal ===\n");
// Configuration - replace with your values
String walletPassphrase = "your_wallet_passphrase";
String encryptedPrivateKey = "{\"iv\":...";
String payloadToSign = "{\"coin\":...";
// Step 1: Decrypt private key
System.out.println("Step 1: Decrypt Private Key");
System.out.println("-".repeat(50));
Gson gson = new Gson();
JsonObject data = gson.fromJson(encryptedPrivateKey, JsonObject.class);
byte[] salt = Base64.getDecoder().decode(data.get("salt").getAsString());
byte[] iv = Base64.getDecoder().decode(data.get("iv").getAsString());
byte[] ciphertextWithTag = Base64.getDecoder().decode(data.get("ct").getAsString());
int iterations = data.get("iter").getAsInt();
int keySize = data.get("ks").getAsInt();
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA256");
KeySpec spec = new PBEKeySpec(walletPassphrase.toCharArray(), salt, iterations, keySize);
SecretKey tmp = factory.generateSecret(spec);
SecretKeySpec secretKey = new SecretKeySpec(tmp.getEncoded(), "AES");
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
GCMParameterSpec gcmSpec = new GCMParameterSpec(128, iv);
cipher.init(Cipher.DECRYPT_MODE, secretKey, gcmSpec);
byte[] decrypted = cipher.doFinal(ciphertextWithTag);
String decryptedPrv = new String(decrypted, StandardCharsets.UTF_8);
System.out.println("✓ Private key decrypted");
System.out.println();
// Step 2: Sign payload
System.out.println("Step 2: Sign Payload");
System.out.println("-".repeat(50));
DeterministicKey key = DeterministicKey.deserializeB58(decryptedPrv, org.bitcoinj.params.MainNetParams.get());
ECKey ecKey = ECKey.fromPrivate(key.getPrivKeyBytes());
// Bitcoin message format
String messagePrefix = "\u0018Bitcoin Signed Message:\n";
byte[] payloadBytes = payloadToSign.getBytes(StandardCharsets.UTF_8);
byte[] prefixBytes = messagePrefix.getBytes(StandardCharsets.UTF_8);
byte[] lengthVarint = encodeVarint(payloadBytes.length);
byte[] messageToSign = new byte[prefixBytes.length + lengthVarint.length + payloadBytes.length];
System.arraycopy(prefixBytes, 0, messageToSign, 0, prefixBytes.length);
System.arraycopy(lengthVarint, 0, messageToSign, prefixBytes.length, lengthVarint.length);
System.arraycopy(payloadBytes, 0, messageToSign, prefixBytes.length + lengthVarint.length, payloadBytes.length);
// Double SHA-256 hash
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] firstHash = digest.digest(messageToSign);
byte[] messageHash = digest.digest(firstHash);
// Sign
ECKey.ECDSASignature signature = ecKey.sign(Sha256Hash.wrap(messageHash));
// Create 65-byte recoverable signature
byte[] result = new byte[65];
// Calculate recovery ID
int recoveryId = -1;
for (int i = 0; i < 4; i++) {
try {
ECKey recovered = ECKey.recoverFromSignature(i, signature, Sha256Hash.wrap(messageHash), true);
if (recovered != null && Arrays.equals(recovered.getPubKey(), ecKey.getPubKey())) {
recoveryId = i;
break;
}
} catch (Exception e) {
// Continue trying
}
}
if (recoveryId == -1) {
throw new RuntimeException("Could not determine signature recovery ID");
}
result[0] = (byte) (31 + recoveryId);
copyBigIntegerTo32Bytes(signature.r.toByteArray(), result, 1);
copyBigIntegerTo32Bytes(signature.s.toByteArray(), result, 33);
String hexSignature = bytesToHex(result);
System.out.println("✓ Payload signed");
System.out.println();
System.out.println("Signature (hex):");
System.out.println(hexSignature);
System.out.println();
System.out.println("✓ Use this signature with the /tx/send endpoint");
}
private static byte[] encodeVarint(long value) {
if (value < 253) {
return new byte[] { (byte) value };
} else if (value <= 0xFFFF) {
byte[] result = new byte[3];
result[0] = (byte) 0xFD;
result[1] = (byte) (value & 0xFF);
result[2] = (byte) ((value >> 8) & 0xFF);
return result;
}
throw new RuntimeException("Payload too large");
}
private static void copyBigIntegerTo32Bytes(byte[] source, byte[] dest, int destOffset) {
int sourceOffset = 0;
int sourceLength = source.length;
if (sourceLength > 32) {
sourceOffset = 1;
sourceLength = 32;
}
int destStart = destOffset + (32 - sourceLength);
System.arraycopy(source, sourceOffset, dest, destStart, sourceLength);
}
private static String bytesToHex(byte[] bytes) {
StringBuilder result = new StringBuilder();
for (byte b : bytes) {
result.append(String.format("%02x", b));
}
return result.toString();
}
}
// 4. Send Transaction
// Use the cURL tab for this step
// 5. Approve Transaction (Optional)
// Use the cURL tab for this step
// 2. Build Transaction Response
{
"payload": "{\"coin\":\"ofctbtc4\",\"recipients\":[{\"address\":\"tb1q...\",\"amount\":\"1\"}],\"fromAccount\":\"62c5b1de8a0c5200071c9a603bdbadc5\",\"nonce\":\"d8e5d930-f827-42b1-ad85-40544dad1be6\",\"timestamp\":\"2025-06-25T17:45:56.394Z\",\"feeString\":\"0\"}",
"feeInfo": { "feeString": "0" },
"coin": "ofc",
"token": "ofctbtc4"
}
// 3. Authenticate Transaction Response
{
"coin": "ofctbtc4",
"payload": "{\"coin\":\"ofctbtc4\",...}",
"signature": "20dda1e9558adb297f69020f94cbf4955fabec73478506347dbb5ac8e73b506fc908bbc48bde75b339b99f5de808ed34b2017055c9df198fd1f8b4e524899f9583"
}
// 4. Send Transaction Response
{
"transfer": {
"id": "613be001f3de560006842d52251d5d49",
"coin": "ofctusd",
"wallet": "603ca8c01b83cb000656311787dab4cd",
"type": "send",
"state": "signed"
},
"status": "signed"
}
// 5. Approve Transaction Response
{
"id": "655686880765186f0b3e9e88e1bdd0f4",
"state": "approved"
}