Merge branch 'master' into develop

# Conflicts:
#	src/rosetta-helpers.ts
This commit is contained in:
Matthew Little
2021-09-08 15:51:41 +02:00
4 changed files with 31 additions and 20 deletions

View File

@@ -1,3 +1,29 @@
# [0.65.0](https://github.com/blockstack/stacks-blockchain-api/compare/v0.64.2...v0.65.0) (2021-09-07)
### Bug Fixes
* added types for search endpoint [#645](https://github.com/blockstack/stacks-blockchain-api/issues/645) ([7cc78fb](https://github.com/blockstack/stacks-blockchain-api/commit/7cc78fb5733930d5d3c2b5c7c773dabd4bdeb294))
* short summaries for BNS endpoints ([e37b5af](https://github.com/blockstack/stacks-blockchain-api/commit/e37b5afbf57ca4d0c183b05eae6e14f87ebc3afd))
* sql optimizations to speed up various tx queries ([10b1c67](https://github.com/blockstack/stacks-blockchain-api/commit/10b1c67d20b99f7c57a6b2c4657faf5019b59745))
* **rosetta:** change sender and receiver operations to token_transfer [#683](https://github.com/blockstack/stacks-blockchain-api/issues/683) ([91856c8](https://github.com/blockstack/stacks-blockchain-api/commit/91856c865598f11c358165ead9f39bd4a73f9128))
### Features
* add execution cost data to transactions ([d9e1131](https://github.com/blockstack/stacks-blockchain-api/commit/d9e1131f8371232129779813704548e266e1916f))
* emit prometheus metrics for socket.io ([3100c56](https://github.com/blockstack/stacks-blockchain-api/commit/3100c5661e62fece6b33bfe2806940e3ea655425))
* expose FT and NFT transfers in /extended/v1/address/[:principal]/transactions_with_transfers ([439d4f4](https://github.com/blockstack/stacks-blockchain-api/commit/439d4f46cdd9b8fcc3f6fa1016482a4df0a02129))
* return git info in /extended/v1/status ([0538ae2](https://github.com/blockstack/stacks-blockchain-api/commit/0538ae297f5c5c211825b0a173be34ccf6e96353))
* token metadata ([33f11bb](https://github.com/blockstack/stacks-blockchain-api/commit/33f11bbcf3345623fbc0ae5a96eec706a351ff05))
## [0.64.2](https://github.com/blockstack/stacks-blockchain-api/compare/v0.64.1...v0.64.2) (2021-08-20)
### Bug Fixes
* Revert "fix(rosetta): conflicting nonce issue in rosetta tx construction [#685](https://github.com/blockstack/stacks-blockchain-api/issues/685)" ([408f1c0](https://github.com/blockstack/stacks-blockchain-api/commit/408f1c02795d483a7a145d1dcc671d7ec760244d))
## [0.64.1](https://github.com/blockstack/stacks-blockchain-api/compare/v0.64.0...v0.64.1) (2021-08-19)

View File

@@ -13,7 +13,6 @@ import {
} from '@stacks/stacks-blockchain-api-types';
import { RosettaErrors, RosettaConstants, RosettaErrorsTypes } from '../../rosetta-constants';
import { rosettaValidateRequest, ValidSchema, makeRosettaError } from '../../rosetta-validate';
import { getAddressNonce } from '../../../rosetta-helpers';
import { ChainID } from '@stacks/transactions';
import { StacksCoreRpcClient } from '../../../core-rpc/client';
@@ -68,8 +67,7 @@ export function createRosettaAccountRouter(db: DataStore, chainId: ChainID): Rou
// return spendable balance (liquid) if no sub-account is specified
let balance = (stxBalance.balance - stxBalance.locked).toString();
// Getting nonce info
const nonce = await getAddressNonce(db, accountIdentifier.address);
const accountInfo = await new StacksCoreRpcClient().getAccount(accountIdentifier.address);
const extra_metadata: any = {};
@@ -119,7 +117,7 @@ export function createRosettaAccountRouter(db: DataStore, chainId: ChainID): Rou
},
],
metadata: {
sequence_number: nonce,
sequence_number: accountInfo.nonce ? accountInfo.nonce : 0,
},
};

View File

@@ -72,7 +72,6 @@ import {
getStacksNetwork,
makePresignHash,
verifySignature,
getAddressNonce,
} from './../../../rosetta-helpers';
import { makeRosettaError, rosettaValidateRequest, ValidSchema } from './../../rosetta-validate';
@@ -371,7 +370,8 @@ export function createRosettaConstructionRouter(db: DataStore, chainId: ChainID)
const stxAddress = options.sender_address;
// Getting nonce info
const nonce = await getAddressNonce(db, stxAddress);
const accountInfo = await new StacksCoreRpcClient().getAccount(stxAddress);
const nonce = accountInfo.nonce;
let recentBlockHash = undefined;
const blockQuery: FoundOrNot<DbBlock> = await db.getCurrentBlock();

View File

@@ -61,10 +61,9 @@ import { getTxSenderAddress, getTxSponsorAddress } from './event-stream/reader';
import { unwrapOptional, bufferToHexPrefixString, hexToBuffer } from './helpers';
import { readTransaction, TransactionPayloadTypeID } from './p2p/tx';
import { getCoreNodeEndpoint, StacksCoreRpcClient } from './core-rpc/client';
import { getCoreNodeEndpoint } from './core-rpc/client';
import { serializeCV, TupleCV } from '@stacks/transactions';
import { getBTCAddress, poxAddressToBtcAddress } from '@stacks/stacking';
import { once } from 'node:events';
enum CoinAction {
CoinSpent = 'coin_spent',
@@ -455,18 +454,6 @@ function makePoisonMicroblockOperation(tx: BaseTx, index: number): RosettaOperat
return sender;
}
/**
* Determine the best nonce to use for the next tx by querying both the stacks-node RPC
* and the postgres db, then taking the max value found.
* See https://github.com/blockstack/stacks-blockchain-api/issues/685
*/
export async function getAddressNonce(db: DataStore, stxAddress: string): Promise<number> {
const nodeNonce = await new StacksCoreRpcClient().getAccountNonce(stxAddress);
const apiNonce = await db.getAddressNonces({ stxAddress: stxAddress });
const nonce = Math.max(nodeNonce, apiNonce.possibleNextNonce);
return nonce;
}
export function publicKeyToBitcoinAddress(publicKey: string, network: string): string | undefined {
const publicKeyBuffer = Buffer.from(publicKey, 'hex');