Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
222 changes: 140 additions & 82 deletions masterBitgoExpress.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,7 @@
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"details": {
"type": "string"
}
},
"required": [
"error",
"details"
]
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
Expand Down Expand Up @@ -193,7 +181,9 @@
"description": "Bad Request",
"content": {
"application/json": {
"schema": {}
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
Expand All @@ -202,19 +192,7 @@
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"details": {
"type": "string"
}
},
"required": [
"error",
"details"
]
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
Expand Down Expand Up @@ -355,7 +333,9 @@
"description": "Bad Request",
"content": {
"application/json": {
"schema": {}
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
Expand All @@ -364,19 +344,7 @@
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"details": {
"type": "string"
}
},
"required": [
"error",
"details"
]
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
Expand Down Expand Up @@ -417,6 +385,7 @@
"type": "string",
"enum": [
"transfer",
"fillNonce",
"acceleration",
"accountSet",
"enabletoken",
Expand Down Expand Up @@ -532,11 +501,13 @@
},
"custodianTransactionId": {
"type": "string"
},
"nonce": {
"type": "string"
}
},
"required": [
"source",
"recipients"
"source"
]
}
}
Expand All @@ -556,19 +527,7 @@
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"details": {
"type": "string"
}
},
"required": [
"error",
"details"
]
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
Expand Down Expand Up @@ -642,19 +601,7 @@
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"details": {
"type": "string"
}
},
"required": [
"error",
"details"
]
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
Expand Down Expand Up @@ -723,19 +670,7 @@
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"error": {
"type": "string"
},
"details": {
"type": "string"
}
},
"required": [
"error",
"details"
]
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
Expand Down Expand Up @@ -939,6 +874,113 @@
}
}
},
"422": {
"description": "Unprocessable Entity",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"500": {
"description": "Internal Server Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
}
},
"/api/{coin}/wallet/recoveryconsolidations": {
"post": {
"parameters": [
{
"name": "coin",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"userPub": {
"type": "string"
},
"backupPub": {
"type": "string"
},
"bitgoPub": {
"type": "string"
},
"multisigType": {
"type": "string",
"enum": [
"onchain",
"tss"
]
},
"commonKeychain": {
"type": "string"
},
"tokenContractAddress": {
"type": "string"
},
"startingScanIndex": {
"type": "number"
},
"endingScanIndex": {
"type": "number"
},
"apiKey": {
"type": "string"
},
"durableNonces": {
"type": "object",
"properties": {
"publicKeys": {
"type": "array",
"items": {
"type": "string"
}
},
"secretKey": {
"type": "string"
}
},
"required": [
"publicKeys",
"secretKey"
]
}
},
"required": [
"multisigType"
]
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {}
}
}
},
"500": {
"description": "Internal Server Error",
"content": {
Expand Down Expand Up @@ -1122,6 +1164,22 @@
"status",
"timestamp"
]
},
"ErrorResponse": {
"title": "ErrorResponse",
"type": "object",
"properties": {
"error": {
"type": "string"
},
"details": {
"type": "string"
}
},
"required": [
"error",
"details"
]
}
}
}
Expand Down
75 changes: 75 additions & 0 deletions src/__tests__/api/master/sendMany.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,81 @@ describe('POST /api/:coin/wallet/:walletId/sendmany', () => {
sinon.assert.calledOnce(multisigTypeStub);
});

it('should be able to sign a fill nonce transaction', async () => {
// Mock wallet get request for TSS wallet
const walletGetNock = nock(bitgoApiUrl)
.get(`/api/v2/${coin}/wallet/${walletId}`)
.matchHeader('any', () => true)
.reply(200, {
id: walletId,
type: 'cold',
subType: 'onPrem',
keys: ['user-key-id', 'backup-key-id', 'bitgo-key-id'],
multisigType: 'tss',
});

// Mock keychain get request for TSS keychain
const keychainGetNock = nock(bitgoApiUrl)
.get(`/api/v2/${coin}/key/user-key-id`)
.matchHeader('any', () => true)
.reply(200, {
id: 'user-key-id',
pub: 'xpub_user',
commonKeychain: 'test-common-keychain',
source: 'user',
type: 'tss',
});

const sendManyStub = sinon.stub(Wallet.prototype, 'sendMany').resolves({
txRequest: {
txRequestId: 'test-tx-request-id',
state: 'signed',
apiVersion: 'full',
pendingApprovalId: 'test-pending-approval-id',
transactions: [
{
state: 'signed',
unsignedTx: {
derivationPath: 'm/0',
signableHex: 'testMessage',
serializedTxHex: 'testSerializedTxHex',
},
signatureShares: [],
signedTx: {
id: 'test-tx-id',
tx: 'signed-transaction',
},
},
],
},
txid: 'test-tx-id',
tx: 'signed-transaction',
});

// Mock multisigType to return 'tss'
const multisigTypeStub = sinon.stub(Wallet.prototype, 'multisigType').returns('tss');

const response = await agent
.post(`/api/${coin}/wallet/${walletId}/sendMany`)
.set('Authorization', `Bearer ${accessToken}`)
.send({
type: 'fillNonce',
nonce: '2',
source: 'user',
pubkey: 'xpub_user',
});

response.status.should.equal(200);
response.body.should.have.property('txRequest');
response.body.should.have.property('txid', 'test-tx-id');
response.body.should.have.property('tx', 'signed-transaction');

walletGetNock.done();
keychainGetNock.done();
sinon.assert.calledOnce(sendManyStub);
sinon.assert.calledOnce(multisigTypeStub);
});

it('should fail when backup key is used for ECDSA TSS signing', async () => {
// Mock wallet get request for TSS wallet
const walletGetNock = nock(bitgoApiUrl)
Expand Down
Loading