How do you transfer tokens from the lockup contract using the CLI? - nearprotocol

If tokens were locked using a lockup contract (docs) what is the process for using the CLI to transfer those tokens once they have reached their unlocking time, either fully or partially?

Before the lockup is fully unlocked, you can call a method transfer on the contract, for example:
near call <yourlockup>.lockup.near transfer '{"amount": "1000000000000000000000000000", "receiver_id": "<receiver_account_id>"}' --accountId=<youraccount> --networkId=mainnet --nodeUrl=https://rpc.mainnet.near.org --gas=200000000000000 --useLedgerKey
Once it is fully unlocked, you can also add a full access key by invoking add_full_access_key with {"new_public_key": "<base58 key>"}, and convert your lockup account into a regular account.

There is a step by step guide here, also includes steps related to stake/unstake:
https://github.com/near/core-contracts/tree/master/lockup#staking-flow
The key steps after unstaking and withdrawing are:
near call lockup1 refresh_staking_pool_balance '{}' --accountId=owner1 --gas=75000000000000
near view lockup1 get_liquid_owners_balance '{}'
near call lockup1 check_transfers_vote '{}' --accountId=owner1 --gas=75000000000000
near call lockup1 transfer '{"amount": "10000000000000000000000000", "receiver_id": "owner-sub-account"}' --accountId=owner1 --gas=50000000000000

Related

On NEAR, how to delete all keys other than the FullAccess key that my Ledger seed phrase created

I want to delete all keys other than the FullAccess key that my Ledger seed phrase created.
When I check which keys are associated with my NEAR Ledger account, I see some like:
"access_key": {
"nonce": "aaaaaaaa",
"permission": {
"FunctionCall": {
"allowance": "0",
"method_names": [
"__wallet__metadata"
],
"receiver_id": "bbbbbbbbbbbbbbbb"
}
}
},
"public_key": "ed25519:cccccccccccccc"
}
(fake values above)
I tried:
NEAR_ENV=mainnet near delete-key bbbbbbbbbbbbbbbb cccccccccccccc --useLedgerKey
Make sure to connect your Ledger and open NEAR app
Deleting key cccccccccccccc on bbbbbbbbbbbbbbbb.
Waiting for confirmation on Ledger...
An error occured
DisconnectedDeviceDuringOperation: Cannot write to hid device
at new CustomErrorClass
What should I have done instead?
Also, note that someone should fix "occured" to "occurred".
There may have been an issue with USB connectivity.
The command in this syntax:
NEAR_ENV=mainnet near delete-key bbbbbbbbbbbbbbbb cccccccccccccc --useLedgerKey
did indeed work when the Ledger was plugged directly into my laptop (rather than into a USB switch connected to my laptop) and was logged in with its NEAR app open.
Oddly, it made me confirm the public key of its FullAccess key 3 times before then also (unsurprisingly) making me confirm the deletion of the cccccccccccccc key.
But it worked!
Now when I run NEAR_ENV=mainnet near keys bbbbbbbbbbbbbbbb, I see just the FullAccess key, so I've achieved my goal.
(Note that in my question and in this answer, I've replaced real values with fake ones.)
UPDATE:
Actually, when running NEAR_ENV=mainnet near send xxxxxxx yyyyy 1 --useLedgerKey, even when plugged directly into my laptop, I got this error:
Waiting for confirmation on Ledger...
An error occured
Error
at new TransportError ...
But then I ran it again, and it worked, although it again weirdly made me confirm the public key of its FullAccess key 3 times before then also (unsurprisingly) making me confirm the transfer. So I don't know what the root cause of either issue was, but trying multiple times seems to have been an effective enough workaround.

Google.apis returns error code 400 after creating maximum amount of service account keys

We are using Google.apis Version 1.36.1 SDK in order to create service account keys for GCP Service accounts.
When we reach maximum amount of keys (10) instead of getting a valid error message / error code we recieve a general 400 error code with a "Precondition check failed." message.
We used to get error code 429 indicating we have reached maximum amount of keys.
Current GoogleApiException object :
Google.GoogleApiException: Google.Apis.Requests.RequestError
Precondition check failed. [400]
Errors [
Message[Precondition check failed.] Location[ - ] Reason[failedPrecondition] Domain[global]
]
The current return code does not provide us with enough information, Is there any other way for us to know the reason of the failure ?
This error message is also related to limits. You can take the official documentation for the Classroom API as an example.
I have found myself in a similar situation where we were deleting service account keys to immediately create new ones. We were getting the same error because there is a delay on the system where it can take from 60-90 seconds to delete the key for you to be able to create it again.

In Substrate what does code: 1012 "Transaction is temporarily banned" mean?

The full text of the message is :
{code: 1012, message: "Transaction is temporarily banned"}
This would indicate that the transaction is held somewhere in Substrate Runtime mempool or something of that nature, but it is not entirely clear what possible causes can trigger this, and what the eventual outcome might be.
For example,
1) is it that too many transactions have been sent from a given account, IP address or other? Has some threshold been reached?
2) is the transaction actually invalid, or not?
3) The use of the word "temporary" suggests a delay in processing, not an outright rejection of the transaction. Therefore does this suggest that the transaction is valid, but delayed? If so, for how long?
The comments in the substrate runtime core/rpc/src/author/errors.rs and core/transaction-pool/graph/src/errors.rs is no clearer about what is the outcome.
In front of the mempool, exists a transaction blacklist, which can trigger this error. Specifically, this error means that a transaction with the same hash was either:
Part of recently mined block
Detected as invalid during block production and removed from the pool.
Additionally, this error can occur when:
The transaction reaches it's longevity, i.e. is not mined for TransactionValidation::longevity blocks after being imported to the pool.
By default longevity is set to u64::max so this normally should not be the problem.
In any case -ltxpool=log should reveal more details around this error.
A transaction is only temporarily banned because it will be removed from the blacklist when either:
30 minutes pass
There are more than 4,000 transactions on the blacklist
Check out core/transaction-pool/graph/src/rotator.rs.

Outlook REST API 410 Error: SyncStateNotFound

I get a 410 when syncing messages:
{\"code\":\"SyncStateNotFound\",\"message\":\"The sync state
generation is not found; generation=1;[highest=4][4][2][3].\"}
This only occurs when syncing messages for select mailfolders on select accounts. It occurs when making a post-initial sync using the relevant delta token. I can recreate this via making
GET https://outlook.office365.com/api/v2.0/me/MailFolders('{folder_id}')/messages/?$deltaToken={delta_token}
In Microsoft's Outlook Sandbox.
Here are the literal steps it takes to reproduce deterministically:
1) Initial Message Sync:
GET https://outlook.office365.com/api/v2.0/me/MailFolders('{folder_id}')/messages
2) Sync with initial delta token:
GET https://outlook.office365.com/api/v2.0/me/MailFolders('{folder_id}')/messages/?$deltaToken={delta_token}
3) Sync with skip token until delta token:
GET https://outlook.office365.com/api/v2.0/me/MailFolders('{folder_id}')/messages/?$skipToken={skip_token}
4) ERROR OCCURS HERE: Mailfolder receives update, so I re-sync messages with delta token from (3). The call below throws a 410 and I can't sync messages.
GET https://outlook.office365.com/api/v2.0/me/MailFolders('{folder_id}')/messages/?$deltaToken={delta_token}
To reiterate: I've isolated this to just testing in the Outlook sandbox, and it still occurs. Testing as in making the GET call to sync (i.e., make perform (2)) using the deltaToken from (3) and its corresponding folderId as query parameters.
Dumb Mistake: Passed in initial delta token as opposed to current.

reading EMV card using PPSE and not PSE

I'm trying to read the data off a contactless Visa Paywave card.
For the Paywave, I have to submit a SELECT using PPSE (2PAY.SYS.DDF01) instead of PSE (1PAY.SYS.DDF01).
The EMV book 1, section 11.3.4, table 43 only describes how to interpret the response for a successful SELECT command using PSE. Does anyone know or can refer me to a source that shows how to process the data returned from a successful SELECT command using PPSE?
Here's my request APDU:
00A404000e325041592e5359532e444446303100
Here's the response:
6F2F840E325041592E5359532E4444463031A51DBF0C1A61184F07A0000000031010500A564953412044454249548701019000
I understand tag 84, tag 85, tag BF0C from the response. According to the examples for reading PSE, I should be able to just send GET PROCESSION OPTIONS (to get the AIP and AFL) with PDOL = null after this successful response as follows: 80A80000830000.
But request 80A80000830000 returns error code 6985 - Command not allowed; conditions of use not satisfied.
I also tried reading all the files after successfully selecting the PPSE by traversing through every single SFI (0-30) and every single record (0-16) of each SFI. Yes, I also did the 3 bit shift and bitwise-OR the SFI with 0x4. But I got no data.
I'm stuck, any help that would point me into getting some info from my Paywave card would be appreciated!
Have you tried this tool from EMVLAB http://www.emvlab.org/emvtags/
Using that tool,
http://www.emvlab.org/tlvutils/?data=6F2F840E325041592E5359532E4444463031A51DBF0C1A61184F07A0000000031010500A564953412044454249548701019000
2PAY.SYS.DDF01 is for contactless (e.g. NFC ) cards, while 1PAY.SYS.DDF01 is for contact cards.
After successfully (SW1 SW2 = 90 00) reading a PSE, you should only search for the SFI (tag 88) which is a mandatory field in the FCI template returned.
With the SFI as your start index, your would have to read the records starting from the start index until you get a 6A83 (RECORD_NOT_FOUND). E.g. if your SFI is 1, you would do a readRecord with record_number=1. That would probably be successful. Then you increament record_number to 2 and do readRecord again. The increament to 3 .... Repeat it until you get 6A83 as your status.
The records read would be ADFs (at least 1). Then your would have to compare the read ADF Names with what your terminal support and also based on the ASI (Application Selection Indicator). At the end you would have a list of possible ADFs (Candidate list)
All the above steps (1-3) are documented in chapter 12.3.2 Book1 v4.3 of the EMV spec.
You would have to make a final selection (Chapter 12.4 Book1)
Read the spec book 1 chapter 12.3 - 12.4 for all the detailed steps.
You seem to have the flow mixed up a bit, you want to:
Send 1PAY or 2PAY, it doesn't actually matter for all of the cards I've tested. This will return a list of the AIDs available on the card. Alternately you can just select an AID straight away if you know it's there but good practice would be to check first.
Get the list of AIDs returned in response to 1PAY/2PAY, in PayWave's case this will probably be A0000000031010 if you sent 2PAY but you may get more if you send 1PAY.
Select one of the AIDs sent back (or one you already know is on there).
Then loop through the SFIs and records sending the Read Records command to get the data.
You don't have to send Get Processing Options before sending the Read Records command even though that's now a normal transaction flow goes.
I think the information you're looking for is available from this VISA website. But only if you're a registered and/or licensed partner of VISA.
EDIT: Looking at the resulting TLV struct under BF0C:
tag=0xBF0C, length=0x1A
tag=0x61, length=0x18
tag=0x4F, length=0x07, value=0xA0000000031010 // looks like an AID to me
tag=0x50, length=0x0A, value="VISA DEBIT"
tag=0x87, length=0x01, value=0x01
I would guess that you need to first select A0000000031010 before getting the processing options.
I was selecting application 2PAY.SYS.DDF01. when I should have been selecting AID = 0xA0000000031010. It looks like there's no records under application 2PAY.SYS.DDF01.
But there was 1 record under application 0xA0000000031010. After I got this application, I performed a READ RECORD, and the first record gave me the PAN and all the credit card info I wanted.
Thanks everyone for chiming in.

Resources